-
which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
SonarQube - Version 8.5.1 (build 38104) -
what are you trying to achieve
Push src .java files to SonarQube for anaylsis -
what have you tried so far to achieve this
-
I am following this DOC - SonarScanner for Ant | SonarQube Docs
-
On this website at the bottom there is the following git link : sonar-scanning-examples/sonarqube-scanner-ant at master · SonarSource/sonar-scanning-examples · GitHub
-
I have pulled the above code to my local.
-
Build.xml content :
<!-- Define the SonarQube global properties (the most usual way is to pass these properties via the command line) -->
<property name="sonar.host.url" value="http://localhost:9000/" />
<!-- Define the Sonar properties -->
<property name="sonar.projectKey" value="test3" />
<property name="sonar.projectName" value="Example of SonarQube Scanner for Ant Usage" />
<property name="sonar.projectVersion" value="1.0" />
<property name="sonar.sources" value="src" />
<property name="sonar.binaries" value="target" />
<property name="sonar.sourceEncoding" value="UTF-8" />
<!-- ========= Define "regular" targets: clean, compile, ... ========= -->
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="init">
<mkdir dir="${build.dir}" />
<mkdir dir="${classes.dir}" />
</target>
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${classes.dir}" fork="true" debug="true" includeAntRuntime="false" />
</target>
<!-- ========= Define SonarQube Scanner for Ant Target ========= -->
<target name="sonar" depends="compile">
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<!-- Update the following line, or put the "sonar-ant-task-*.jar" file in your "$HOME/.ant/lib" folder -->
<classpath path="C:\utils\apache-ant-1.10.1\lib\*.jar" />
</taskdef>
<!-- Execute SonarQube Scanner for Ant Analysis -->
<sonar:sonar />
</target>
<!-- ========= The main target "all" ========= -->
<target name="all" depends="clean,compile,sonar" />
This build runs as expected and sonaqube is populated with the one .java source file located in the src folder but when I add more .java files to the source folder get this error :
org.sonar.java.AnalysisException: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.
For some reason my src folder cannot contain more than one .java file if so then it fails with the above error.
If you do not understand what I’m explaining above I’m willing to setup a zoom call and show you what I’m experiencing. I have been struggling with this for time.