Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant read external properties for sonar scan #90

Open
vidhangithub opened this issue Oct 12, 2022 · 1 comment
Open

Cant read external properties for sonar scan #90

vidhangithub opened this issue Oct 12, 2022 · 1 comment

Comments

@vidhangithub
Copy link

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.

@slawekjaranowski
Copy link
Member

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

Try:

mvn initialize sonar:sona

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants