Sonarqube gradle plugin

604 views
Skip to first unread message

Andrew Holland

unread,
Oct 22, 2015, 8:38:39 AM10/22/15
to SonarQube
Hi,

We are getting an java.lang.NullPointerException when using the sonarqube-gradle-plugin 1.0 with sonar 5.1.2 & 5.2 RC3 when specifying the sonar.branch property, if i remove or comment out the sonar.branch then the analysis is successful.

apply plugin: 'org.sonarqube'

sonarqube {
    properties {
        property 'sonar.branch', "$branch"
        .....
    }
}

I can see the branch name ( 'update-sonarqube-plugin') is being passed in via the debug

13:22:52.963 INFO  - -------------  Scan <project name> update-sonarqube-plugin

I've supplied the stacktrace below with all the identifiying information removed

gradlew sonar --no-daemon --stacktrace

:sonarqube
INFO: Default locale: "en_GB", source code encoding: "UTF-8"
INFO: Work directory: ....
INFO: SonarQube Server 5.2-RC3
13:22:50.951 INFO  - Load global repositories
13:22:51.091 INFO  - Load global repositories (done) | time=125ms
13:22:51.107 INFO  - User cache: ...\.sonar\cache
13:22:51.544 INFO  - Load plugins index
13:22:51.575 INFO  - Load plugins index (done) | time=31ms
13:22:52.074 INFO  - Process project properties
13:22:52.589 INFO  - Load project repositories
13:22:52.605 INFO  - Load project repositories (done) | time=16ms
13:22:52.605 INFO  - Apply project exclusions
13:22:52.683 INFO  - Load quality profiles
13:22:52.729 INFO  - Load quality profiles (done) | time=46ms
13:22:52.729 INFO  - Load active rules
13:22:52.917 INFO  - Load active rules (done) | time=188ms
13:22:52.932 WARN  - 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
13:22:52.932 WARN  - 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
13:22:52.932 WARN  - 'sonar.dynamicAnalysis' is deprecated since version 4.3 and should no longer be used.
13:22:52.963 INFO  - Publish mode
13:22:52.963 INFO  - -------------  Scan <project name> update-sonarqube-plugin
13:22:53.041 INFO  - Language is forced to java
13:22:53.041 INFO  - Load server rules
13:22:53.151 INFO  - Load server rules (done) | time=110ms
13:22:53.229 INFO  - Base dir: ....
13:22:53.229 INFO  - Working dir: ...
13:22:53.244 INFO  - Source paths: src
13:22:53.244 INFO  - Test paths: test
13:22:53.260 INFO  - Binary dirs: build/classes/main, build/resources/main
13:22:53.260 INFO  - Source encoding: UTF-8, default locale: en_GB
13:22:53.260 INFO  - Index files
13:22:53.275 INFO  - Excluded sources:
13:22:53.291 INFO  -   src/.../.../.../**
13:22:53.291 INFO  -   src/.../.../.../**
13:22:53.291 INFO  -   src/.../.../**
13:22:54.773 INFO  - 458 files indexed
13:22:54.773 INFO  - 2159 files ignored because of inclusion/exclusion patterns
13:22:54.804 INFO  - Quality profile for java: Sonar way
13:22:54.851 INFO  - Sensor JavaSquidSensor
13:22:57.004 INFO  - Java Main Files AST scan...
13:22:57.019 INFO  - 261 source files to be analyzed
:sonarqube FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonarqube'.
> Unable to execute Sonar

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':sonarqube'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:62)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
        at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
        at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
        at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
        at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
        at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
        at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
        at org.gradle.internal.Factories$1.create(Factories.java:22)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
        at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
        at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
        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:43)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:77)
        at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:47)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
        at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
        at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
        at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
        at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
        at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
        at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
        at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
        at org.gradle.launcher.Main.doAction(Main.java:33)
        at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
        at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
        at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: org.sonar.runner.impl.RunnerException: Unable to execute Sonar
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
        at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
        at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
        at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
        at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
        at org.sonar.runner.api.Runner.execute(Runner.java:100)
        at org.sonarqube.gradle.SonarQubeTask.run(SonarQubeTask.java:50)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
        ... 60 more
Caused by: org.sonar.squidbridge.api.AnalysisException: SonarQube is unable to analyze file : '<file name removed>'
        at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:102)
        at org.sonar.java.ast.JavaAstScanner.scan(JavaAstScanner.java:75)
        at org.sonar.java.JavaSquid.scanSources(JavaSquid.java:131)
        at org.sonar.java.JavaSquid.scan(JavaSquid.java:124)
        at org.sonar.plugins.java.JavaSquidSensor.analyse(JavaSquidSensor.java:86)
        at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58)
        at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50)
        at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98)
        at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
        at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:258)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:253)
        at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:251)
        at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243)
        at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100)
        at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85)
        at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153)
        at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110)
        at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:76)
        at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
        at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
        ... 74 more
Caused by: java.lang.NullPointerException
        at org.sonar.batch.source.SymbolizableBuilder.loadPerspective(SymbolizableBuilder.java:46)
        at org.sonar.batch.source.SymbolizableBuilder.loadPerspective(SymbolizableBuilder.java:32)
        at org.sonar.batch.deprecated.perspectives.BatchPerspectives.as(BatchPerspectives.java:63)
        at org.sonar.java.SonarComponents.symbolizableFor(SonarComponents.java:104)
        at org.sonar.java.model.VisitorsBridge.createSonarSymbolTable(VisitorsBridge.java:154)
        at org.sonar.java.model.VisitorsBridge.visitFile(VisitorsBridge.java:124)
        at org.sonar.java.ast.JavaAstScanner.simpleScan(JavaAstScanner.java:94)
        ... 95 more


BUILD FAILED

Total time: 22.001 secs



Thanks

Andy

Julien HENRY

unread,
Oct 22, 2015, 12:08:14 PM10/22/15
to SonarQube
Hi Andy,

Do you confirm it is working properly when not using sonar.branch? Also could you precise the version of the SonarQube Java Plugin you are using?

Thanks

Julien

Andrew Holland

unread,
Oct 22, 2015, 2:57:36 PM10/22/15
to SonarQube
Hi Julien, 

Yes works fine if i remove sonar.branch and also seems to works fine if i hard code the branch name but dosen't work when i use a variable (the variable did work with the old sonarRunner plugin).

Using version 1.0 of the gradle plugin, and 3.6 of the java plugin.

Thanks

Andy

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/b2254663-e422-46dd-b7f6-c8422bc54630%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc

Julien HENRY

unread,
Oct 23, 2015, 5:12:17 AM10/23/15
to SonarQube
I'm not able to reproduce with a simple project.

Could you please run:

./gradlew sonarqube -DsonarRunner.dumpToFile=out.txt

and send me (privately) the resulting file so that I can see if there is something strange in your configuration?

I was tempted to say this is an issue in Java plugin but if you are sure it is working with former Gradle plugin this remove this option.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+unsubscribe@googlegroups.com.

Andrew Holland

unread,
Oct 23, 2015, 10:43:54 AM10/23/15
to SonarQube
I managed to reproduce it with a simple project (see attached), you will need git installed

just run ./gradlew sonarqube to see it fail.

Thanks

Andy
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
sonarqube-gradle.zip

Julien HENRY

unread,
Nov 2, 2015, 4:52:41 AM11/2/15
to SonarQube
Thanks for the reproducer.

The issue come from a trailing line break in the branch property. Could be fixed on your side:

def branchFromScm() {
return "git rev-parse --abbrev-ref HEAD".execute().text.trim()
}

I have created a ticket on our side:
Reply all
Reply to author
Forward
0 new messages