Update to JDK 17 and Gradle 7.4.2

I am using JDK 17 (temurin-17.jdk), so I need to use gradle version 7 > (I am using https://services.gradle.org/distributions/gradle-7.4.2-bin.zip);

When I try to build my project, I get the following error:

**

Task :compileJava Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

Task :bootJar FAILED

FAILURE: Build failed with an exception.

What went wrong: A problem was found with the configuration of task ':bootJar' (type 'BootJar'). In plugin 'org.springframework.boot' type 'org.springframework.boot.gradle.tasks.bundling.BootJar' property 'bootInf' is missing an input or output annotation.

Reason: A property without annotation isn't considered during up-to-date checking.

Possible solutions:

Add an input or output annotation. Mark it as @internal. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#missing_annotation for more details about this problem.

**

My build.gradle looks like this:

buildscript {
  repositories {
    mavenLocal()
    maven {
      url "https://plugins.gradle.org/m2/"
    }
    mavenCentral()
    jcenter()
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.1.RELEASE")
    classpath("net.researchgate:gradle-release:2.8.1")
    classpath("com.bmuschko:gradle-docker-plugin:3.1.0")
    classpath("gradle.plugin.org.hidetake:gradle-swagger-generator-plugin:2.18.1")
  }
}

 //Technically any privileged credentials will work, but intended to be the service account
def service_username = System.getenv('SERVICE_USERNAME')
def service_password = System.getenv('SERVICE_PASSWORD')

def configDir = "$project.projectDir/config"

repositories {
    mavenLocal()
    maven { url "https://ci1.mycwt.com/nexus/repository/Development_Artifacts/" }
    mavenCentral()
        maven { url "https://plugins.gradle.org/m2/" }
    jcenter()
}

group = 'com.somethingSomething'

apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'idea'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'net.researchgate.release'
apply plugin: 'org.hidetake.swagger.generator'


bootRun {
    jvmArgs '-javaagent:AppServerAgent-1.8-20.8.0.30686/ver20.8.0.30686/javaagent.jar'
}

test{
  jvmArgs  '-javaagent:AppServerAgent-1.8-20.8.0.30686/ver20.8.0.30686/javaagent.jar'
}
/**
 * PMD Configurations
 */
pmd {
    toolVersion = '6.22.0'
    ruleSetFiles = files('config/cwtRuleSet.xml')
    ruleSets = []
    ignoreFailures = false
    pmdTest.enabled = false
}
tasks.withType(Pmd) {
    reports {
        xml.enabled = true
        html.enabled = true
    }
}

/**
 * Jacoco Configurations
 */
jacoco {
    toolVersion = "0.8.7"
}

jacocoTestCoverageVerification{
    violationRules {
        rule {
            limit {
                minimum = 0.93
            }
        }
        afterEvaluate {
            classDirectories.setFrom(files(classDirectories.files.collect {
                fileTree(dir: it, excludes: ['**/com/somethingSomething/config/**',
                                             '**/com/somethingSomething//nextgen/config/**',
                                             '**/com/somethingSomething/model/**',
                                             '**/com/somethingSomething/*Application*',
                                             '**/com/somethingSomething//nextgen/web/**',
                                             '**/com/somethingSomething/preferencing/service/Invalid*'])
            }))
        }
    }
}

jacocoTestReport {
    afterEvaluate {
        classDirectories.setFrom(files(classDirectories.files.collect {
            fileTree(dir: it, excludes: ['**/com/somethingSomething/config/**',
                                         '**/com/somethingSomething//nextgen/config/**',
                                         '**/com/somethingSomething/model/**',
                                         '**/com/somethingSomething/*Application*',
                                         '**/com/somethingSomething//nextgen/web/**',
                                         '**/com/somethingSomething/preferencing/service/Invalid*'])
        }))
    }
}

build.dependsOn jacocoTestCoverageVerification
build.dependsOn jacocoTestReport
jacocoTestCoverageVerification.shouldRunAfter jacocoTestReport

/**
 * Checkstyle Configurations
 */
checkstyle {
    toolVersion = 8.30
    ignoreFailures = false
    maxErrors = 0
    maxWarnings = 5 //There are known issues with lambdas and line wraps not being evaluated correctly in checkstyle
    configFile = project(':').file("$configDir/checkstyle/checkstyle.xml")
    configProperties = ['suppressionFile': project(':').file("$configDir/checkstyle/suppressions.xml")]
}

task generateJavaDocs(type: Javadoc) {
  source = sourceSets.main.allJava
  failOnError = false
  title= "Service"
}

release {
  afterReleaseBuild.dependsOn publish
}

publish {
  dependsOn build
    repositories {
        maven {
            {
                url= nexusReleaseURL
                credentials {
                    username = service_username
                    password = service_password
                }
            }
            {
                url= nexusSnapshotURL
                credentials {
                    username = service_username
                    password = service_password
                }
            }
        }
    }
}

bootJar {
  baseName = "${jarBaseName}"
  enabled = true
  //classifier = "${grgit.head().id}"
}

springBoot {
  mainClassName = "com.somethingSomething.ServiceApplication"
  buildInfo()
}

sourceCompatibility = 17
targetCompatibility = 17

dependencyManagement {
    imports {
        mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.1034'
    }
}

task bootRunWithLocalProfile {
    description 'This runs the application with the local profile activated, which uses local redis, logs to ' +
            'the console, and disables AppDynamics.'
    doFirst {
        bootRun.configure {
            systemProperty 'spring.profiles.active', 'local'
        }
    }
    group 'application'

    finalizedBy bootRun
}

task bootRunWithMockDataSources {
    description 'This runs the application with the local and mockdata profiles activated, which uses local redis, ' +
            'logs to the console, disables AppDynamics, and replaces select external integrations with mock ' +
            'services from mock-services'
    doFirst {
        println 'Make sure you have the appropriate mock-services running, or the server ' +
                'won\'t function properly...'
        bootRun.configure {
            systemProperty 'spring.profiles.active', 'local,mockdata'
        }
    }
    group 'application'

    finalizedBy bootRun
}

dependencies {
  implementation('com.amazonaws:aws-java-sdk-translate')

  implementation("org.springframework.boot:spring-boot-gradle-plugin:2.1.1.RELEASE")
  implementation("com.somethingSomething:commons:1.0-SNAPSHOT")

//  implementation("com.google.protobuf:protobuf-gradle-plugin:0.8.18")

  implementation("org.springframework.boot:spring-boot-starter-web")
  implementation("org.springframework.boot:spring-boot-starter-json")
  implementation("org.springframework.boot:spring-boot-starter-actuator")

  implementation("org.springframework.data:spring-data-redis")
  implementation("org.aspectj:aspectjweaver:1.8.8")
  implementation("org.apache.sis.core:sis-referencing:0.7")
  implementation("com.cwt.eit.springboot.utils:load-balancer-control:1.0.8")
  implementation("org.jblas:jblas:1.2.4");

  compileOnly('org.projectlombok:lombok:1.18.20')
  annotationProcessor('org.projectlombok:lombok:1.18.20')
  implementation('org.apache.commons:commons-lang3:3.4')
  implementation('io.dropwizard.metrics:metrics-core')
  implementation('com.ryantenney.metrics:metrics-spring:3.1.3')
  implementation('com.appdynamics.agent:agent-api:4.5.18.29239')
  implementation("org.apache.commons:commons-collections4:4.2")
  implementation("org.apache.commons:commons-pool2:2.6.0")
  implementation("org.json:json:20180813")
  implementation('com.cwt.dna:amenity-parser:2.3.16')

  implementation('javax.xml.bind:jaxb-api:2.3.1')
  implementation('org.glassfish.jaxb:jaxb-runtime:2.3.1')
  implementation('org.glassfish.metro:webservices-rt:2.4.4')
  implementation('org.glassfish.metro:webservices-api:2.4.4')
  implementation('com.cwt.bpg.services.common:security-jwt:3.11.0'){
    exclude(group: 'org.apache.camel')
    exclude(group: 'org.springframework')
  }
  implementation('com.cwt.bpg.services.common:security-model:3.11.0'){
    exclude(group: 'org.apache.camel')
    exclude(group: 'org.springframework')
  }

  testImplementation("org.powermock:powermock-classloading-xstream:1.7.4")

  testImplementation('junit:junit:4.12')
  testImplementation('org.mockito:mockito-core:4.0.0')
  testImplementation('net.bytebuddy:byte-buddy:1.11.21')
  testImplementation('com.appdynamics.agent:agent-api:4.5.18.29239')
  testImplementation('commons-io:commons-io:2.6')
  testImplementation("org.springframework.boot:spring-boot-starter-test:2.1.1.RELEASE")

  testImplementation("org.projectlombok:lombok:1.16.16")

  swaggerUI 'org.webjars:swagger-ui:3.23.0'
}

swaggerSources {
  swagger {
    inputFile = file('swagger.yaml')
  }
}

Thank you for looking into this.

I expect the project to build and run successfully.

Upvotes: 0

Views: 4590

Answers (1)

tbatch
tbatch

Reputation: 1849

Look at the upgrade guide from Gradle. You have a lot of stuff that needs to change in your build. For example, compileOnly is deprecated, as are some of your plugins. This is all outlined in the linked guide, as well as the steps to fix it.

Upvotes: 2

Related Questions