Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use case for the task buildNeeded?

Tags:

java

gradle

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'?

like image 300
Cengiz Avatar asked Dec 12 '11 21:12

Cengiz


People also ask

What is the use of multi-project builds?

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++.

What is the purpose of a Gradle Java plugin?

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.

How do I list tasks in Gradle?

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.


2 Answers

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.

like image 125
Peter Niederwieser Avatar answered Nov 15 '22 15:11

Peter Niederwieser


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.

like image 23
Angelo Fuchs Avatar answered Nov 15 '22 15:11

Angelo Fuchs