ilPittiz
ilPittiz

Reputation: 754

Grails 4 - Gradle 'assemble' task not generating .war.original archive

I just upgraded my Grails web-app from version 3.2 to 4.0.

I have a provided dependency in build.gradle (fairly common configuration):

dependencies {
    ...
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    provided "org.springframework.boot:spring-boot-starter-tomcat"
    ...
}

I’ve just noticed that by executing Gradle assemble task I don’t get the myApp.war.original archive anymore (which used to be build without all provided libs), but only the one including provided dependencies.

Am I missing something here? I'd really like to spare those ~4MB of jars in lib-provided folder. Thanks in advance!


Update 1

Following @ck1's advice i changed provided dependency to providedCompile, but the result is the same. Though I already use the war plugin, I noticed that the sequence of tasks initiated by assemble task is:

> Task :assetCompile
Finished Precompiling Assets
> Task :compileJava
> Task :compileGroovy
> Task :buildProperties
> Task :processResources
> Task :classes
> Task :compileWebappGroovyPages NO-SOURCE
> Task :compileGroovyPages
> Task :compileGsonViews
> Task :findMainClass
> Task :bootWar
> Task :war SKIPPED
> Task :assemble

So the war task is skipped in favor of the new bootWar task (not available in Gradle 3, used by Grails 3). Any way to force it? Or is it something the plugin should already support?


Update 2

After some research, I added to build.gradle

war {
    enabled = true
}

and was able to get the war task to execute:

> Task :assetCompile
Finished Precompiling Assets
> Task :compileJava
> Task :compileGroovy
> Task :buildProperties
> Task :processResources
> Task :classes
> Task :compileWebappGroovyPages NO-SOURCE
> Task :compileGroovyPages
> Task :compileGsonViews
> Task :findMainClass
> Task :bootWar
> Task :war           // not skipped
> Task :assemble

I basically got to where I wanted to, i.e. get a .war archive without all the provided dependencies; differently from before though, not a pair of .war archives (myApp.war and myApp.war.original) but a single one named myApp.war not including the unneeded stuff.

But I'm still pretty much confused, as Spring Boot's Gradle plugin documentation states bootWar is an extension of war.

The bootRepackage task has been replaced with bootJar and bootWar tasks for building executable jars and wars respectively. Both tasks extend their equivalent standard Gradle jar or war task, giving you access to all of the usual configuration options and behaviour.

But then Spring Boot 2.0 Migration Guide states war task is expected to be skipped:

The bootRepackage task has been replaced with bootJar and bootWar tasks for building executable jars and wars respectively. The jar and war tasks are no longer involved.

So again, what am I missing out?

Upvotes: 3

Views: 975

Answers (1)

ck1
ck1

Reputation: 5443

You should replace provided with either the providedCompile or providedRuntime dependency configuration from the war plugin.

These two configurations have the same scope as the respective compile and runtime configurations, except that they are not added to the WAR archive.

Reference:

https://docs.gradle.org/4.10.2/userguide/war_plugin.html

Upvotes: 0

Related Questions