0

I am new to sonarqube and trying to execute a code scan on a java/jaxrs backend with gradle.

My build.gradle is the following:

buildscript {
    dependencies {
        classpath group: "com.liferay", name: "com.liferay.gradle.plugins", version: "4.4.5"
        classpath group: "org.sonarsource.scanner.gradle", name:"sonarqube-gradle-plugin", version:"3.3"
    }

    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        maven {
            url "https://repository-cdn.liferay.com/nexus/content/groups/public"
        }
    }
}

apply plugin: "org.sonarqube"
apply plugin: "com.liferay.plugin"

dependencies {
    compileOnly group: "javax.ws.rs", name: "javax.ws.rs-api", version: "2.1"
    compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
    compileOnly group: "org.osgi", name: "org.osgi.service.jaxrs", version: "1.0.0"
    compile group: 'com.liferay', name: 'com.liferay.portal.remote.cors.api', version: '1.0.4'
    compileInclude group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

    compileOnly group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
    compileOnly group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.9'
    compileOnly group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.5'

    implementation group: 'com.liferay.portal', name: 'release.portal.api', version: '7.3.1-ga2'

    implementation group: 'commons-lang', name: 'commons-lang', version: '2.6'

    implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'

    //
    implementation group: 'org.junit.platform', name: 'junit-platform-commons', version: '1.7.0'
    testImplementation('org.junit.jupiter:junit-jupiter-api:5.4.2')
    testRuntime('org.junit.jupiter:junit-jupiter-engine:5.4.2')
    testCompile('org.junit.jupiter:junit-jupiter-params:5.4.2')
    testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.7.0'
    testImplementation group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.7.0'
    testCompile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

    testImplementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.5'
    testImplementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.9'
    testImplementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.5'
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

task copyJar(type: Copy) {
    from "build/libs"
    into "../../../../files/osgi/modules/"
}

copyJar.dependsOn(build)

repositories {
    maven {
        url "https://repository-cdn.liferay.com/nexus/content/groups/public"
    }
}

test {
    useJUnitPlatform()
}

When I try to execute the sonar-scanner command from windows powershell or cmd:

.\gradlew sonarqube -Dsonar.projectKey=be_d254_enroll_center -Dsonar.host.url=http://localhost:9000 -Dsonar.login=1f774e64a98490b5e01646104342de340e40f263 -Dsonar.sources=src

I get the following error that points at another project be_256 different from the project from where I executed the command which is be_261

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':LR/rs/256/be_256'.
> Cannot add task 'downloadNode' as a task with that name already exists.

Config:

  • Sonarqube LTS 8.9.3
  • Gradle version 4.10.2
  • Java version 11

I tried to clear gradle cache but it did not work. Any help is appreciated. Thanks.

Edit 1

I have been able to solve the previous error by completely uninstalling Gradle and re-installing it, I now have the following error:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':LR/rs/261/be_261'.
> Could not resolve all artifacts for configuration ':LR/resident_services/d261_update_address/be_d261_update_address:classpath'.
   > Could not download sonar-scanner-api.jar (org.sonarsource.scanner.api:sonar-scanner-api:2.16.1.361)
      > Could not get resource 'https://repository-cdn.liferay.com/nexus/content/groups/public/org/sonarsource/scanner/api/sonar-scanner-api/2.16.1.361/sonar-scanner-api-2.16.1.361.jar'.
         > Could not GET 'https://repository-cdn.liferay.com/nexus/content/groups/public/org/sonarsource/scanner/api/sonar-scanner-api/2.16.1.361/sonar-scanner-api-2.16.1.361.jar'.
            > Received fatal alert: handshake_failure

Edit 2

I am once again stuck on this issue, I have tried once again to clear gradle's cache but it did not work

FAILURE: Build failed with an exception.

    * What went wrong:
    A problem occurred configuring project ':LR/rs/256/be_256'.
    > Cannot add task 'downloadNode' as a task with that name already exists.
  • Please check your TLS version. Since you are using Java 11, I am assuming its on 1.2. The maven repo is using TLS 1.3. Try using TLS1.3 with Java 11. Look here for more details https://stackoverflow.com/questions/60955206/java-11-sslhandshakeexception-with-tls-1-3-how-do-i-revert-to-tls-1-2 – Ashish Dec 17 '21 at 17:27
  • I am using Java 11 only for sonarqube's server, and using java 8u311 on local, I have added AVA_TOOL_OPTIONS=-Dhttps.protocols=TLSv1.3 to forces tls 1.3, but I am back once again to the first issue Cannot add task 'downloadNode' as a task with that name already exists. – Khalil Barigou Dec 20 '21 at 14:08

1 Answers1

0

This issue was fixed after I moved the BE folder to another directory.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 20 '21 at 21:08