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