- Set exclusions in the POM.XML file.
- Set exclusions in the SONAR Runner plugin, in Jenkins.
Use exclusion to analyze everything but the specified files:
- sonar.exclusions - to exclude source code files
Use inclusion to analyzes only the specified files:
- sonar.test.exclusions - to exclude unit test files
- sonar.inclusions
- sonar.test.inclusions
For example, in POM.XML:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> (...) <properties> (...) <sonar.exclusions>**/*.css,**/*.js</sonar.exclusions> </properties> </project>
In Jenkins, you can configure the SONAR plugin inside each job. In the Post-build Action you can set this configuration in the "Aditional properties" fields with "-D" prefix.
[INFO] [15:20:44.174] Source paths: src/main/webapp, pom.xml, src/main/java [INFO] [15:20:44.175] Test paths: src/test/java [INFO] [15:20:44.175] Binary dirs: target/classes [INFO] [15:20:44.176] Source encoding: UTF-8, default locale: en_US [INFO] [15:20:44.176] Index files [INFO] [15:20:44.194] Excluded sources: [INFO] [15:20:44.194] **/*.css [INFO] [15:20:44.194] **/*.js [INFO] [15:20:47.235] 366 files indexed
No hay comentarios:
Publicar un comentario