Which server do I put sonar-ant-task-*.jar?

I need to enable Sonarqube analysis for my Ant builds. I have the following servers: 1 Jenkins master, 1 Jenkins slave, & 1 Sonarqube. Which server should I put sonar-ant-task-*.jar?


The jar needs to be available to Ant, so presumably on the machine(s) where analysis takes place. This is really an Ant question, so if you have a local Ant expert you might want to consult her/him.


this Ant task starts the Sonarqube scanner, so it has to be available on the build machine (Jenkins) only.
See https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Ant for all the details.
General advice:
you may simply put the sonar-ant-task-*.jar in $ANT_HOME/lib but it’s better to keep your ant core installation clean and use a special folder for addon tasks via ANT_ARGS -lib
Better use batch or shell script to start your ant files, for example


set JAVA_HOME=C:\java\jdk\1.8.0_171
set ANT_HOME=C:\ant
set ANT_ARGS=-lib C:\ant_xtralibs;C:\ant_testlibs
set PATH=%PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin

:: default
call ant -f %1

:: debug
::call ant -debug -f %1

Linux, don’t forget the quotationmarks on the ANT_ARGS line !

  ANT_ARGS="-lib /usr/local/ant_xtralibs:/usr/local/ant_testlibs"
  export ANT_ARGS

Some advantages of starting ant like that :

• ANT_ARGS is a special environment variable. Its content is automatically added to the invocation of ant.
• you may use your own ant settings on a machine where you have no admin rights
• using a separate folder for your ant addon libs and load via -lib option keeps your ant installation clean and avoids polluting the %ANT_HOME%/lib folder


1 Like