1

I am getting the following issue in Jenkins when updating gradle;

Execution failed for task ':xxx:extractModuleInfo'. 06:38:45 > Artifact xxxxx.jar wasn't produced by this build.

I have been researching on the issue and I think it's known issue when updating gradle. Please refer to the section Publishing Spring Boot Applications in this link:

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

Here is the buildgradle of the application:

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

How is that components feature adding that check to the jar?

Fernando
  • 381
  • 1
  • 5
  • 20

1 Answers1

2

Add/modify jar task as below in build.gradle

jar {
    enabled = true
}

This should fix the issue

ynerdy
  • 564
  • 4
  • 7
  • Why does that help? – Lee Meador Feb 02 '21 at 23:45
  • 1
    @LeeMeador Starting from 6, Gradle performs a sanity check before uploading, to make sure you don’t upload stale files (files produced by another build like fat jar). This introduces a problem with Spring Boot applications which are uploaded using the components.java component. This is caused by the fact that the main jar task is disabled by the Spring Boot application. A workaround is to tell Gradle what to upload. You might want to re-enable the jar task, and add the bootJar with a different classifier. jar { enabled = true } bootJar { classifier = 'application' } – ynerdy May 24 '21 at 06:31