我有一个新的Grails 3.1.7项目,由gradle包装器编译。该项目只是由以下人员创建的基础项目:grails create-app
当我运行时: ./gradlew --info clean jar boot重新打包
我在构建的最后一部分看到以下输出
:jar (Thread[main,5,main]) started.
:jar
Executing task ':jar' (up-to-date check took 0.023 secs) due to:
Output file /var/jenkins_home/workspace/helloworld/build/libs/helloworld-0.1.jar has changed.
Output file /var/jenkins_home/workspace/helloworld/build/libs/helloworld-0.1.jar has been removed.
:jar (Thread[main,5,main]) completed. Took 0.259 secs.
:findMainClass (Thread[main,5,main]) started.
:findMainClass
Executing task ':findMainClass' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
:findMainClass (Thread[main,5,main]) completed. Took 0.041 secs.
:war (Thread[main,5,main]) started.
:war
Executing task ':war' (up-to-date check took 0.039 secs) due to:
Output file /var/jenkins_home/workspace/helloworld/build/libs/helloworld-0.1.war has changed.
Output file /var/jenkins_home/workspace/helloworld/build/libs/helloworld-0.1.war has been removed.
:war (Thread[main,5,main]) completed. Took 4.305 secs.
:bootRepackage (Thread[main,5,main]) started.
:bootRepackage
Executing task ':bootRepackage' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
Jar task not repackaged (didn't match withJarTask): task ':jar'
Jar task not repackaged (didn't match withJarTask): task ':pathingJar'
Jar task not repackaged (didn't match withJarTask): task ':pathingJarCommand'
Setting mainClass: helloworld.Application
:bootRepackage (Thread[main,5,main]) completed. Took 0.94 secs.
BUILD SUCCESSFUL
重新打包任务中发生了什么?
这是什么意思?
Jar task not repackaged (didn't match withJarTask): task ':jar'
gradle.properties:
grailsVersion=3.1.7
gradleWrapperVersion=2.13
build.gradle:
buildscript {
ext {
grailsVersion = project.grailsVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.8.2"
classpath "org.grails.plugins:hibernate4:5.0.6"
}
}
version "0.1"
group "helloworld"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"org.grails.grails-gsp"
apply plugin:"asset-pipeline"
ext {
grailsVersion = project.grailsVersion
gradleWrapperVersion = project.gradleWrapperVersion
}
repositories {
mavenLocal()
maven { url "https://repo.grails.org/grails/core" }
}
dependencyManagement {
imports {
mavenBom "org.grails:grails-bom:$grailsVersion"
}
applyMavenExclusions false
}
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
console "org.grails:grails-console"
profile "org.grails.profiles:web:3.1.7"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}
task wrapper(type: Wrapper) {
gradleVersion = gradleWrapperVersion
}
assets {
minifyJs = true
minifyCss = true
}
此示例的代码位于:https://github.com/liftyourgame/helloworld
在 grails-3.1.5 之前,bootRepackage
任务已经处理了所有 jar 任务,这对于路径 jar 来说是不需要的。
现在,如果应用了War
插件(默认情况下),它仅处理war
任务。
此外,如果应用War
插件,则gradle(w) assemble
(grails war
也使用)仅构建 WAR(无 jar)工件。 这同样适用于 Spring-boot。
但这通常很好,因为战争也是可执行的(即 java -jar my.war
)。
因此,如果您确实想要构建该 JAR 工件并且应该对其进行重新打包,请相应地重新配置bootRepackage
任务:
bootRepackage.withJarTask = jar
但是 - 如果没有充分的理由反对它 - 我会说最好坚持使用 war 文件并将其用作可执行文件。 或删除War
插件,该插件使assemble
和bootRepackage
默认用于构建/处理 jar 工件。