# Getting The main branch of this project is empty while building my project

**URL:** <https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166>\
**Category:** SonarQube Server / Community Build\
**Created:** [November 1, 2019, 11:51am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166 "2019-11-01T11:51:32Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadab\_sayeed](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shadab_sayeed/32/7365_2.png) [@shadab\_sayeed](https://community.sonarsource.com/u/shadab_sayeed)\
**Post date:** [November 1, 2019, 11:51am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/1 "2019-11-01T11:51:32Z")

</div>

I am using sonarqube to check the code quality of my test scripts.I dont have the main source code in my project as It only consists test scripts. After building my project I am getting message “The main branch of this project is empty.” and all metrics are 0 on sonar dashboard.What should I do if I have to check the quality of test script also.

I have tried to explicitly define sonar.source to src/test/java but It didnt work at all.Please help

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [November 4, 2019, 4:33pm UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/2 "2019-11-04T16:33:10Z")

</div>

Hi,

Welcome to the community!

Somehow your definition of `sonar.sources` isn’t working. You wrote `sonar.source`. Was that a typo in your composition of this post, or is that actually what you set? Because the recognized parameter ends with an ‘s’.

BTW, you’re seeing the message that your project is empty because your files are being analyzed _as tests_ and so no LOC count is being calculated. It’s that metric, specifically, that the project homepage keys on to know whether or not to draw itself. Once you get `sonar.sources` sorted out, this problem should go away.

BTW, how are you analyzing? With Maven? And what’s your analysis command?

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![shadab\_sayeed](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shadab_sayeed/32/7365_2.png) [@shadab\_sayeed](https://community.sonarsource.com/u/shadab_sayeed)\
**Post date:** [November 27, 2019, 11:10am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/3 "2019-11-27T11:10:17Z")

</div>

Hi Ann,

Thank you so much for the reply and sorry for too much delay in the reply.Actually it was a typo in sonar.source. I used exact sonar.sources in the configuration but it didnt work.

I have defined sonar.sources in build.gradle file as:

![3](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/b/b46aef378efdbe79c1c8a1ad1ea48044e0e2f853.png)

Still it shows “The project is empty”.

I don’t know whether it is analyzing my project or not. And if it is analyzing then why it is not showing any bug, vulnerability or defect etc.

---

<div class="post-metadata">

**Author:** ![shadab\_sayeed](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shadab_sayeed/32/7365_2.png) [@shadab\_sayeed](https://community.sonarsource.com/u/shadab_sayeed)\
**Post date:** [November 27, 2019, 11:10am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/4 "2019-11-27T11:10:49Z")

</div>

Please have a look on my project’s structure:

 ![1](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/a/ae8b89d3dd00bd8bfe1afdab1081b44d3f812f23.png)

---

<div class="post-metadata">

**Author:** ![shadab\_sayeed](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shadab_sayeed/32/7365_2.png) [@shadab\_sayeed](https://community.sonarsource.com/u/shadab_sayeed)\
**Post date:** [November 27, 2019, 11:11am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/5 "2019-11-27T11:11:53Z")

</div>

![4](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/0/07bfd88d943c53ab3a144e9c4596cd47a2e60e88.png)

---

<div class="post-metadata">

**Author:** ![shadab\_sayeed](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shadab_sayeed/32/7365_2.png) [@shadab\_sayeed](https://community.sonarsource.com/u/shadab_sayeed)\
**Post date:** [November 27, 2019, 11:12am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/6 "2019-11-27T11:12:26Z")

</div>

When I open my project on sonar server and goes to the code section it shows as:

 ![5](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/e/ee9c9a906a3fbb9d11e66201d043e18f3c363f27.png)

---

<div class="post-metadata">

**Author:** ![shadab\_sayeed](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shadab_sayeed/32/7365_2.png) [@shadab\_sayeed](https://community.sonarsource.com/u/shadab_sayeed)\
**Post date:** [November 27, 2019, 11:12am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/7 "2019-11-27T11:12:59Z")

</div>

After opening the folder structure:

 ![6](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/a/aa0a9c816d163c3f9a76453b5ec9557ed4ab0fd6.png)

---

<div class="post-metadata">

**Author:** ![shadab\_sayeed](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shadab_sayeed/32/7365_2.png) [@shadab\_sayeed](https://community.sonarsource.com/u/shadab_sayeed)\
**Post date:** [November 27, 2019, 11:16am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/8 "2019-11-27T11:16:58Z")

</div>

> [@ganncamp](#):
>
> And what’s your analysis command

gradle clean sonarqube

and for maven i am using mvn clean sonar:sonar

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [November 27, 2019, 11:33am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/9 "2019-11-27T11:33:46Z")

</div>

Hi,

you might use  
[https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-gradle](https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-gradle)  
for a quick test if it works correctly.

Gilbert

---

<div class="post-metadata">

**Author:** ![shadab\_sayeed](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shadab_sayeed/32/7365_2.png) [@shadab\_sayeed](https://community.sonarsource.com/u/shadab_sayeed)\
**Post date:** [November 27, 2019, 11:59am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/10 "2019-11-27T11:59:03Z")

</div>

Hi Gilbert,

Actually the project which you provided above consist a main source file (App.java) whose unit test is written in AppTest.java in test folder. So here the sonar will analyse the code because main source code is available but my primary problem is that my framework does not consist main source code as I have a automation testing framework which have no main package (only consists test scripts in test folder).Can you please check it without source code.

Regards,  
Shadab

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [December 2, 2019, 7:37pm UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/11 "2019-12-02T19:37:32Z")

</div>

Hi Shadab,

I think instead of setting `sonar.sources` to `src` you need to set it to `src/test`.

&nbsp;  
HTH,  
Ann

---

<div class="post-metadata">

**Author:** ![shadab\_sayeed](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/shadab_sayeed/32/7365_2.png) [@shadab\_sayeed](https://community.sonarsource.com/u/shadab_sayeed)\
**Post date:** [December 4, 2019, 6:38am UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/12 "2019-12-04T06:38:39Z")

</div>

Hi Ann,

It is still not working…I tried the same (src/test) for sonar source

subprojects {  
sonarqube {  
properties {  
property “sonar.sources”, “src/test”  
}  
}  
}

Is there any other sonar configuration which is overriding my configuration?

---

<div class="post-metadata">

**Author:** ![anon67236913](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@anon67236913](https://community.sonarsource.com/u/anon67236913)\
**Post date:** [December 4, 2019, 6:08pm UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/13 "2019-12-04T18:08:07Z")

</div>

Hi,

did you already check the global | project settings for exclusions in Sonarqube server ?  
Should also be seen in the analysis logs.

Gilbert

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [December 5, 2019, 1:23pm UTC](https://community.sonarsource.com/t/getting-the-main-branch-of-this-project-is-empty-while-building-my-project/16166/14 "2019-12-05T13:23:12Z")

</div>

Hi guys,

I think at this point it will be useful to use the `sonar.scanner.dumpToFile` [parameter](https://docs.sonarqube.org/latest/analysis/analysis-parameters/) (you’ll need to provide a file name as the value) so we can see what value `sonar.sources`, and also maybe `sonar.tests` actually end up with.

&nbsp;  
Ann
