我有一个由gradle包装器编译的新Grails 3.1.7项目。该项目只是由grails create-app
创建的基础项目当我跑步时: ./gradlew --info clean jar bootRepackage
我在构建的最后部分看到了以下输出
: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
}
答案 0 :(得分:0)
,bootRepackage
任务已经处理了所有jar路径的jar任务。
如果应用war
插件(默认情况下),它现在只处理War
任务。
另外,如果应用了gradle(w) assemble
插件,grails war
(例如War
也使用它)只构建一个war(无jar)假象。这同样适用于spring-boot。
但这通常很好,因为战争也是可执行的(即java -jar my.war
)。
所以,如果你真的想要构建那个jar文物并且应该重新打包,请相应地重新配置bootRepackage
任务:
bootRepackage.withJarTask = jar
然而 - 如果没有充分的理由反对它 - 我会说更好地坚持战争文件并将其用作可执行文件。或删除使War
和assemble
默认构建/处理jar工件的bootRepackage
插件。