How to set multiple source locations in Sonar Server?

I am using Maven 3 and in my java project, the pom file contains one source location as follows.

<build> <sourceDirectory>src/main/java</sourceDirectory> <testSourceDirectory>src/test/java</testSourceDirectory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>${JDK}</source> <target>${JDK}</target> <excludes> <!--<exclude>**/**/api/notification/**/INotificationProfileManager.java</exclude> --> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <configuration> <version>1.3</version> <archive> <manifest> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> <manifestEntries> <Class-Path>./MubarsherTradeClasspath-1.0.jar</Class-Path> <Specification-Vendor>Mubasher</Specification-Vendor> <Implementation-Vendor>Mubasher</Implementation-Vendor> <Sealed>false</Sealed> </manifestEntries> </archive> </configuration> </plugin> 

After compilation, the created files are in the path .../generate/src/main/java/... When the Sonar analysis is performed, it checks for these generated classes, which themselves have the path ../src/main/java/... , so the analysis is not performed.

So, I need to know how to identify several source paths for sonar analysis?

+6
source share
1 answer

you can use sonar-runner for this. This is more useful.

You can declare two modules. One of the source directories. Then you need to configure the execution by declaring a properties file.

This file should look like this:

 sonar.projectKey=myproject sonar.projectName=myprojectname sonar.projectVersion=version sonar.sourceEncoding=UTF-8 sonar.modules=normalsource-module, generated-module normalsource-module.sonar.projectName=Normal Sources Module normalsource-module.sonar.language=java normalsource-module.sonar.sources=src/main/java normalsource-module.sonar.binaries=target/classes normalsource-module.sonar.projectBaseDir=. generated-module.sonar.projectName=Generated Sources Module (Java) generated-module.sonar.language=java generated-module.sonar.sources=src/main/java generated-module.sonar.binaries=target/classes generated-module.sonar.projectBaseDir=. 

Hope this helps,

Hi

+8
source

All Articles