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). What could be the issue?
If I understand correctly, you checkout the repository under ncs/nrf, 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
Thanks for the response @aalvarez . That helped. But now sonar-scanner fails with the following exception trace.
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.
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.