Importing external issues on properties files via Maven Java Scan

Hello All,

Need your help here, I am trying to import external issues on .properties/.json resource files in Generic Issue Format during maven scan, but fail to import any, I tried either absolute file path or relative file path.

my external issue json file like below:

{
  "issues": [
    {
      "severity": "MAJOR",
      "type": "BUG",
      "primaryLocation": {
        "textRange": {
          "startLine": 1,
          "endLine": 1,
          "startColumn": 1,
          "endColumn": 2,
          "lineText": "a=test"
        },
        "message": "text: a",
        "filePath": "src/main/resources/hello.properties"
      },
      "engineId": "properties",
      "ruleId": "properties-rule"
    }
  ]
}


my mvn scan command:


mvn -Dmaven.test.skip=true -B -f pom.xml clean install  sonar:sonar -Dsonar.projectKey=demo-maven -Dsonar.projectName=demo-maven -Dsonar.sourceEncoding=utf-8 -Dsonar.externalIssuesReportPaths=maven_issues.json -X

Scan result shows the files in maven_issues.json are unknown and thus failed to import

Could you help share how we can make the import work in this case?

Thanks a lot in advance

Best regards

could someone kindly help please? Thanks!

Hey there.

Please don’t bump threads after a day. :slight_smile: In fact, it becomes less likely we’ll see it, as once a thread has a reply it moves off our list of “threads with no replies”.

You’ll need to make sure the scanner is aware of your src/main/resources directory, which it won’t be by default

For example, having this in your pom.xml file:

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <maven.compiler.release>11</maven.compiler.release>
    <sonar.sources>src/main/java,src/main/resources</sonar.sources>
  </properties>

Hello @Colin,
Thank you very much for the reply, I was almost giving up to get response, and didn’t releaize it’s because I was making my post off your thread list, nice remind, I now catch it.

Your solution works for me! thanks again~

however I have got a new issue, as I am analyzing a multi-module project for our client, some of their modules in scope is having no resources folder, and mvn sonar scan then reports error

.<moduleA>/src/main/resources does not exist for Maven module A,  Please check the property sonar.sources

Wondering if there is a way to silently skip this error without modifying the source project? because the source project is out of our control

Best Regards

Hello @Colin,
I guess I know how to solve my followed question, that resources not exist error. I reset the sonar.sources value to src/main, then it is ok. thanks again for your help! and I am closing this issue now.

Best Regards

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.