RE: Configure SonarQube in my workspace

Patricia Hevia, 8 Jaren geleden aangepast. Junior Member Berichten: 69 Aanmelddatum: 24-3-11 Recente berichten
Hello,

I am working with Liferay DXP and I would like integrate SonarQube in my workspace, I am using gradle.

My workspace is called: test-workpace

My gradle.properies file (path: test-workspace/gradle.properties) is:
systemProp.sonar.host.url=http://localhost:9000
systemProp.sonar.sourceEncoding=UTF-8
systemProp.sonar.forceAuthentication=true
systemProp.sonar.login=<mytoken>

# Definición de variables para el proyecto.
description = 'Gradle - Sample Project'
group = 'com.test.sonarqube.gradle'
version = '1.0.0'</mytoken>


My build.gradle file (path: test-workspace/build.gradle) is:
buildscript {
        repositories {
                mavenLocal()
                jcenter()
                maven {
                        url "https://plugins.gradle.org/m2/"
                }
        }
        dependencies {
                classpath group: "org.sonarsource.scanner.gradle", name:"sonarqube-gradle-plugin", version:"2.5"
        }
}
group = 'com.test.sonarqube.gradle'
apply plugin: "org.sonarqube"


When I execute gradle sonarqube all workspace is scanned but I would like to configure each modules like a project in SonarQube.

Someone know how to configure gradle files to do it?.

Thank you very much!
thumbnail
Sushil Patidar, 8 Jaren geleden aangepast. Expert Berichten: 467 Aanmelddatum: 31-10-11 Recente berichten
Hi,

i think configuration of following properties in each project may solve your issue.
sonar.projectKey [${project.group}:]${project.name} for root module
<root module key>:<module path> for submodules

sonar.projectName ${project.name}


Regards
thumbnail
Vishal Panchal, 6 Jaren geleden aangepast. Expert Berichten: 289 Aanmelddatum: 20-5-12 Recente berichten
Thanks Sushil, that worked.
thumbnail
Lokesh Sharma, 5 Jaren geleden aangepast. Junior Member Berichten: 54 Aanmelddatum: 30-7-15 Recente berichten
Hi Vishal,
Can you please provide you gradle file Facing same issue
Rafal Pydyniak, 5 Jaren geleden aangepast. New Member Berichten: 4 Aanmelddatum: 6-12-16 Recente berichten
Hello,
I know it's an old topic but if that helps you can just run it like: 
./gradlew sonarqube \
  -Dsonar.projectKey=test2 \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.login=115ee4c271411c118e7935ee705bdebcdf714b4a
you just need to provide your projectKey, url of your SonarQube and your token as login (the one you generated when you created a project - if you don't have it you can always generate it again in your account settings in security tab)The only thing you need for that is to have sonarqube plugin in build.gradle
plugins {
  id "org.sonarqube" version "2.7"
}
I used to use that (before Jenkins) and that worked but I've only tested in on particular modules not the whole project (just because we wanted to have few SonarQube projects for one workspace because we have quite a lot modules).If perhaps you wanted to use Jenkins instead you can check this SonarQube with Jenkins and Liferay integration tutorial
Best regards and hope that helpsRafał Pydyniak