Without Gradle War Plugin, bootRepackage
task depends on jar
task but with Gradle War Plugin, it depends on war
task.
How can I change it to depend on jar
task even though I'm using Gradle War Plugin?
UPDATE:
I'm using war
task to create a war file including documents to be deployed to a documentation server and I want to use bootRepackage
d jar file to provide a service. My war
task depends on asciidoctor
task which depends on test
task (I'm using Spring REST Docs.) but I don't want to run asciidoctor
task or test
task when using bootRepackage
task.
I solved my problem with the following setup:
ext {
mainClassName = 'com.izeye.throwaway.Application'
}
task myBootRepackage(type: BootRepackage, dependsOn: jar) {
}
but I'm not sure this is a good practice.
This is a sample project having the above configuration:
https://github.com/izeye/spring-boot-throwaway-branches/tree/war
We can add Spring Boot support into our Gradle project by applying the Spring Boot Gradle plugin. We can select the preferred Spring Boot version by setting the version of the Spring Boot Gradle plugin. This means that we don't have to set the dependency versions of the Spring Boot dependencies.
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.
The Spring Boot Gradle Plugin provides Spring Boot support in Gradle. It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by spring-boot-dependencies . Spring Boot's Gradle plugin requires Gradle 6.8, 6.9, or 7.
You should have been able to do this:
bootRepackage {
withJarTask jar
}
While this correctly causes the jar task's jar to be repackaged, it doesn't remove the dependency on the war task. This is another symptom of this Spring Boot issue.
Until this issue has been resolved, the approach that you've taken – declaring your own BootRepackage task and manually configuring the tasks that it depends upon – is your best option.
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