Difference between jar and assemble task

what is the difference between assemble and jar task of java plugin in gradle?

I tried executing them with a sample Hello world project they both seems to do the same job.

‘assemble’ and ‘build’ are what we call ‘lifecycle’ tasks. They are convenient names for doing several things.

‘jar’ is a task that only builds the main jar.

You can see all the tasks that the Java plugin adds here: https://docs.gradle.org/current/userguide/java_plugin.html#N120B1

In this case, with no other plugins applied, assemble and jar will seem to do the same thing. But if you had other tasks that “assembled” things (e.g., a javadoc jar or sources jar), assemble might do more.

1 Like