Skip to content

Cant read external properties for sonar scan #90

@vidhangithub

Description

@vidhangithub

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions