Hi,
I have a multi-project build with mostly Java and some Groovy stuff (Gradle 2.1). When building a dependent project, some of the parent projects are always rebuilt, even though nothing changed. When running gradle --debug I found that this is caused by a dynamically created manifest:
project(":A") {
Closure manifestClosure = {
attributes("CompanyName": solutionProperties['solution.company'] ?: rootProject.productCompany,
// more attributes ...
)
}
jar {
manifest manifestClosure
archiveName = "${baseName}.${extension}"
}
}
project(":B") {
dependencies {
compile project(":A")
}
}
This now always triggers a build of compileJava and jar as well:
./gradlew :B:compileJava
I understand that the manifest is not based on an input file so Gradle has no way of knowing whether the manifest and hence the jar has changed.
My question is now why the compile dependency to project A needs the jar (and hence the manifest) and not just the compiled output of project A?
I tried to change the dependencies of project B like this:
project(":B") {
dependencies {
compile project(':A').sourceSets.main.output
compile project(path: ':A', configuration:'compile')
}
}
The first line provides the compiled classes, the second the (transient) dependencies. This solved the issue for me but is a bit cumbersome, especially as I have more than one such project dependency. Is there a better way to configure this build dependency without triggering a recompile caused by the dynamically created manifest?
Regards,
Wolfgang