sonar skipping all modules except root one - maven

I'm trying to run sonar on entire project using maven, but for some reason it skips submodules and analyse only root module. Is there any explanation of such a strange behaviour?
Any help is greatly appreciated!
Here is maven final output:
ADDITION
mvn clean install doesn't skip anything, but mvn sonar:sonar do.

The SonarQube Maven Plugin is an aggregator plugin. It's executed only on the root module. That's the reason why Maven flags sub-modules as SKIPPED, even if they are correctly analysed.

I do not find full description, but have youtried sonar.includedModules=rootModule?
Source

Related

Command to run maven spotbug goal

I have a maven project with spotbugs plugin enabled. Before committing the code, i just need to run the maven spotbugs check. How do i run just the spot bug check on my project?
I just figured it out.
mvn spotbugs:check

How to generate maven artifact with jenkins build number

I'm trying associate maven artifacts name with build number.
ex: sample.1.0.0-snapshot.ear into sample.1.0.0-snapshot.buildnumber.ear
I have tried maven-buildnumber plugin but still no luck.
could anyone help me to do this.
You can use the Versions Maven plugin by executing following command before any other maven targets after clean.
mvn versions:set -DnewVersion=sample.1.0.0-snapshot.$BUILD_NUMBER

Why should run first mvn clean clover2:setup install clover2:clover, then: mvn sonar:sonar

Based on the question Sonar + Clover only runs on src-instrumented, it is suggested using first mvn clean clover2:setup install clover2:clover, then: mvn sonar:sonar.
Just wonder why we cannot use mvn clean clover2:setup install clover2:clover sonar:sonar?
In the past it was the recommended way to run goal sonar:sonar alone. This is no more the case since SonarQube Scanner for Maven stopped trying to run unit tests + collect coverage for you by forking a new Maven lifecycle.
General advice is now to run goals in a single command. For example mvn clean package sonar:sonar
In the case of Clover the clover:setup goal will alter the Maven Model to make all other plugins (like surefire) use instrumented classes instead of original source code. This is indeed a problem because it will prevent SonarQube to match class files. So in your case you should either stick with two separate goals, or manually configure sonar.sources to refer to original source code.
Compared the maven logs and found the possible reason:
The "mvn clean clover2:setup install clover2:clover sonar:sonar" seems having issue to find the Source dirs. The log shows it uses ${project}\target\clover\src-instrumented and ${project}\target\generated-sources\annotations as the source dirs.
If explicitly specify src/main/java, then this single command works well. The only tricky thing is why running the goals separately doesn't need to specify sonar.sources but the plugin can still find the right folder for source dirs.

How to run Sonar on a sub-module?

I am using Sonar integration with Jenkins. I want to run Sonar only on a sub-module of a project and not the entire project. But, when I specify -pl sub-module in the options for Sonar, it says that it is not supported.
Is there a way to achieve this?
Thanks
cd into the submodule and run mvn sonar:sonar there.
The drawback of this approach is that it will create a new top-level entry on the Sonar server; Sonar can't merge the results of a submodule run with an existing full analysis.

mvn test on multi module project?

I have a strange issue and I don't know if my conclusion is correct. I have a multi module project with two children:
Rector build order:
mvn-project-test
mvn-project-core
core depends on test (so the build order is correct). Of course, running 'mvn test' doesn't install any artifacts locally. When running it, maven complaints (correctly) that ~/.m2/respositories/...../mvn-project-test-1.0-SNAPSHOT.jar is missing and the core build fails.
Shouldn't maven use the dependencies from the target folder of other multimodule children? Or must I always use 'mvn test install' on multi module projects? (Or third, I'm completely wrong and my whole project configurationis somehow broken)
Finally, the test project hasn't any content, yet, just dependencies so the jar is empty. But that shouldn't be a problem, right?
Cheers,
Jan
There were ideas for Maven 3 to allow the various mojos to see the whole build and do magic like "if none of my upstream projects changed, skip my tests" and things like that.
But as it is, each module is independent. Dependencies will only be resolved from the local repository. So if you don't mvn install, your tests won't work.

Resources