Task :sonarqube FAILURE:

i am trying to upgrade project to Gradle 8.4 and JAVA 17. i am getting error during sounarqube scan:

Task :sonarqube

FAILURE: Build failed with an exception.

  • What went wrong:
    ‘java.io.File org.gradle.api.tasks.testing.JUnitXmlReport.getDestination()’

i am not sure if i am using correct plugin version, but i have tried 3 different latest is:
classpath(‘org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882’)

Hi,

Welcome to the community!

That’s not a lot to go on, but what there is points away from SonarQube analysis. Can you add --info to your command and post the log?

 
Thx,
Ann

Project scope is migration to java 17

Job deployment fails. i am using Gradle 8.4 and JAVA 17.(Eclipse Adoptium_jdk-17.0.12.7-hotspot)
FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project ‘Project’.

Could not resolve all files for configuration ‘:classpath’.
Could not resolve org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882.
Required by:
project :
No matching variant of org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute ‘org.gradle.plugin.api-version’ with value ‘8.4’ but:

  • Variant ‘apiElements’ capability org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882 declares a library, packaged as a jar, and its dependencies declared externally:
  • Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
  • Other compatible attribute:
  • Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.4’)
  • Variant ‘javadocElements’ capability org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882 declares a component for use during runtime, and its dependencies declared externally:
  • Incompatible because this component declares documentation and the consumer needed a library
  • Other compatible attributes:
  • Doesn’t say anything about its target Java version (required compatibility with Java 8)
  • Doesn’t say anything about its elements (required them packaged as a jar)
  • Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.4’)
  • Variant ‘runtimeElements’ capability org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
  • Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
  • Other compatible attribute:
  • Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.4’)
  • Variant ‘sourcesElements’ capability org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882 declares a component for use during runtime, and its dependencies declared externally:
  • Incompatible because this component declares documentation and the consumer needed a library
  • Other compatible attributes:
  • Doesn’t say anything about its target Java version (required compatibility with Java 8)
  • Doesn’t say anything about its elements (required them packaged as a jar)
  • Doesn’t say anything about org.gradle.plugin.api-version (required ‘8.4’)

Hi,

Can you share your analysis configuration?

 
Thx,
Ann

Gradle.buiild file?

  classpath('org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882')

Hi,

That doesn’t look like what’s in the docs.

 
HTH,
Ann

It is in dependencies {
classpath(“org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}”)
classpath(‘org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882’)
classpath(‘org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0’)
classpath(‘org.openapitools:openapi-generator-gradle-plugin:4.2.3’)
}

it used to work with gradle 7.0.2 and JAVA 8

Hi,

Can I suggest you try it the way it shows up in the docs?

 
Ann

i did and it failed.
A problem occurred evaluating root project ‘project’.

Could not find method plugins() for arguments [build_ejy4486ihsi5ates93dt6kgnu$_run_closure1$_closure4@1597802a] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler_Decorated.

Hi,

Please share your configuration and the full log.

 
Thx,
Ann

I cannot upload file your system does not allow more than 6 links

type or paste code here

group 'com.**'
ext['spring-kafka.version'] = '2.9.11'

buildscript {
    ext {
        springBootVersion = '2.7.18'
        lombokVersion = '1.18.24'
        appfabricSpringVersion = '4.2.1'
        dalVersion = '1.0.49.RELEASE'
        libsVersion = '1.0.32.RELEASE'
        tomcatVersion = '9.0.90'
        tikaVersion = '2.4.0'
        sys_user = System.env.SYS_USER
        sys_pass = System.env.SYS_PASSWORD
        subfolder = System.env.ARTIFACT_SUB_FOLDER
    }
    repositories {
        maven {
            url 'Link.1.com'
        }
    }
    plugins {
        id "org.sonarqube" version "5.1.0.4882" 
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath('org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:5.1.0.4882')
        classpath('org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0')
        classpath('org.openapitools:openapi-generator-gradle-plugin:4.2.3')
    }
}

apply plugin: 'java'
apply plugin: 'org.sonarqube'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'org.openapi.generator'


sourceCompatibility = 17
targetCompatibility = 17

version = '1.0.0'

if (System.env.BUILD_NUMBER) {
    version = "1.0.${System.env.BUILD_NUMBER}"
}

repositories {
  maven {
      url "link.2.com"
      credentials {
          username = (System.env.SYS_USER != null && System.env.SYS_USER != '') ? System.env.SYS_USER : System.env.LOCAL_USER
          password = (System.env.SYS_PASSWORD != null && System.env.SYS_PASSWORD != '') ? System.env.SYS_PASSWORD : System.env.LOCAL_PASSWORD
      }
  }

  maven {
      url 'Link.3.com'
      credentials {
          username = (System.env.SYS_USER != null && System.env.SYS_USER != '') ? System.env.SYS_USER : System.env.LOCAL_USER
          password = (System.env.SYS_PASSWORD != null && System.env.SYS_PASSWORD != '') ? System.env.SYS_PASSWORD : System.env.LOCAL_PASSWORD
      }
  }

  maven {
      url 'Link.4.com'
      credentials {
          username = (System.env.SYS_USER != null && System.env.SYS_USER != '') ? System.env.SYS_USER : System.env.LOCAL_USER
          password = (System.env.SYS_PASSWORD != null && System.env.SYS_PASSWORD != '') ? System.env.SYS_PASSWORD : System.env.LOCAL_PASSWORD
      }
  }
    mavenCentral()
}


tasks.register('zipTestResults', Zip) {
    from projectDir
     archiveAppendix = 'audit' 
    archiveBaseName = 'test-results' 
    destinationDirectory = file("$buildDir/zips") 

    include 'build/reports/**'
    include 'build/test-results/**'
    include 'git-commit'
}

test {
    //Line below opens the java.util package to all unnamed modules, making the serialVersionUID field accessible.
    jvmArgs += '--add-opens=java.base/java.util=ALL-UNNAMED'
    testLogging {
        events = ['passed', 'failed']
        exceptionFormat = 'full'
    }
 reports {
     junitXml.required = true
     junitXml.outputLocation = layout.buildDirectory.dir("test-results/junit")
   }
    outputs.upToDateWhen { false }
}

bootJar {
    enabled = true
    manifest {
        attributes(
                'Specification-Version': archiveVersion
        )
    }
}

jar {
    enabled = false
}

sonarqube {
    properties {
        property 'sonar.projectName','project'
        property 'sonar.exclusions', '**/generated/**.java'
        property 'sonar.host.url', 'https://sonarqube.allstate.com'
        property 'sonar.login', sys_user
        property 'sonar.password', sys_pass
        property 'sonar.sources', 'src/main'
        property 'sonar.projectKey', 'Project'
    }
}

jacocoTestReport {
    reports {
       //xml.enabled true
      xml.required = true
       }
}

publishing {
    publications {
        myArtifact(MavenPublication) {
            from components.java
            artifactId archivesBaseName
            artifacts = ["build/libs/**-${version}.jar"]
            artifact(zipTestResults) {
                classifier 'audit'
            }
        }
    }
}

artifactory {
    contextUrl = 'Link.5.com'
    publish {
        repository {
            repoKey = "ISG-UnstructuredData/udp-core/${subfolder}"
            username = sys_user
            password = System.env.SYS_PASSWORD
        }
        defaults {
            properties = ['git.commit': System.env.GITHUB_COMMIT_ID]
            publications('myArtifact')
        }
    }
    clientConfig.info.setBuildNumber(System.env.BUILD_NUMBER)
}

test {
    useJUnitPlatform()
}

dependencies {
    implementation "com.compozed.appfabric:com-compozed-appfabric-security:${appfabricSpringVersion}"
    implementation "com.compozed.appfabric:com-compozed-appfabric-oauth2-starter-api:${appfabricSpringVersion}"
    implementation(group: 'com.compozed.appfabric', name: 'com-compozed-appfabric-kafka', version: '4.2.1') {
        exclude group: 'org.apache.commons', module: 'commons-compress'
    }
    implementation "com.allstate.isg:udp-on-prem-cms-lib:1.0.51"
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.cloud:spring-cloud-starter-config:3.0.2'
    implementation 'org.springframework.cloud:spring-cloud-starter-vault-config:3.1.3'
    implementation 'org.springframework.data:spring-data-mongodb:3.3.5'

    implementation "org.projectlombok:lombok:${lombokVersion}"
    annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
    implementation 'com.amazonaws:aws-java-sdk-s3:1.12.261'
    implementation "com.allstate.isg:udp-on-prem-common-libs:${libsVersion}"
    implementation "com.allstate.isg:udp-on-prem-dal:${dalVersion}"

    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'com.microsoft.sqlserver:mssql-jdbc:9.4.1.jre8'

    implementation group: "com.github.java-json-tools", name: "json-schema-validator", version: "2.2.14"
    // AVRO
    implementation 'io.confluent:kafka-avro-serializer:5.5.0'
    implementation 'io.confluent:kafka-schema-registry-client:5.5.0'
    implementation group: 'org.apache.avro', name: 'avro', version: '1.9.2'
    implementation group: 'org.apache.kafka', name: 'kafka-clients', version: '3.2.3'

    //Vulnerability fix
    implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.21'
  //  implementation group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.67'
    implementation group: 'commons-io', name: 'commons-io', version: '2.7'
    implementation group: 'org.glassfish.jersey.core', name: 'jersey-common', version: '2.34'
    implementation group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: "${tomcatVersion}"
    implementation group: 'org.springframework.security', name: 'spring-security-crypto', version: '5.6.4'
    implementation group: 'org.springframework.security', name: 'spring-security-web', version: '5.8.11'
    implementation("org.springframework.security:spring-security-core:5.8.11")
    implementation "org.yaml:snakeyaml:1.32"
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.13.4'
    implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.4.2'
    implementation "org.springframework:spring-expression:x 6.0.7"
    implementation "org.springframework:spring-webmvc:6.0.7"

    implementation "org.springframework.vault:spring-vault-core:2.3.3"
    implementation group: "com.google.guava", name: "guava", version: "32.0.1-jre"
    //CVE-2023-43642
    implementation("org.xerial.snappy:snappy-java:1.1.10.4")

    implementation "ch.qos.logback:logback-core:1.2.13"
    implementation "ch.qos.logback:logback-classic:1.2.13"
    // CVE-2023-34042
    implementation 'org.springframework.security:spring-security-config:5.7.11'
    //CVE-2023-39410
    implementation "org.apache.avro:avro:1.11.3"
    configurations.implementation {
        exclude group: "org.bouncycastle",module: "bcprov-jdk15on"
        exclude group: "org.bouncycastle",module: "bcprov-jdk18on"
        exclude group : "com.h2database", module:"h2"
        exclude group: 'org.apache.commons', module: 'commons-compress'
    }

    testImplementation "org.projectlombok:lombok:${lombokVersion}"
    testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'io.github.benas:random-beans:3.4.0'
    testImplementation "com.compozed.appfabric:com-compozed-appfabric-starter-api-testutils:${appfabricSpringVersion}"
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'org.springframework') {
            details.useVersion '5.3.39'
            details.because 'CVE-2022-22950'
        }

        if (details.requested.group == 'org.springframework' && details.requested.module.name == 'spring-webmvc') {
            details.useVersion '5.3.39'
        }
        if (details.requested.group == 'org.springframework' && details.requested.module.name == 'spring-expression') {
            details.useVersion '5.3.39'
        }
        if (details.requested.group == 'org.springframework' && details.requested.module.name == 'spring-web') {
            details.useVersion '5.3.39'
            // CVE-2024-22243
       }
    }
    resolutionStrategy.dependencySubstitution {
    	substitute(module('org.springframework:spring-webmvc:5.3.31'))
    			.using(module('org.springframework:spring-webmvc:5.3.39'))
    			.because('CVE-2024-38816')
    	substitute(module('org.apache.tomcat.embed:tomcat-embed-websocket:9.0.83'))
    			.using(module('org.apache.tomcat.embed:tomcat-embed-websocket:9.0.90'))
    			.because('CVE-2024-23672')
    	substitute(module('com.nimbusds:nimbus-jose-jwt:9.22'))
    			.using(module('com.nimbusds:nimbus-jose-jwt:9.37.2'))
    			.because('CVE-2023-52428')
              // Fix for CVE-2024-25710
        substitute(module('software.amazon.ion:ion-java:1.0.2'))
                .using(module('com.amazon.ion:ion-java:1.10.5'))
                .because('CVE-2023-52428')
 
    }

}

processTestResources {
    setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}

sourceSets {
    main {
        java {
            srcDir "${rootDir}/generated/bulkaccessapi/src/main/java"
        }
    }
}

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

openApiGenerate {
    generatorName = "java"
    library = "resttemplate"
    inputSpec = "$rootDir/src/main/resources/bulk-access-spec.yaml".toString()
    outputDir = "${rootDir}/generated/bulkaccessapi".toString()

    systemProperties = [
            modelDocs: "false",
            models   : "",
            apis     : "false",
    ]
    configOptions = [
            useOptional          : "true",
            swaggerDocketConfig  : "false",
            performBeanValidation: "true",
            useBeanValidation    : "true",
            useTags              : "false",
            singleContentTypes   : "true",
            title                : rootProject.name,
            java17                : "true",
            dateLibrary          : "java17",
            serializableModel    : "true",
            serializationLibrary : "jackson",
            skipDefaultInterface : "true",
            artifactId           : rootProject.name,
            apiPackage           : "com.",
            modelPackage         : "com..model",
            invokerPackage       : "com.",
            interfaceOnly        : "true"
    ]
}

compileJava.dependsOn tasks.openApiGenerate

Hi,

Why are you still listing the dependency?

 
Ann

i have tried both ways and it does not like plugins {} option

Hi

Can I have the logs for the plugin version without the classpath listing?

 
Thx,
Ann

A problem occurred evaluating root project ‘***’.

Could not find method plugins() for arguments [build_ejy4486ihsi5ates93dt6kgnu$_run_closure1$_closure4@51afac8f] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler_Decorated.

Hi,

Can I have the full log, starting from the analysis command? Not just the error.

In fact, can you add a --info to that command and then provide the full log, starting from that command?

 
Thx,
Ann

It fails right away.:

Build file ‘C:***\build.gradle’ line: 30

A problem occurred evaluating root project ‘***’.

Could not find method plugins() for arguments [build_ejy4486ihsi5ates93dt6kgnu$_run_closure1$_closure4@5c3114d4] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler_Decorated.

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.
BUILD FAILED in 45ms
Watched directory hierarchies: [C:****]

Hi,

Could I have the full log, starting from the analysis command, please?

 
Thx,
Ann