I am working on a Gradle project, have added a task to the build.gradle to run the gitProperties task (com.gorylenko.gradle-git-properties).
It builds the output file just fine, but I need the processResources task to always run after the generateGitProperties task. Whenever I run the build, processResources shows UP-TO-DATE.
task printGitProperties { // make sure generateGitProperties task to execute before accessing generated properties
dependsOn generateGitProperties
doLast {
println project.ext.gitProps
}
}
gitProperties {
gitPropertiesResourceDir = file("${project.rootDir}/src/main/deploy")
extProperty = 'gitProps'
println tasks
}
generateGitProperties.outputs.upToDateWhen { false } // make sure the generateGitProperties task always executes (even when git.properties is not changed)
generateGitProperties.finalizedBy printGitProperties
tasks.processResources.dependsOn generateGitProperties.gitProperties
tasks.findByName('processResources').mustRunAfter 'generateGitProperties'
//tasks.processResources.dependsOn(generateGitProperties)
How do I force processResources to always run? The commented code is just a fraction of everything I have tried.
CodePudding user response:
tasks.processResources.outputs.upToDateWhen { false }
