Gradle 4.x - 'jar' is not generated

Hi, i’m trying to migrate build of large project from gradle 3.x to 4.3.1 and experience some very strange problem - ‘jar’ task does not generate any output.

Output of the clean build is following:

:my-dummy-module-api:jar UP-TO-DATE

so … it says that JAR is “UP-TO-DATE”, but file is missing at all.
Executing build with ‘–debug’ says

No discovered inputs for task ':my-dummy-module-ap:jar'
Skipping task ':my-dummy-module-ap:jar' as it is up-to-date (took 0.011 secs).

Our configuration of ‘jar’ task does not specify inputs and according to documentation this way all output files should be included -> include(includeSpec)

If includes are not provided, then all files in this container will be included.

What’s wrong? Any hints? How the problem can be diagnosed further?

Hi @xtracoder,

I guess the bundle task is changing something with the inputs to the jar file. What are the plugins you have applied? Can you maybe share a build scan?
Is the problem solved by running a clean build, or by removing the .gradle directory and then running a clean build?


Thanks for the hint. While digging the problem further I’ve noticed another line in log

[DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Clean stale outputs' started
[INFO] [org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter] Deleting stale output file: ...\build\libs\my-dummy-module-api-X.X.X.X-SNAPSHOT.jar

So, steps actually happening look like following:

  • ‘bundle’ task actually generates a ‘JAR’ file (via bnd tools)
  • native Gradle task executed later - deletes that file and does nothing else

The final result - “no jar file”.

So far I just disabled ‘jar’ task to keep other task dependencies - this seem to fix that problem.

Probably there is some better approach … ‘jar’ task is automatically added by ‘java’ plugin, we do not needed because OSGI .jar is generated in ‘bundle’, but it stays in task dependencies …