SonarQube 2.2 Plugin and Gradle 3.1 issue

sonarqube
plugins

(B All) #1

We had previously been using older Sonar plugin with Gradle 2.13 and it was working fine but looking to migrate to the newer Gradle 3.1 which needs the Sonar Qube 2.0 or above plugin. I have setup the buold.gradle as I had been instructed but looks like there is an old sonar logging class it is looking for when loading the plugin? Below is the error and the top of the gradle file. Any help appreciated.

buildscript {
   repositories {
      if ("${use_maven_local}" == "true") {
         mavenLocal()
      }

      maven {
         credentials {
            username "${maven_username}"
            password "${maven_password}"
         }

         if (artifactory?.trim()) {
            url "${artifactory}"
         } else {
            url 'repo url removed for post'
         }
      }
   }

   dependencies {
     // classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2"
      classpath 'se.transmode.gradle:gradle-docker:1.2'
      classpath 'org.ajoberstar:grgit:1.1.0'
   }
}

plugins {
   id "java"
   id "org.sonarqube" version "2.2"
   id "maven"
}

And the error

➜  i2platform git:(gradle3) ✗ /Users/brendon/Library/gradle-3.1/bin/gradle --stacktrace  build

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/brendon/workspace/i2platform/build.gradle' line: 33

* What went wrong:
An exception occurred applying plugin request [id: 'org.sonarqube', version: '2.2']
> Failed to apply plugin [id 'org.sonarqube']
   > Could not generate a proxy class for class org.sonarqube.gradle.SonarQubeTask.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'org.sonarqube', version: '2.2']
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:224)
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:171)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:156)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:573)
        at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)
        at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:151)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:148)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:33)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:112)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:106)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:92)
        at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:66)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:79)
        at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:51)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:59)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.HintGCAfterBuild.execute(HintGCAfterBuild.java:44)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:293)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'org.sonarqube']
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:155)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:112)
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator$5.run(DefaultPluginRequestApplicator.java:174)
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:212)
        ... 57 more
Caused by: org.gradle.api.GradleException: Could not generate a proxy class for class org.sonarqube.gradle.SonarQubeTask.
        at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:201)
        at org.gradle.api.internal.AbstractClassGenerator.generate(AbstractClassGenerator.java:64)
        at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:115)
        at org.gradle.api.internal.project.taskfactory.TaskFactory.createTask(TaskFactory.java:77)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.createTask(AnnotationProcessingTaskFactory.java:46)
        at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.createTask(DependencyAutoWireTaskFactory.java:39)
        at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:63)
        at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:98)
        at org.sonarqube.gradle.SonarQubePlugin.createTask(SonarQubePlugin.java:101)
        at org.sonarqube.gradle.SonarQubePlugin.apply(SonarQubePlugin.java:84)
        at org.sonarqube.gradle.SonarQubePlugin.apply(SonarQubePlugin.java:63)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
        at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:139)
        ... 60 more
Caused by: java.lang.NoClassDefFoundError: org/sonarsource/scanner/api/LogOutput
        at org.gradle.internal.reflect.ClassInspector.inspectClass(ClassInspector.java:67)
        at org.gradle.internal.reflect.ClassInspector.visitGraph(ClassInspector.java:51)
        at org.gradle.internal.reflect.ClassInspector.inspect(ClassInspector.java:31)
        at org.gradle.api.internal.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:260)
        at org.gradle.api.internal.AbstractClassGenerator.inspectType(AbstractClassGenerator.java:216)
        at org.gradle.api.internal.AbstractClassGenerator.generateUnderLock(AbstractClassGenerator.java:95)
        ... 73 more
Caused by: java.lang.ClassNotFoundException: org.sonarsource.scanner.api.LogOutput
        ... 79 more

Thanks in advance for any ideas I am out of them…


(B All) #2

I also tried this with the

classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.2"

not commented and it did not make a difference. Looked at adding

But I see no other examples need that. Thanks again


(Benjamin Muschko) #3

I just tried with the following build script and the plugin version seems to be fine with 3.1.

plugins {
   id "java"
   id "org.sonarqube" version "2.2"
   id "maven"
}

I ran the command gradle sonarqube for a local instance of Sonarqube 6.1. Can you please provide a sample project on GitHub that reproduces the issue including a checked in Wrapper? Please also let me know what version of Sonarqube you are using.


(B All) #4

I am sorry I have probably done a horrible job of explaining this and some of my knowledge of sonar is lacking as all I was really tasked with was making our build.gradle work with gradle 3.x. In doing so it flagged apply plugin: 'sonar-runner’
and told me it was deprecated so that was all I was trying to do was to update to the newer sonarcube plug in. So I switched over to it and then changed all my setup calls to the newer calls.

from ex.

sonarRunner {
//   toolVersion = '2.4'

   sonarProperties {
      property "sonar.projectName", "Platform"
      property "sonar.projectKey", "com.platform"
      property "sonar.sourceEncoding", "UTF-8"
   }
}

subprojects {
   sonarRunner {
      sonarProperties {
         property "sonar.sourceEncoding", "UTF-8"
         property "sonar.jacoco.reportPath", "${buildDir}/jacoco/test.exec"
      }
   }
}

to

sonarqube {

   properties {
      property "sonar.projectName", "Platform"
      property "sonar.projectKey", "com.platform"
      property "sonar.sourceEncoding", "UTF-8"
   }
}

subprojects {
   sonarqube {
      properties {
         property "sonar.sourceEncoding", "UTF-8"
         property "sonar.jacoco.reportPath", "${buildDir}/jacoco/test.exec"
      }
   }

Then I added sonarqube-gradle-plugin:2.2 to our artifactory and I can see it grab it. Sure I am over simplifying this and not phrasing this right. We are not using a wrapper script for our gradle.build file.

Thanks for helping someone not familiar enough with sonar :wink:


(Benjamin Muschko) #5

OK, thanks for the clarified answer. Is your issue resolved? I could really read that out of your answer.


(B All) #6

no still getting that error of > Could not generate a proxy class for class org.sonarqube.gradle.SonarQubeTask.

with the stack showing

Caused by: java.lang.ClassNotFoundException: org.sonarsource.scanner.api.LogOutput

(Am I missing a classpath or dependency? Didn’t see it on any examples)

One interesting thing I just found was that it also fails the same way with gradle 2.14. So appear more to the plugin that gradle version from that info.

Thanks again for any ideas.


(Benjamin Muschko) #7

Yes, you are missing a transitive dependency in your binary repository: org.sonarsource.scanner.api:sonar-scanner-api:2.8. Please see the POM file for more information. You should also make sure that you upload the whole transitive tree of dependencies used by the plugin.


(B All) #8

Yeah that did it sorry i thought we had the normal pom in there but it was an autogenerated one when the jar was uploaded.