Issue with Sonar Scanner for Ant

2,061 views
Skip to first unread message

Bindu

unread,
Aug 6, 2017, 5:34:52 PM8/6/17
to SonarQube
Hi,

I followed the steps for running the SonarQube scanner for Ant as explained in this document (https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Ant )
Now when i try to run the build, i get the below error-

sonar:
  [taskdef] Could not load definitions from resource org/sonar/ant/antlib.xml. It could not be found.
adding /usr/share/ant/lib/sonarqube-ant-task-*.jar which contains wildcards and may not do what you intend it to do depending on your OS or version of Java
  [taskdef] Could not load definitions from resource org/sonar/ant/antlib.xml. It could not be found.
[antlib:org.sonar.ant] Could not load definitions from resource org/sonar/ant/antlib.xml. It could not be found.

BUILD FAILED
/tmp/sonar-scanning-examples-master/sonarqube-scanner-ant/build.xml:48: Problem: failed to create task or type antlib:org.sonar.ant:sonar
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet

This appears to be an antlib declaration.
Action: Check that the implementing library exists in one of:
        -/usr/share/ant/lib
        -/root/.ant/lib
        -a directory added on the command line with the -lib argument

        at org.apache.tools.ant.UnknownElement.getNotFoundException(UnknownElement.java:499)
        at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:431)
        at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163)
        at org.apache.tools.ant.Task.perform(Task.java:347)
        at org.apache.tools.ant.Target.execute(Target.java:435)
        at org.apache.tools.ant.Target.performTasks(Target.java:456)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
        at org.apache.tools.ant.Main.runBuild(Main.java:851)
        at org.apache.tools.ant.Main.startAnt(Main.java:235)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 0 seconds


Below is the build.xml entry for sonar-scanner 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="/usr/share/ant/lib/sonarqube-ant-task-*.jar" />
                        </taskdef>
                <!-- Execute SonarQube Scanner for Ant Analysis -->
                <sonar:sonar />
        </target>


Please can you suggest what steps i could do to fix this problem, Thank you.

Julien HENRY

unread,
Aug 7, 2017, 3:22:31 AM8/7/17
to SonarQube
Hi,

Can you please try to replace the "*" by the real value in:
<classpath path="/usr/share/ant/lib/sonarqube-ant-task-*.jar" />

++

Julien

Bindu Boinapalli

unread,
Aug 7, 2017, 9:56:48 AM8/7/17
to Julien HENRY, SonarQube
Thanks Henry, Issue got fixed with above change and was able to analyze project to SonarQube.



Thank you.

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/lZodPivGNxs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/d3a0b8df-5c25-4449-8ce3-dd8cf57512d8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages