Discussion:
SonarQube Plugin on reactor projects
f***@public.gmane.org
11 years ago
Permalink
Hello,

we're using sonar-maven-plugin from the commandline to analyze reactor
projects by just executing in the reactor's main project and get a nice
project report in SonarQube.

Now I try to use the Eclipse plugin and stumble upon two issues:

1) our main reactor project ist non-java nature, so I cannot add
org.sonar.ide.eclipse.core.sonarNature by eclipse UI. I managed to
associate it by changing .project manually and then associate a SonarQube
project.

2) when I do this and try to analyze the reactor, I get the following
error:

Retrieve remote issues of project REFERENZKURZNAMEKLEIN...
Start SonarQube analysis on REFERENZKURZNAMEKLEIN...
INFO: SonarQube Server 4.3
09:26:46.853 INFO - Incremental mode
09:26:46.855 INFO - Load batch settings
09:26:46.958 INFO - User cache: C:\Users\frank.jakop\.sonar\cache
09:26:46.965 INFO - Install plugins
09:26:46.978 INFO - Include plugins:
09:26:46.978 INFO - Exclude plugins: devcockpit, jira, pdfreport, views,
report, buildstability, scmactivity, buildbreaker
09:26:48.153 INFO - Create JDBC datasource for
jdbc:h2:D:\Workspaces\tolina_1\.metadata\.plugins\org.eclipse.core.resources\.projects\REFERENZKURZNAMEKLEIN\org.sonar.ide.eclipse.core\.sonartmp\preview1400830007141-0
09:26:49.303 INFO - Initializing Hibernate
Exception in thread "main" 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 java.security.AccessController.doPrivileged(Native Method)
at
org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at
org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at
org.sonar.runner.impl.BatchLauncherMain.execute(BatchLauncherMain.java:41)
at
org.sonar.runner.impl.BatchLauncherMain.main(BatchLauncherMain.java:59)
Caused by: java.lang.IllegalStateException: You must define the following
mandatory properties for
'de.tolina.REFERENZKURZNAMEKLEIN:REFERENZKURZNAMEKLEIN': sonar.sources
at
org.sonar.batch.scan.ProjectReactorBuilder.checkMandatoryProperties(ProjectReactorBuilder.java:289)
at
org.sonar.batch.scan.ProjectReactorBuilder.defineProject(ProjectReactorBuilder.java:126)
at
org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:114)
at
org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:95)
at
org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:72)
at
org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:90)
at
org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:56)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:44)
at
org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82)
at
org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at
org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at
org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:175)
at
org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:163)
at
org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at
org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
at
org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 6 more

Is this supposed to not work on non-java reactor projects? I would really
wonder, because the maven plugin works fine.

Best Regards
Frank
Julien HENRY
11 years ago
Permalink
Hi Frank,

As you know Eclipse doesn't support multi-module projects. When you import
a muti-module project in Eclipse using m2e, the root module is some kind of
empty project (its only use is the ability to edit root pom.xml). That's
why it is not possible to associate this project to SQ. You have to
associate each Eclipse project for each Maven module to the correct
SonarQube module (it should be straightforward using the association
wizard).

Then you can run analysis on each module.

++

Julien
...
f***@public.gmane.org
11 years ago
Permalink
Hi Julien,

tahnks for this hint, but that's not the same as the analysis with maven
plugin. With the maven plugin we get one SQ project for all modules
combined. When I would use the single-module technique, we would have each
module as a separate SQ project.
As this would be the same information only split up, SQ would whack me if
I tried the reactor analysis from maven the next time after analysing the
modules separately.
The error message then is

The project 'myProject1' is already defined in SonarQube but not as a
module of project 'myProjectMaster'. If you really want to stop directly
analysing project 'myProject1', please first delete it from SonarQube and
then relaunch the analysis of project 'myProjectMaster'

So this is not really fine either.

Regards
Frank


Von:
julien.henry-tdHRWj7/***@public.gmane.org
An:
user-***@public.gmane.org
Datum:
02.06.2014 09:07
Betreff:
Re: [sonar-user] SonarQube Plugin on reactor projects



Hi Frank,

As you know Eclipse doesn't support multi-module projects. When you import
a muti-module project in Eclipse using m2e, the root module is some kind
of empty project (its only use is the ability to edit root pom.xml).
That's why it is not possible to associate this project to SQ. You have to
associate each Eclipse project for each Maven module to the correct
SonarQube module (it should be straightforward using the association
wizard).

Then you can run analysis on each module.

++

Julien


2014-05-23 9:33 GMT+02:00 <frank.jakop-***@public.gmane.org>:
Hello,

we're using sonar-maven-plugin from the commandline to analyze reactor
projects by just executing in the reactor's main project and get a nice
project report in SonarQube.

Now I try to use the Eclipse plugin and stumble upon two issues:

1) our main reactor project ist non-java nature, so I cannot add
org.sonar.ide.eclipse.core.sonarNature by eclipse UI. I managed to
associate it by changing .project manually and then associate a SonarQube
project.

2) when I do this and try to analyze the reactor, I get the following
error:

Retrieve remote issues of project REFERENZKURZNAMEKLEIN...
Start SonarQube analysis on REFERENZKURZNAMEKLEIN...
INFO: SonarQube Server 4.3
09:26:46.853 INFO - Incremental mode
09:26:46.855 INFO - Load batch settings
09:26:46.958 INFO - User cache: C:\Users\frank.jakop\.sonar\cache
09:26:46.965 INFO - Install plugins
09:26:46.978 INFO - Include plugins:
09:26:46.978 INFO - Exclude plugins: devcockpit, jira, pdfreport, views,
report, buildstability, scmactivity, buildbreaker
09:26:48.153 INFO - Create JDBC datasource for
jdbc:h2:D:\Workspaces\tolina_1\.metadata\.plugins\org.eclipse.core.resources\.projects\REFERENZKURZNAMEKLEIN\org.sonar.ide.eclipse.core\.sonartmp\preview1400830007141-0

09:26:49.303 INFO - Initializing Hibernate
Exception in thread "main" 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 java.security.AccessController.doPrivileged(Native Method)
at
org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at
org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at
org.sonar.runner.impl.BatchLauncherMain.execute(BatchLauncherMain.java:41)

at
org.sonar.runner.impl.BatchLauncherMain.main(BatchLauncherMain.java:59)
Caused by: java.lang.IllegalStateException: You must define the following
mandatory properties for
'de.tolina.REFERENZKURZNAMEKLEIN:REFERENZKURZNAMEKLEIN': sonar.sources
at
org.sonar.batch.scan.ProjectReactorBuilder.checkMandatoryProperties(ProjectReactorBuilder.java:289)

at
org.sonar.batch.scan.ProjectReactorBuilder.defineProject(ProjectReactorBuilder.java:126)

at
org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:114)

at
org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:95)

at
org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:72)

at
org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:90)

at
org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)

at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:56)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:44)
at
org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:82)

at
org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)

at
org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)

at
org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:175)

at
org.sonar.batch.bootstrap.BootstrapContainer.doAfterStart(BootstrapContainer.java:163)

at
org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)

at
org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)

at org.sonar.batch.bootstrapper.Batch.startBatch(Batch.java:92)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:74)
at
org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)
at
org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)

... 6 more

Is this supposed to not work on non-java reactor projects? I would really
wonder, because the maven plugin works fine.

Best Regards
Frank
Julien HENRY
11 years ago
Permalink
There is something missing for my understanding. Using Maven plugin from
command line, you should run "normal" analysis (mvn sonar:sonar). It will
publish results to the SQ server. This is usually triggered by your CI
server.
In Eclipse you are using incremental preview mode so results are not pushed
to the server. And this is a case where doing an analysis of a sub module
alone is supported.
...
Loading...