What is the difference between "gradle build" and "gradle bootJar"? Why would I use bootJar if I can still create the artifact using build?
bootJar on the other hand is a specific task added by Spring Boot Gradle plugin that, when the java plugin is present, attaches itself to the assemble lifecycle task. The assemble task is automatically configured to depend upon the bootJar task so running assemble (or build ) will also run the bootJar task.
Gradle is a build automation tool known for its flexibility to build software. A build automation tool is used to automate the creation of applications. The building process includes compiling, linking, and packaging the code. The process becomes more consistent with the help of build automation tools.
The Spring Boot gradle plugin provides the bootRun task that allows a developer to start the application in a “developer mode” without first building a JAR file and then starting this JAR file. Thus, it's a quick way to test the latest changes you made to the codebase.
public class BootWar extends War implements BootArchive. A custom War task that produces a Spring Boot executable war.
In contrast to the build.gradle file, only one settings.gradle file is executed per Gradle build. We can use it to define the projects of a multi-project build. Besides, we can also possible to register code as part of different life cycle hooks of a build.
Some of those tasks are assemble, check, build, jar, javadoc, clean and many more. These tasks are also set up in such a way, that they describe a useful dependency graph for a Java project, meaning it's generally enough to execute the build task and Gradle (and the Java plugin) will make sure, that all necessary tasks are performed.
Overview The Spring Boot Gradle plugin helps us manage Spring Boot dependencies, as well as package and run our application when using Gradle as a build tool. In this tutorial, we'll discuss how we can add and configure the plugin, and then we'll see how to build and run a Spring Boot project. 2.
The gradlew script is tied to a specific Gradle version. That’s very useful, because it means whoever manages the project can enforce what version of Gradle should be used to build it. Gradle features are not always compatible between versions, so using the Gradle wrapper means the project will get built consistently every time.
build
is a lifecycle task contributed by the Base Plugin. It is
Intended to build everything, including running all tests, producing the production artifacts and generating documentation. You will probably rarely attach concrete tasks directly to
build
asassemble
andcheck
are typically more appropriate.
bootJar
on the other hand is a specific task added by Spring Boot Gradle plugin that, when the java
plugin is present, attaches itself to the assemble
lifecycle task.
The
assemble
task is automatically configured to depend upon thebootJar
task so runningassemble
(orbuild
) will also run thebootJar
task.(Packaging Executable Jars)
You want to use bootJar
if you're only interested in building the executable jar and not interested in executing tests, code coverage, static code analysis or whatever is attached to the check
lifecycle task.
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