Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Could not initialize class org.gradle.internal.buildevents.BuildExceptionReporter$ExceptionStyle on Gradle build sonarqube task #158

Open
OneAndOnlySeabass opened this issue Jun 28, 2022 · 0 comments

Comments

@OneAndOnlySeabass
Copy link

Hi,

I am trying to build and scan my code the detekt sonar-kotlin plugin from an Azure Pipelines Gradle task. I have plugin version 2.5.0 installed on our SonarQube environment. On the sonarqube step, I get the following error:

> Task :app:sonarqube FAILED
:app:sonarqube (Thread[Execution worker for ':',5,main]) completed. Took 25.313 secs.
Created user preferences directory.

FAILURE: Build failed with an exception.

* What went wrong:
Could not initialize class org.gradle.internal.buildevents.BuildExceptionReporter$ExceptionStyle

* 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/
Error: The process '/home/vsts/work/1/s/gradlew' failed with exit code 1
    at ExecState._setResult (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.200.2/node_modules/azure-pipelines-task-lib/toolrunner.js:944:25)
    at ExecState.CheckComplete (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.200.2/node_modules/azure-pipelines-task-lib/toolrunner.js:927:18)
    at ChildProcess.<anonymous> (/home/vsts/work/_tasks/Gradle_8d8eebd8-2b94-4c97-85af-839254cc6da4/2.200.2/node_modules/azure-pipelines-task-lib/toolrunner.js:840:19)
    at ChildProcess.emit (events.js:198:13)
    at maybeClose (internal/child_process.js:982:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
##[error]Error: The process '/home/vsts/work/1/s/gradlew' failed with exit code 1

I have made sure to use the most compatible tool versions as listed here: https://detekt.dev/docs/introduction/compatibility/
As we do not have an Android project we do not have AGP installed.

Detekt Version Gradle Version Kotlin Version AGP Version Java Target Level JDK Version
1.19.0 7.3.0 1.5.31 4.2.2 1.8 17

My build.gradle.kts file looks as follows:

plugins {
    application // <1>
    id("org.jetbrains.kotlin.jvm") version "1.5.31"
    id ("org.sonarqube") version "3.3"
    id("jacoco")
}

repositories {
    mavenCentral() // <2>
}

dependencies {
    implementation(platform("org.jetbrains.kotlin:kotlin-bom")) 

    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") 

    implementation("com.google.guava:guava:30.1.1-jre") 

    testImplementation("org.jetbrains.kotlin:kotlin-test") 

    testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") 
}

application {
    mainClass.set("demo.AppKt") // <5>
}

tasks.named<Test>("test") {
    useJUnitPlatform() // <6>
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

jacoco {
    toolVersion = "0.8.7"
}

tasks.jacocoTestReport {
    dependsOn ("test")
    reports {
        xml.isEnabled = true
    }
}

My Gradle build Azure pipeline task looks as follows:

- task: Gradle@2
        displayName: 'Build Gradle project'
        inputs:
          gradleWrapperFile: 'gradlew'
          gradleOptions: '-Xmx3072m'
          javaHomeOption: 'JDKVersion'
          jdkVersionOption: '1.11'
          jdkArchitectureOption: 'x64'
          publishJUnitResults: false
          tasks: 'build jacocoTestReport sonarqube --info'

Could you help me resolve this issue?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant