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

Change DuplicatesStrategy from EXCLUDE to INCLUDE #756

Merged
merged 3 commits into from
Mar 31, 2022

Conversation

georgecao
Copy link
Contributor

I just build JBake from source by run ./gradlew clean build distZip, and run jbake command in the terminal, I got the following:

➜  jbake git:(ds) jbake 
JBake v${jbakeVersion} (${timestamp} ${gitHash}#) [http://jbake.org]

It seems that build process did not expand variables defined in default.properties.

# application version
version=v${jbakeVersion}
# build timestamp
build.timestamp=${timestamp}
# abbreviated git hash
git.hash=${gitHash}

I retried the build by setting duplicatesStrategy = DuplicatesStrategy.FAIL, then it failed.
But use duplicatesStrategy = DuplicatesStrategy.INHERIT, the build process complains

Entry default.properties is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.3.3/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

Then I tried duplicatesStrategy = DuplicatesStrategy.INCLUDE, works like a charm. Although it may not be the root cause...

@georgecao georgecao changed the title Change DuplicatesStrategy from EXCLUDE to INHERIT Change DuplicatesStrategy from EXCLUDE to INCLUDE Mar 18, 2022
@georgecao
Copy link
Contributor Author

@jonbullock

@jonbullock jonbullock self-assigned this Mar 24, 2022
@jonbullock
Copy link
Member

Thanks for raising this, I want to understand why this change was required before a decision is made on how to proceed. As value substitution has worked previously which suggests a recent change may have caused this.

@jonbullock jonbullock added this to the v2.7.0 milestone Mar 24, 2022
Copy link
Member

@jonbullock jonbullock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I understand the cause of this now. Could you change the whole processResources block to:

processResources {
    filesMatching("default.properties") {
        expand jbakeVersion: project.version,
            timestamp: grgit.head().dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss'['VV']'")),
            gitHash: grgit.head().abbreviatedId
    }
}

Stops the duplication and the need for a strategy at all.

@georgecao
Copy link
Contributor Author

@jonbullock PTAL

Copy link
Member

@jonbullock jonbullock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@jonbullock jonbullock merged commit 4d5cd56 into jbake-org:master Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants