SonarCloud | Advanced setup | CI-based analysis | SonarScanner for Ant

Was this page helpful?

On this page

Start FreeLog in

SonarScanner for Ant

The SonarScanner for Ant provides a task that is a wrapper of SonarScanner to allow integration of SonarCloud analysis into an Apache Ant build script. It is now deprecated and will be removed in the future. We recommend adjusting your configuration to use the SonarScanner CLI directly.

Moving from SonarScanner for Ant to SonarScanner CLI

If you’re still using the SonarScanner for Ant, follow these steps to remove the wrapper, create a, and run the analysis. 


The SonarScanner CLI is installed on your machine. See Installation for more details.

Configuring your sonar properties

  1. Create a in your project.
  2. Move the sonar.* properties from your build.xml  file to the file. For example:""
sonar.projectName="Example of SonarScanner for Ant Usage"

See SonarScanner for more information on how to configure project properties.

Running the analysis

1. Set the environment variable SONAR_TOKEN with the personal access token generated on My account > Security > Generate Tokens. Note that the token can also be set through the command line argument -Dsonar.token.

2. Run the command sonar-scanner , or sonar-scanner.bat  on Windows, from the project base directory to run the analysis.

[Archived] sample project

For comparison purposes, a sample SonarScanner for Ant project is available here.

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARLINT, SONARQUBE, SONARCLOUD, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License