SonarScanner for Ant (Deprecated)
On this page
SonarScanner for Ant is deprecated. You can start using the SonarScanner instead by following the instructions below.
The SonarScanner for Ant provides a task
to allow the integration of a SonarQube Community Build analysis into an Apache Ant build script.
Moving from SonarScanner for Ant to SonarScanner CLI
The SonarScanner for Ant is an Ant Task that is a wrapper of the SonarScanner CLI, which works by invoking the SonarScanner CLI and passing to it all properties named following a sonar.*
convention. It is now deprecated. We recommend using the SonarScanner CLI directly.
If you’re still using the SonarScanner for Ant, follow these steps to remove the wrapper from your build file, create a sonar-project.properties
in your project, and run the analysis.
Prerequisites
The SonarScanner CLI is installed on your machine.
Configuring your sonar properties
- Create a
sonar-project.properties
in your project. - Move the
sonar.*
properties from yourbuild.xml
file to thesonar-project.properties
file. For example:
See SonarScanner CLI for more information on how to configure project properties.
Running the analysis
Create a Sonar authentication token and run the analysis using sonar-scanner -Dsonar.token=myAuthenticationToken
.
Alternatively, instead of passing the token in your command line, you can create the SONAR_TOKEN
environment variable and set the token as its value before you launch the analysis.
See SonarScanner CLI for more information.
[Archived] sample project
For comparison purposes, a sample SonarScanner for Ant project is available here: https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonar-scanner-ant/ant-basic
Was this page helpful?