【问题标题】:Spring boot repackage: Jar task not repackaged (didn't match withJarTask)Spring boot 重新打包:Jar 任务未重新打包(与 JarTask 不匹配)
【发布时间】:2016-06-01 03:50:21
【问题描述】:

我有一个由 gradle wrapper 编译的新 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
}

此示例的代码位于:https://github.com/liftyourgame/helloworld

【问题讨论】:

    标签: grails gradle spring-boot


    【解决方案1】:

    在 grails-3.1.5 之前,bootRepackage 任务已处理所有不希望用于路径 jar 的 jar 任务。

    如果应用了War 插件,它现在只处理war 任务(默认情况下)。

    此外,如果应用了War 插件,gradle(w) assemble(例如,grails war 也使用它)仅构建一个战争(无 jar)工件。这同样适用于 spring-boot。

    但这通常很好,因为战争也是可执行的(即java -jar my.war)。

    因此,如果您真的想构建该 jar 工件并且应该重新打包,请相应地重新配置 bootRepackage 任务:

    bootRepackage.withJarTask = jar
    

    但是 - 如果没有充分的理由反对它 - 我会说最好坚持使用 war 文件并将其用作可执行文件。或删除使assemblebootRepackage 默认构建/处理jar 工件的War 插件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-08
      • 1970-01-01
      • 2017-01-16
      • 2019-07-05
      • 2017-05-31
      • 1970-01-01
      • 2021-04-27
      • 2023-02-10
      相关资源
      最近更新 更多