PHP and Gradle project

I have a PHP project built using Gradle (don’t ask why and I cannot change it.). I have setup the project in Githhub with the sonarcloud token and added the build.yml following the Gradle setup steps. Branch in main. The integration with sonarcloud works fine however I am not getting any files or lines of code analyzed. Below is setup:

id “org.sonarqube” version “”


name: SonarCloud
      - main
    types: [opened, synchronize, reopened]
    name: Build and analyze
    runs-on: ubuntu-latest
      - uses: actions/checkout@v3
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: Set up JDK 17
        uses: actions/setup-java@v3
          java-version: 17
          distribution: 'zulu' # Alternative distribution options are available
      - name: Cache SonarCloud packages
        uses: actions/cache@v3
          path: ~/.sonar/cache
          key: ${{ runner.os }}-sonar
          restore-keys: ${{ runner.os }}-sonar
      - name: Cache Gradle packages
        uses: actions/cache@v3
          path: ~/.gradle/caches
          key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
          restore-keys: ${{ runner.os }}-gradle
      - name: Build and analyze
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        run: ./gradlew build sonar --info

Below is what I am getting.

and Sonarcloud also shows “The main branch of this project is empty.” for this project.

There are no issues reported in the Github Actions logs other than “0 languages detected in 0 preprocessed files”.

We have another project which is Java using Gradle and shows data for the scans so we know the integration is setup fine but this PHP project using Gradle is giving us grief.

Any help would be appreciated.


Leaving aside your building with Gradle… are you really forced to analyze with Gradle? Normally we do tell people to use the SonarScanner that relates to their build tool, but in your case, I think we can make an exception. :joy:

The reason to use SonarScanner for Gradle if you’re building with Gradle is that it saves you the burden of anlaysis configuration by reading e.g. your source & test file locations out of the build context. But that’s typically a very Java-centric config. And I suspect that’s the problem here: analysis is being fed an empty set for sonar.sources because there are no Java files in your project.

So instead, you should either switch to using SonarScanner CLI or manually override the analysis properties to point to your actual project files.