I don't understand why there is the task 'buildNeeded' which is provided by the java plugin. Does not task 'build' solve the problem? The gradle documentation says:
buildNeeded: Performs a full build of the project and all projects it depends on.
and
build: Performs a full build of the project.
Should / does not the task 'build' compile and build all the necessary things? Why to distinguish between 'build' and 'buildNeeded'?
With multi-project builds this becomes possible because each subproject contains its own source code and configuration. Not only can you create a different jar file based on different source code, but you could just as easily setup a subproject to compile Kotlin, Scala, Groovy, or even C++.
The Java Gradle Plugin development plugin can be used to assist in the development of Gradle plugins. It automatically applies the Java Library plugin, adds the gradleApi() dependency to the api configuration and performs validation of plugin metadata during jar task execution.
To get an overview of all Gradle tasks in our project, we need to run the tasks task. Since Gradle 5.1, we can use the --group option followed by a group name. Gradle will then show all tasks belonging to the group and not the other tasks in the project.
buildNeeded
runs a full build
for all projects that a project depends on. In particular it runs test
for the depended-on projects, which can make sense if you want to play it safe. By comparison, build
only runs a minimum set of tasks for the depended-on projects (e.g. jar
), just enough to satisfy the dependency. build
is used more often than buildNeeded
.
build does not call a full build on all child projects.
If you project has no dependent projects it doesn't make any difference.
The idea is that if you change API within a parent project you want to recompile all child projects with the new one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With