将gradle从4.10.1更新到6.4.1时遇到gradle构建问题

时间:2020-07-16 14:37:16

标签: gradle

在更新gradle时,我在Jenkins中遇到以下问题;

任务':xxx:extractModuleInfo'的执行失败。 06:38:45>工件xxxxx.jar不是由此版本生产的。

我一直在研究此问题,我认为在更新gradle时这是已知问题。 请参阅此链接中的发布Spring Boot应用程序部分:

https://docs.gradle.org/current/userguide/upgrading_version_6.html

这是应用程序的构建版本:

import java.time.format.DateTimeFormatter
import java.time.ZonedDateTime

apply plugin: 'org.springframework.boot'
apply plugin: 'war'

def checkpoint = version

description 'Spring Boot / MVC web application (controllers for SEAR services, etc)'

springBoot {
  // Generates build info and will be used in /info endpoint
  buildInfo()
}
/*
bootRun {
  addResources = false
  systemProperties = System.properties
  main = 'creditcard.lifecycle.CreditCardApplication'
  jvmArgs = [ "-Djavax.net.ssl.trustStore=..//cacerts"]
}
*/

dependencies {
  implementation project(':xx')
  implementation project(':xx')
  implementation project(':xxxx')
  implementation project(':xxxxxxxxxxxxxxxxxxxxxx')
  implementation project(':xxxxxxxxxxxxxxxxxxxxxxx')
  implementation project(':xxxxxxxxxxxxxxx')
  implementation project(':xxxxxxxxxxxxxxxx')
  implementation project(':xxx')
  implementation project(':xxxxx)
  implementation project(':xxxxx')
  implementation project(':xxxxx')
  implementation project(':xxxxx')
  implementation project(':xxxxx')
  implementation libraries.wf_retrofit
  implementation libraries.commons_lang3

  implementation ('org.springframework.boot:spring-boot-starter-web') {
    exclude module: "spring-boot-starter-tomcat"
    exclude module: "tomcat-embed-core"
    exclude module: "tomcat-embed-el"
    exclude module: "tomcat-embed-websocket"
    exclude module: "tomcat-annotations-api"
  }

  implementation ('org.springframework.boot:spring-boot-starter-tomcat:1.5.8.RELEASE')



  implementation ('wf.authx:authx:0.9+')

  implementation libraries.jackson

  implementation libraries.searj
  implementation libraries.commonscodec
  implementation ('org.springframework.boot:spring-boot-starter-actuator')
  //include schema after it is built
  //compile group: 'wf.ebs', name: 'schemas', version: '2018.1-SNAPSHOT'
  runtimeOnly 'org.springframework.boot:spring-boot-starter-undertow'
}

configurations {
  compile.exclude module: 'spring-boot-starter-tomcat'
  compile.exclude group: 'org.apache.tomcat'
  compile.exclude module: "tomcat-embed-el"
  compile.exclude module: "searj-authx-spring-boot-starter"
}


task createCheckpointFile {
  doLast {
    //Need to pass variables as jenkins parameters
    //def checkpoint = "xxxx_${Release}.${BUILD_NUMBER}"
    println "Checkpoint = ${checkpoint}"
    
    def TODAY_DT_US = ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z"))
    String fileContent = "BUILD_CHECKPOINT=${checkpoint}\nBUILD TSTAMP: ${TODAY_DT_US} \nBUILD_DIR=$projectDir"
    new File("${buildDir}/xxxxx.checkpoint").write(fileContent)
  }
}




/*
jar {
  from file("${buildDir}/xxxx.checkpoint")
  baseName = 'xxxxxx'
  manifest {
    attributes("Implementation-Title": "xxxx",
      "Implementation-Version": "$project.version")
  }
}
*/

//bootRepackage.enabled = false
//jar.dependsOn createCheckpointFile

war {
  enabled = true

  archiveFileName = 'xxxx.war'
  
  //copy-move
  webInf { from("${buildDir}/xxxx.checkpoint") }
}
war.dependsOn createCheckpointFile

该组件的功能如何将该检查添加到jar中?

1 个答案:

答案 0 :(得分:1)

如下所示在build.gradle中添加/修改jar任务

jar {
    enabled = true
}

这应该可以解决问题