Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot change output directory #775

Open
AlexCzar opened this issue Mar 20, 2023 · 6 comments
Open

cannot change output directory #775

AlexCzar opened this issue Mar 20, 2023 · 6 comments

Comments

@AlexCzar
Copy link

Repro

; mkdir jb-repro && cd jb-repro
; jbake -i
; cat << EOF > jbake.properties
destination.folder=target
EOF
; jbake -b
; ls -1

expected

assets
content
jbake.properties
target
^-----
templates

actual

assets
content
jbake.properties
output
^-----
templates

Environment

JBake installed manually, using the binary package from github releases.

; jbake --help | head -n1
JBake v2.7.0-rc.7 (2023-02-26 11:08:41[GMT] c4ab637#) [http://jbake.org]
; java -version
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)
; uname -a
Darwin user-workstation 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
@ottlinger
Copy link
Contributor

Hi, does

jbake -i . target

work out for you?

@AlexCzar
Copy link
Author

AlexCzar commented Mar 20, 2023

; jbake -i . target
JBake v2.7.0-rc.7 (2023-02-26 11:08:41[GMT] c4ab637#) [http://jbake.org]

17:12:26.154 ERROR jbake - Error: Required folder cannot be found! Expected to find [template.folder] at: /Users/username/Documents/jb-repro/./templates

But, I tried jbake -i && jbake . target and that does work.

@ottlinger
Copy link
Contributor

I can reconfirm the problem with JDK20 as well. The configuration code looked ok, but I assume that either the property is not read from the configuration file or is overwritten with the default instead .....

@AlexCzar
Copy link
Author

AlexCzar commented Mar 21, 2023

Interestingly:

; jbake -ls | rg -i 'destination\.?folder'
destination.folder......................: target                                  
destinationFolder.......................: /Users/username/Documents/worknotes/output

@AlexCzar
Copy link
Author

Looked at the code, and, I think, I know why.
Here's the potential culprit:

config = getJBakeConfigurationFactory().setEncoding(res.getPropertiesEncoding()).createDefaultJbakeConfiguration(res.getSource(), res.getDestination(), res.getConfig(), res.isClearCache());

and then, if we look at res.getDestination():
public File getDestination() {
if (destination != null) {
return new File(destination);
} else {
return new File(getSource(), "output");
}
}

and, finally:
public DefaultJBakeConfiguration createDefaultJbakeConfiguration(File sourceFolder, File destination, File propertiesFile, boolean isClearCache) throws JBakeException {
DefaultJBakeConfiguration configuration = (DefaultJBakeConfiguration) getConfigUtil().loadConfig(sourceFolder, propertiesFile);
configuration.setDestinationFolder(destination);
configuration.setClearCache(isClearCache);
return configuration;
}

So, if the destination directory is not specified on the command line, "output" value is set as if it came from the command line, and the rest of the code dutifully overwrites any other destination value that comes from the configuration.

@tymur-berezhnoi
Copy link

I have the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants