我刚刚将我的 Grails 网络应用程序从 3.2 版升级到 4.0 版。
我在 build.gradle
中有一个 provided
依赖项(相当常见的配置):
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"
...
}
我刚刚注意到,通过执行 Gradle assemble
任务,我不再获得 myApp.war.original
存档(过去是在没有提供所有内容的情况下构建的libs),但只有一个包含提供的依赖项。
我是不是漏掉了什么?我真的很想在 lib-provided
文件夹中保留那些 ~4MB 的 jar。
提前致谢!
更新 1
按照@ck1 的建议,我将provided
依赖项更改为providedCompile
,但结果是一样的。
虽然我已经使用了 war
插件,但我注意到 assemble
任务启动的任务序列是:
> 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
因此 war
任务被跳过以支持新的 bootWar
任务(在 Gradle 3 中不可用,由 Grails 3 使用)。
有什么办法强制吗?还是插件应该已经支持了?
更新 2
经过一些研究,我添加到build.gradle
war {
enabled = true
}
并且能够让 war
任务执行:
> 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
我基本上到达了我想去的地方,即获得一个没有所有提供的依赖项的 .war 存档;与以前不同的是,不是一对 .war 文件(myApp.war
和 myApp.war.original
)而是一个名为 myApp.war
不包括不需要的东西。
但我仍然很困惑,因为
Spring Boot's Gradle plugin documentation声明 bootWar
是 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.
然后Spring Boot 2.0 Migration Guide状态 war
任务预计将被跳过:
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.
那么,我又错过了什么?
最佳答案
您应该替换 provided
与 providedCompile
或 providedRuntime
来自 war
的依赖配置插件。
These two configurations have the same scope as the respective compile and runtime configurations, except that they are not added to the WAR archive.
引用:
关于gradle - Grails 4 - Gradle 'assemble' 任务不生成 .war.original 存档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59323898/