achraf
achraf

Reputation: 15

exclude dependencies when running sonar analysis

I have a test project requiring some heavy jars which i put in ${M2_HOME}\test\src\main\resources\ and add them in the pom.xml using :

    <dependency>
        <groupId>server</groupId>
        <artifactId>server</artifactId>
        <version>1.0</version>
        <scope>system</scope>
        <systemPath>${M2_HOME}\test\src\main\resources\server.jar</systemPath>
    </dependency>
    <dependency>
        <groupId>client</groupId>
        <artifactId>client</artifactId>
        <version>6.0</version>
        <scope>system</scope>
        <systemPath>${M2_HOME}\test\src\main\resources\client.jar</systemPath>
    </dependency> 

I want to know if it possible to exclude them during sonar analysis, or generally just analyze java sources folder.

Upvotes: 1

Views: 2885

Answers (1)

Pascal Thivent
Pascal Thivent

Reputation: 570315

If the problem is that these JARs are included in sonar analysis because they are located in src/main/resources, then one obvious solution would be to put them somewhere else (see the post scriptum). If for whatever reason this is not possible, please clarify (I'd really like to know why you put these JARs under resources).

If the problem is that these JARs are declared as dependencies, you could use a specific profile not including them to run sonar.

PS: Note that using the system scope is a bad practice and has several drawbacks (as mentioned here or here). A cleaner approach would be to use a file based repository as suggested in this answer.

Upvotes: 1

Related Questions