I’m surprised this isn’t working. In fact, several user have complained about the opposite: they would like Gradle to ignore changes to Manifest attributes and not rebuild the jar file.
If you run the build with --info you’ll see messages about why Gradle considers each task to be up-to-date. Is it possible that your jar file contains no sources?
The jar file contains a HelloWorld class and a Hello World Junit test. Both are working (The jar prints hello world if I run “gradle clean” before the build and the test fails the build if i change it).
The info logs say:
Skipping task ‘:classes’ as it has no actions.
:classes UP-TO-DATE
:classes (Thread[main,5,main]) completed. Took 0.015 secs.
:jar (Thread[main,5,main]) started.
:jar
Skipping task ‘:jar’ as it is up-to-date (took 0.016 secs).
:jar UP-TO-DATE
:jar (Thread[main,5,main]) completed. Took 0.016 secs.
:assemble (Thread[main,5,main]) started.
:assemble
Skipping task ‘:assemble’ as it has no actions.
:assemble UP-TO-DATE
:assemble (Thread[main,5,main]) completed. Took 0.016 secs.
:compileTestJava (Thread[main,5,main]) started.
:compileTestJava
Skipping task ‘:compileTestJava’ as it is up-to-date (took 0.234 secs).
Same issue here. We’re building a tar.gz providing an executable jar with its 3rd party dependencies in a subfolder. The MANIFEST.MF inside the JAR contains the classpath with all these libraries from runtime dependency. Changing only a 3rd dependency, i.e. by upgrading its version results in a UP-TO-DATE JAR-Task.