Sonarqube properties file in sonar ant tasks (sonarqube-ant-task-2.5.jar)


(vazzilena) #1


Most of my project properties are declared in the ant build script. I would like to also specify custom SONAR_RUNNER_OPTS and SONAR_SCANNER_OPTS and I am thinking about putting those in sonarqube properties file, that the project currently does not have (I would like to avoid command line arguments as much as possible)

So, given the fact I am using sonar ant tasks, what is the right way to supply the sonar property file to ant?

My ant task looks like this:

(Gilbert Rebhan) #2

SONAR_RUNNER_OPTS and SONAR_SCANNER_OPTS are environment variables.
Just keep the values you want to set in your propertyfile and use them in your ant script like that, before you call the sonar task:

<!-- windows-->
<exec executable="cmd">
  <arg value="/c"/>
  <env key="SONAR_RUNNER_OPTS" value="${sonarrunneropts}"/>
  <env key="SONAR_SCANNER_OPTS" value="${sonarscannerropts}"/>
  <arg value="set"/>
<!--linux -->
<exec executable="sh">
   <arg value="-c"/>
   <arg value="export SONAR_RUNNER_OPTS=${sonarrunneropts}"/>
   <arg value="export SONAR_SCANNER_OPTS=${sonarscanneropts}"/>
  <!-- execute Sonar -->
  <sonar:sonar />


(vazzilena) #3

I will do as you suggest.

I was hoping that I can leave the OS specific logic out of the script and rather load those from properties file, but looks like this is not the way.

Many thanks for looking into my problem :slight_smile: