Error in Build File while using Sonar Plugin for Ant

sonarqube

(Diana) #1

-Version: Sonarqube7.3 win 64 and sonar ant plugin - sonarqube-ant-task-2.5.jar
-Am trying to use the sonar plug for ant and sonar server to generate the project dashboard
-My project has a SDK which we are trying to customize. We are using Ant to build the code. I have added the jar in my “software” folder of my SDK where all other external jar are added.

  • I have updated my build.xml with the sonar properties as suggested in the tutorial. However when I build the project am getting a errror in the below line.

Sharing the entire code of build.xml.
Kindly suggest if am going in the right direction.

<!-- ========= Define the main properties of this project ========= -->
	<property name="src.dir" value="src" />
	<property name="build.dir" value="target" />
	<property name="classes.dir" value="${build.dir}/classes" />
	
	<!-- 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="org.sonarqube:sonarqube-scanner-ant" />
	<property name="sonar.projectName" value="Example of SonarQube Scanner for Ant Usage" />
	<property name="sonar.projectVersion" value="1.0" />
	<property name="sonar.language" value="java" />
	<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="path/to/sonar/ant/task/lib/sonarqube-ant-task-*.jar" />
		</taskdef>
		
		<!-- Execute SonarQube Scanner for Ant Analysis -->
		<sonar:sonar />
	</target>

	<!-- ========= The main target "all" ========= -->
	<target name="all" depends="clean,compile,sonar" />

<property name="project.name" value="deploy-customisation" />
    <property name="workspace.folder" value="${basedir}/.." />
    <property name="project.folder" value="${basedir}" />
    <property file="${project.folder}/project.properties" />
    <property name="software.folder" value="${bundle.folder}/software" />
    <property name="software.customisation.folder" value="${software.folder}/components/modules/customisation" />
    <property name="customisation.project.file" value="customisation.xml"/>
    <property name="database.scripts.folder" value="${bundle.folder}/database-scripts"/>

    <target name="generate">
        <ant antfile="${software.folder}/lib/customisation/build-project.xml" target="compile" inheritall="false">
            <property name="customisation.project.folder" value="${basedir}"/>
            <property name="customisation.project.file" value="${customisation.project.file}"/>
            <property name="software.customisation.folder" value="${software.customisation.folder}"/>
        </ant>
    </target>

    <target name="package">
        <ant antfile="${software.folder}/lib/customisation/build-project.xml" target="package" inheritall="false">
            <property name="customisation.project.folder" value="${basedir}"/>
            <property name="customisation.project.file" value="${customisation.project.file}"/>
            <property name="software.customisation.folder" value="${software.customisation.folder}"/>
        </ant>
    </target>

    <target name="deploy">
        <ant antfile="${software.folder}/lib/customisation/build-project.xml" inheritall="false">
            <property name="customisation.project.folder" value="${basedir}"/>
            <property name="customisation.project.file" value="${customisation.project.file}"/>
            <property name="software.customisation.folder" value="${software.customisation.folder}"/>
            <property name="database.scripts.folder" value="${database.scripts.folder}"/>
        </ant>
    </target>

    <target name="undeploy">
        <ant antfile="${software.folder}/lib/customisation/build-project.xml" target="undeploy" inheritall="false">
            <property name="customisation.project.folder" value="${basedir}"/>
            <property name="customisation.project.file" value="${customisation.project.file}"/>
            <property name="software.customisation.folder" value="${software.customisation.folder}"/>
        </ant>
    </target>