# Sonar-project.properties not read by sonarscanner

**URL:** <https://community.sonarsource.com/t/sonar-project-properties-not-read-by-sonarscanner/85383>\
**Category:** SonarQube Cloud\
**Tags:** github-actions, cfamily\
**Created:** [March 8, 2023, 7:15am UTC](https://community.sonarsource.com/t/sonar-project-properties-not-read-by-sonarscanner/85383 "2023-03-08T07:15:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![forkbeard](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/forkbeard/32/36946_2.png) [@forkbeard](https://community.sonarsource.com/u/forkbeard)\
**Post date:** [March 8, 2023, 7:15am UTC](https://community.sonarsource.com/t/sonar-project-properties-not-read-by-sonarscanner/85383/1 "2023-03-08T07:15:05Z")

</div>

- ALM used : Github
- CI system used : Github actions
- Scanner command used when applicable (private details masked): sonar-scanner -X --define sonar.cfamily.build-wrapper-output=“${{ env.BUILD\_WRAPPER\_OUT\_DIR }}”
- Languages of the repository: C, CMake
- Only if the SonarCloud project is public, the URL: [https://sonarcloud.io/project/overview?id=balaji-nordic\_sdk-nrf](https://sonarcloud.io/project/overview?id=balaji-nordic_sdk-nrf)
  - And if you need help with pull request decoration, then the URL to the PR too: [workflow: Move common parts of sonarcloud and sonarcloud-native-posix by balaji-nordic · Pull Request #96 · balaji-nordic/sdk-nrf · GitHub](https://github.com/balaji-nordic/sdk-nrf/pull/96/files)

- Error observed : The `sonar-project.properties` file does not seem to be read by sonarscanner. It uses default options and fails.
- Steps to reproduce: Just re-run : [workflow: Move common parts of sonarcloud and sonarcloud-native-posix · balaji-nordic/sdk-nrf@ea85f15 · GitHub](https://github.com/balaji-nordic/sdk-nrf/actions/runs/4352800996)
- Potential workaround: Not use sonar-project.properties file and instead give all options as input to sonar-scanner  
ted)!\*\*

In the PR mentioned above, I tried to move some sonar-scanner options to the sonar-project.properties file (which I placed in the root folder of the repo). However, when I ran the github workflow that had sonar-scanner command in it, it does not seem to parse the file. For example, I had set `sonar.host.url="https://sonarcloud.io"` in the file. But sonar-scanner tries to connect to localhost/127.0.0.1:9000 and fails. (See logs here → [workflow: Move common parts of sonarcloud and sonarcloud-native-posix · balaji-nordic/sdk-nrf@ea85f15 · GitHub](https://github.com/balaji-nordic/sdk-nrf/actions/runs/4352800996/jobs/7606031274)). What could be the issue?

---

<div class="post-metadata">

**Author:** ![aalvarez](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/aalvarez/32/39649_2.png) [@aalvarez](https://community.sonarsource.com/u/aalvarez)\
**Post date:** [March 8, 2023, 9:37am UTC](https://community.sonarsource.com/t/sonar-project-properties-not-read-by-sonarscanner/85383/2 "2023-03-08T09:37:59Z")

</div>

Hello Balaji,

If I understand correctly, you checkout the repository under [`ncs/nrf`](https://github.com/balaji-nordic/sdk-nrf/blob/ea85f15cd17563e0f244c2a06758d508e34e069f/.github/workflows/sonarcloud.yml#L22), right? `sonar-scanner` will look for that file on the working directory, which by default will be two levels up. You can try specifying the path explicitly with

`sonar-scanner -Dproject.settings=ncs/nrf/sonar-project.properties`

Let me know if this helps.

---

<div class="post-metadata">

**Author:** ![forkbeard](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/forkbeard/32/36946_2.png) [@forkbeard](https://community.sonarsource.com/u/forkbeard)\
**Post date:** [March 9, 2023, 7:43am UTC](https://community.sonarsource.com/t/sonar-project-properties-not-read-by-sonarscanner/85383/4 "2023-03-09T07:43:58Z")

</div>

Thanks for the response @aalvarez . That helped. But now sonar-scanner fails with the following exception trace.

```auto
2023-03-09T07:28:22.9066155Z []
2023-03-09T07:28:23.0365322Z 07:28:23.035 INFO: ------------------------------------------------------------------------
2023-03-09T07:28:23.0365730Z 07:28:23.036 INFO: EXECUTION FAILURE
2023-03-09T07:28:23.0366166Z 07:28:23.036 INFO: ------------------------------------------------------------------------
2023-03-09T07:28:23.0370189Z 07:28:23.036 INFO: Total time: 4:06.726s
2023-03-09T07:28:23.1704054Z 07:28:23.169 ERROR: Error during SonarScanner execution
2023-03-09T07:28:23.1704785Z org.sonar.java.AnalysisException: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.
2023-03-09T07:28:23.1705366Z 07:28:23.169 INFO: Final Memory: 31M/107M
2023-03-09T07:28:23.1706472Z 07:28:23.169 INFO: ------------------------------------------------------------------------
2023-03-09T07:28:23.1715428Z at org.sonar.java.classpath.ClasspathForMain.init(ClasspathForMain.java:75)
2023-03-09T07:28:23.1716076Z at org.sonar.java.classpath.AbstractClasspath.getElements(AbstractClasspath.java:319)
2023-03-09T07:28:23.1716683Z at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:205)
2023-03-09T07:28:23.1717165Z at org.sonar.java.JavaFrontend.<init>(JavaFrontend.java:97)
2023-03-09T07:28:23.1717621Z at org.sonar.plugins.java.JavaSensor.execute(JavaSensor.java:112)
2023-03-09T07:28:23.1718189Z at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
2023-03-09T07:28:23.1718828Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
2023-03-09T07:28:23.1719487Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:48)
2023-03-09T07:28:23.1720188Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:66)
2023-03-09T07:28:23.1720877Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:48)
2023-03-09T07:28:23.1721773Z at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
2023-03-09T07:28:23.1722429Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2023-03-09T07:28:23.1723060Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-03-09T07:28:23.1723638Z at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:468)
2023-03-09T07:28:23.1724286Z at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:464)
2023-03-09T07:28:23.1724959Z at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:420)
2023-03-09T07:28:23.1725618Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2023-03-09T07:28:23.1726226Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-03-09T07:28:23.1726834Z at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:130)
2023-03-09T07:28:23.1727481Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2023-03-09T07:28:23.1728099Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-03-09T07:28:23.1728626Z at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
2023-03-09T07:28:23.1729079Z at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
2023-03-09T07:28:23.1729715Z at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
2023-03-09T07:28:23.1730407Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-03-09T07:28:23.1730987Z at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2023-03-09T07:28:23.1731595Z at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2023-03-09T07:28:23.1732095Z at java.base/java.lang.reflect.Method.invoke(Unknown Source)
2023-03-09T07:28:23.1732683Z at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
2023-03-09T07:28:23.1733226Z at com.sun.proxy.$Proxy0.execute(Unknown Source)
2023-03-09T07:28:23.1733916Z at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
2023-03-09T07:28:23.1734500Z at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
2023-03-09T07:28:23.1735013Z at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
2023-03-09T07:28:23.1735457Z at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
2023-03-09T07:28:23.1735891Z at org.sonarsource.scanner.cli.Main.main(Main.java:61)
2023-03-09T07:28:23.5182905Z ##[error]Process completed with exit code 1.
2023-03-09T07:28:23.5232367Z Post job cleanup.

```

I cant figure out any other error. Here is the full log [workflow: Move common parts of sonarcloud and sonarcloud-native-posix · balaji-nordic/sdk-nrf@0c7f00c · GitHub](https://github.com/balaji-nordic/sdk-nrf/actions/runs/4371949785/jobs/7648334550) (you will need to click ‘Download log archive’ to get the log as it is pretty huge.

---

<div class="post-metadata">

**Author:** ![forkbeard](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/forkbeard/32/36946_2.png) [@forkbeard](https://community.sonarsource.com/u/forkbeard)\
**Post date:** [March 9, 2023, 7:46am UTC](https://community.sonarsource.com/t/sonar-project-properties-not-read-by-sonarscanner/85383/5 "2023-03-09T07:46:24Z")

</div>

This text stands out.

```auto
2023-03-09T07:28:23.1704785Z org.sonar.java.AnalysisException: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.

```

Could it be that my exclusions filter did not work? I do exclude .java files along with other files here → [workflow: Move common parts of sonarcloud and sonarcloud-native-posix by balaji-nordic · Pull Request #99 · balaji-nordic/sdk-nrf · GitHub](https://github.com/balaji-nordic/sdk-nrf/pull/99/files#diff-43ed9d31bea2a6d518d69836bcd1a8e6bd81bf4df96c4745792c220ca5aa549cR4)

---

<div class="post-metadata">

**Author:** ![aalvarez](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/aalvarez/32/39649_2.png) [@aalvarez](https://community.sonarsource.com/u/aalvarez)\
**Post date:** [March 9, 2023, 7:58am UTC](https://community.sonarsource.com/t/sonar-project-properties-not-read-by-sonarscanner/85383/6 "2023-03-09T07:58:17Z")

</div>

Try removing the quotation marks on the config file. i.e.

```auto
sonar.exclusions=ncs/modules/ **,ncs/zephyr/** ,ncs/nrf/ext/ **,** /*.py, **/*.vsdx,** twister-out **,** /*.java, **/*.html,** /*.xml,**/*.php
sonar.cpd.exclusions= **CMakeFiles**

```

---

<div class="post-metadata">

**Author:** ![forkbeard](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/forkbeard/32/36946_2.png) [@forkbeard](https://community.sonarsource.com/u/forkbeard)\
**Post date:** [March 9, 2023, 8:33am UTC](https://community.sonarsource.com/t/sonar-project-properties-not-read-by-sonarscanner/85383/7 "2023-03-09T08:33:01Z")

</div>

that was it. Thanks for your help 🙂 Appreciate it.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [March 16, 2023, 10:13am UTC](https://community.sonarsource.com/t/sonar-project-properties-not-read-by-sonarscanner/85383/9 "2023-03-16T10:13:32Z")

</div>

Closed on March 16, 2023, 10:13am UTC

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