# How can I analyze the project with the sonar-project.properties file located in the subdirectory?

**URL:** <https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532>\
**Category:** SonarQube Server / Community Build\
**Created:** [November 23, 2022, 4:27pm UTC](https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532 "2022-11-23T16:27:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![codeluyor](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@codeluyor](https://community.sonarsource.com/u/codeluyor)\
**Post date:** [November 23, 2022, 4:27pm UTC](https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532/1 "2022-11-23T16:27:07Z")

</div>

**The relevant section of my project directory is as follows:**

```auto
> |- Project_Source
  | >|- configs
  | | >|- sonar-project.properties
  | | >|- CMakeList.txt
  | | >|- // other config files ...
  | >|- executable
  | >|- inc
  | >|- drv
  | >|- src-common

```

**My commands are as follows:**

```auto
cd Project_Source
cd configs
mkdir build-sonarqube
cd build-sonarqube
cmake ..
cd ..
build-wrapper-linux-x86-64 --out-dir bw-output cmake --build build-sonarqube/ --config Release 
sonar-scanner -Dsonar.projectKey=... -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.host.url=http://... -Dsonar.login=....

```

Before this editing, the files in the **“configs”** folder were placed under **“project\_source”** and analysis output was obtained without any problems. Since I wanted to ensure code integrity and keep it in a separate place, I wanted to analyze it by taking it to a subfolder (of course, I rearranged the relative and absolute paths) but as a result, 0 files were analyzed.

The analysis is a success, but the number of scanned files shows 0, what exactly is the reason for this?

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [November 24, 2022, 1:35pm UTC](https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532/2 "2022-11-24T13:35:55Z")

</div>

You will need to initiate the scan from the root directory you want to scan. If you can’t keep the _sonar-project.properties_ file there, you should point to it [as documented](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/)

> - The property project.settings can be used to specify the path to the project configuration file (this option is incompatible with the `sonar.projectBaseDir` property). Ex:
> 
> ```auto
> sonar-scanner -Dproject.settings=../myproject.properties
> 
> ```

---

<div class="post-metadata">

**Author:** ![codeluyor](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@codeluyor](https://community.sonarsource.com/u/codeluyor)\
**Post date:** [November 28, 2022, 7:59am UTC](https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532/3 "2022-11-28T07:59:12Z")

</div>

So you mean move the sonar-project.properties file to the root of the project?

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [November 28, 2022, 9:05am UTC](https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532/4 "2022-11-28T09:05:02Z")

</div>

It’s one option – or take the other option suggested and use `-Dproject.settings` to point to the properties file in the subdirectory, while still initiating the scan from the root of the project.

---

<div class="post-metadata">

**Author:** ![codeluyor](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@codeluyor](https://community.sonarsource.com/u/codeluyor)\
**Post date:** [November 28, 2022, 3:00pm UTC](https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532/5 "2022-11-28T15:00:57Z")

</div>

Unfortunately, I tried this command after your previous comment, and the result is successful but the file analysis still shows 0.

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [November 29, 2022, 12:34pm UTC](https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532/6 "2022-11-29T12:34:51Z")

</div>

I would suggest sharing the logs from your scanner command.

---

<div class="post-metadata">

**Author:** ![codeluyor](https://avatars.discourse-cdn.com/v4/letter/c/8e7dd6/32.png) [@codeluyor](https://community.sonarsource.com/u/codeluyor)\
**Post date:** [May 31, 2023, 4:53pm UTC](https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532/7 "2023-05-31T16:53:48Z")

</div>

I could not reply because of a long break, there was a place I missed in the path configuration definition, and the problem has been fixed.

---

<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:** [June 7, 2023, 4:53pm UTC](https://community.sonarsource.com/t/how-can-i-analyze-the-project-with-the-sonar-project-properties-file-located-in-the-subdirectory/76532/8 "2023-06-07T16:53:58Z")

</div>

Closed on June 7, 2023, 4:53pm UTC

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