Gradle Incremental Builds - possible to ignore manifest in up-to-date check?
build.gradle, gradle, jar, java
Solution
Given above declaration, and assuming that code hasn't changed, the `jar` task should only be out-of-date if `version` has changed. (Running with `--info` will tell you which file(s) have changed.) Best solution is to prevent that, at least at development time. (E.g. don't set `version` to `new Date()`.)
Also note that out-of-date does not cascade. Downstream tasks will only rerun if their inputs or outputs have changed. They don't care if upstream tasks were up-to-date or not.
Problem
The subject pretty much asks the question, but for more detail, I have the following in my `build.gradle`: ``` jar { manifest { attributes("Built-By": "Gradle") attributes("Build-Version": version) attributes("Main-Class": "somePackage.SomeClass") } } ``` When building, since the manifest is auto-generated, it always thinks the `jar` task is out of date, even if nothing has changed in the code. Ideally, I'd like to be able to check to see if the version is the same as the last build. If it is, and if previous task dependencies (`compileJava` et al) are all `UP-TO-DATE`, I'd like the jar task to report `UP-TO-DATE` as well. Failing that, I'd be pretty happy if I could just get the jar task to ignore the manifest file altogether. For an individual jar task this isn't such a big deal, but as soon as one jar reports that it's not `UP-TO-DATE`, all the tasks that depend on it then have to re-compile, re-jar, etc etc, which makes builds take way longer than they actually need to. And since the very first jar task in my dependency path reports that it's not up-to-date because of the manifest issue, that means the whole thing is forced to recompile/re-jar/re-war/re-ear/etc every-single-time, and we're talking about a few hundred thousand lines of code here. Anyway, if anybody knows of a way to solve this little annoyance I'd be grateful EDIT I also have a zip task that depends on the jar task: ``` task zip(type:Zip, dependsOn:jar) { from jar include jar.archiveName from '.' include 'run.bat' } ``` Running this command: ``` gradlew :myProject:zip -Pversion=1.0 ``` I consistently get the following output every time, even if I run it twice in a row with no changes anywhere: ``` :myProject:compileJava UP-TO-DATE :myProject:processResources UP-TO-DATE :myProject:classes UP-TO-DATE :myProject:jar :myProject:zip ```