properties-maven-plugin icon indicating copy to clipboard operation
properties-maven-plugin copied to clipboard

Cant read external properties for sonar scan

Open vidhangithub opened this issue 2 years ago • 1 comments

I'm trying to read few exclusion rules from a external .properties file , so that I can keep my pom.xml clean. I tried using properties-maven-plugin but it fails to see the property (and I don't see that much information /logs about how to debug it to show me like the property file being read and the values that it retrieved). Below is the plugin definition on my pom.xml

 <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.0.0</version>
                <executions>
                    <execution>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>${basedir}/sonar-project.properties</file>
                            </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

The properties file inside my base dir is as below :-

sonar.issue.ignore.multicriteria=e1
sonar.issue.ignore.multicriteria.e1.ruleKey=java:S4502
sonar.issue.ignore.multicriteria.e1.resourceKey=**/*.java

when I trigger "mvn sonar:sonar" it simply ignores the exclusions defined in properties file. But when I define these on pom.xml as below , "mvn sonar:sonar" consider those exclusions.

<properties>
<sonar.issue.ignore.multicriteria>e1</sonar.issue.ignore.multicriteria>
        <sonar.issue.ignore.multicriteria.e1.ruleKey>java:S4502</sonar.issue.ignore.multicriteria.e1.ruleKey>
        <sonar.issue.ignore.multicriteria.e1.resourceKey>**/*.java</sonar.issue.ignore.multicriteria.e1.resourceKey>
</properties>

Can somebody help here? Thanks in advance.

vidhangithub avatar Oct 12 '22 19:10 vidhangithub

When you executed only one goal mvn sonar:sona I afraid that properties-maven-plugin is not executed.

Try:

mvn initialize sonar:sona

slawekjaranowski avatar Oct 22 '23 16:10 slawekjaranowski