[JAVA] Control tasks performed in Gradle

Gradle, are you using it? It's also great for Java development. However, I have had one complaint from before. That is, compilation is executed every time Javadoc is created or Jar is created.

It doesn't take long because I already have a cache, but I wanted to control it a little smarter.

When I looked it up when I had time, the key was in the figure below.

image https://docs.gradle.org/current/userguide/java_plugin.htmlから拝借

From this figure, you can see that when you run gradle build, assemble, check and related tasks are executed one after another, and you should run classes to compile ...

Also, if you want to execute a test-type task, you can execute test, and it seems that classes will be executed when you execute this.

As a result, we found the following. If you want to compile only, execute the following command

gradle classes

If you want to run only the test, execute the following command (compilation must already be completed)

gradle test -x classes
//-x excludes the task

By keeping this figure in mind, it seems that you will not have to spend time on unnecessary tasks.

Recommended Posts

Control tasks performed in Gradle
[Gradle] Build operations often performed in Java projects
gradle tasks Japanese translation
Jigsaw notes in Gradle
Copy dependent jars in Gradle 5
[Gradle] About Java plug-in tasks
Spring Boot 2 multi-project in Gradle
Popular trends in gradle and maven
Automatically specify version in gradle project
Do HelloWorld in Java / IntelliJ / Gradle
Make multi-project executable JAR in Gradle
Browse local Maven artifacts in Gradle
Notes on signal control in Java
Event processing is performed in Spring.
Implement Spring Boot application in Gradle
Hello world in Java and Gradle