SonarScanner for Ant
The SonarScanner for Ant provides a task
to allow the integration of SonarQube analysis into an Apache Ant build script.
The SonarScanner for Ant is an Ant Task that is a wrapper of SonarScanner, which works by invoking SonarScanner and passing to it all properties named following a sonar.*
convention. This has the downside of not being very Ant-y, but the upside of providing instant availability of any new analysis parameter introduced by a new version of SonarQube. Therefore, successful use of the SonarScanner for Ant requires strict adherence to the property names shown below.
Using the SonarScanner for Ant
Define a new sonar Ant target in your Ant build script:
Run the following command from the project base directory to launch the analysis. You need to pass an authentication token using the sonar.token
property. For example, to set it through the command line:
Alternatively, you can create the SONAR_TOKEN
environment variable and set the token as its value before you launch the analysis.
Sample project
To help you get started, a simple project sample is available here: https://github.com/SonarSource/sonar-scanning-examples/tree/master/sonarqube-scanner-ant
Troubleshooting
Enable debug logs
To enable debug logs, use the regular Ant verbose option: -v
© 2008-2023, SonarSource S.A, Switzerland. Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution-NonCommercial 3.0 United States License. SONARQUBE is a trademark of SonarSource SA. All other trademarks and copyrights are the property of their respective owners.