# Ant with sonarqube

**URL:** <https://community.sonarsource.com/t/ant-with-sonarqube/34969>\
**Category:** SonarQube Server / Community Build\
**Tags:** java\
**Created:** [November 25, 2020, 9:51am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969 "2020-11-25T09:51:56Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![madhumohan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@madhumohan](https://community.sonarsource.com/u/madhumohan)\
**Post date:** [November 25, 2020, 9:51am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/1 "2020-11-25T09:51:56Z")

</div>

Hi,

- How to scan ant projects with sonar
- I got error while running ant sonar commond
- error : Fail to download libraries from server
- Please do the needful

---

<div class="post-metadata">

**Author:** ![Daniel\_Meppiel](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/daniel_meppiel/32/13047_2.png) [@Daniel\_Meppiel](https://community.sonarsource.com/u/Daniel_Meppiel)\
**Post date:** [November 25, 2020, 9:58am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/2 "2020-11-25T09:58:51Z")

</div>

Hi Madhumohan,

Please share the must-have information when posting any question in the community, otherwise there is little way anyone can help you:

> Must-share information (formatted with [Markdown](https://commonmark.org/help/)):
> 
> - which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
> - what are you trying to achieve
> - what have you tried so far to achieve this

When you say:

> [@madhumohan](#):
>
> Please do the needful

Please keep in mind this is a community of SonarQube users who voluntarily help each other, and therefore, there is no obligation for anyone to do anything.

Best regards,  
Daniel

---

<div class="post-metadata">

**Author:** ![madhumohan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@madhumohan](https://community.sonarsource.com/u/madhumohan)\
**Post date:** [November 25, 2020, 10:37am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/3 "2020-11-25T10:37:47Z")

</div>

Hi Daniel,

I got report on sonar server with code of build.xml file

```
<property name="ANT_CLASSPATH" value="lib" />
<property name="sonar.host.url" value="http://localhost:9000" />
<property name="sonar.login" value="abcd" />
<property name="sonar.password" value="abcd" />
<property name="sonar.projectKey" value="sonarbuild" />
<property name="sonar.projectName" value="sonarbuild" />
<property name="sonar.projectVersion" value="1.0" />
<property name="sonar.language" value="java" />
<property name="sonar.sources" value="." />
<property name="sonar.java.binaries" value="dist" />

	<property name="sonar.sourceEncoding" value="ISO-8859-1" />

<!-- - - - - - - - - - - - - - - - - - 
      target: name                      
     - - - - - - - - - - - - - - - - - -->
<target name="sonar">
	<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
        	<classpath path="sonar-ant-task-2.3.jar" />
        </taskdef>
	    <sonar:sonar />
</target>

```

But, I’m getting error when i mention the remote server instead of localhost  
Please find the error details  
build.xml:26: java.lang.IllegalStateException: Fail to download libraries from server

---

<div class="post-metadata">

**Author:** ![madhumohan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@madhumohan](https://community.sonarsource.com/u/madhumohan)\
**Post date:** [November 25, 2020, 10:39am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/4 "2020-11-25T10:39:03Z")

</div>

Sonarqube : Version 8.4.2

---

<div class="post-metadata">

**Author:** ![Daniel\_Meppiel](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/daniel_meppiel/32/13047_2.png) [@Daniel\_Meppiel](https://community.sonarsource.com/u/Daniel_Meppiel)\
**Post date:** [November 25, 2020, 11:10am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/5 "2020-11-25T11:10:07Z")

</div>

Madhumohan, I will need the full log of the analysis in debug mode in order to be able to help.

Best regards,  
Daniel

---

<div class="post-metadata">

**Author:** ![madhumohan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@madhumohan](https://community.sonarsource.com/u/madhumohan)\
**Post date:** [November 27, 2020, 9:57am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/6 "2020-11-27T09:57:42Z")

</div>

Hi Daniel,  
Please find the logs

D:\Dev\Portal\liferay-plugins-sdk-6.1.1\portlets\BeamPromotionalNDownloads-portlet\build.xml:28: java.lang.IllegalStateException: Fail to download libraries from server  
at org.sonar.runner.impl.Jars.dowloadFiles(Jars.java:78)  
at org.sonar.runner.impl.Jars.download(Jars.java:57)  
at org.sonar.runner.impl.JarDownloader.download(JarDownloader.java:46)  
at org.sonar.runner.impl.JarDownloader.checkVersionAndDownload(JarDownloader.java:37)  
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:71)  
at java.security.AccessController.doPrivileged(Native Method)  
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)  
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)  
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)  
at org.sonar.runner.api.Runner.execute(Runner.java:100)  
at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:51)  
at org.sonar.ant.SonarTask.execute(SonarTask.java:46)  
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)  
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:498)  
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)  
at org.apache.tools.ant.Task.perform(Task.java:352)  
at org.apache.tools.ant.Target.execute(Target.java:437)  
at org.apache.tools.ant.Target.performTasks(Target.java:458)  
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1406)  
at org.apache.tools.ant.Project.executeTarget(Project.java:1377)  
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)  
at org.apache.tools.ant.Project.executeTargets(Project.java:1261)  
at org.apache.tools.ant.Main.runBuild(Main.java:857)  
at org.apache.tools.ant.Main.startAnt(Main.java:236)  
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)  
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)  
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1  
at org.sonar.runner.impl.Jars.dowloadFiles(Jars.java:72)  
… 27 more

Total time: 1 second

---

<div class="post-metadata">

**Author:** ![Daniel\_Meppiel](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/daniel_meppiel/32/13047_2.png) [@Daniel\_Meppiel](https://community.sonarsource.com/u/Daniel_Meppiel)\
**Post date:** [November 27, 2020, 10:28am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/8 "2020-11-27T10:28:41Z")

</div>

Hi Madhumohan,

> [@madhumohan](#):
>
> Please find the logs

These are unfortunately not the full logs: I would need the full logs from the line in which you launch the SonarScanner. Also, please can you tell what is the SonarScanner version you are using?

Thanks, regards,  
Daniel

---

<div class="post-metadata">

**Author:** ![madhumohan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@madhumohan](https://community.sonarsource.com/u/madhumohan)\
**Post date:** [November 27, 2020, 12:55pm UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/9 "2020-11-27T12:55:59Z")

</div>

Hi Daniel,

please find the logs and SonarScanner version : sonar-scanner-4.4.0.2170-linux

D:\Dev\Portal\liferay-plugins-sdk-6.1.1\portlets\BeamPromotionalNDownloads-portlet\>ant sonar  
Buildfile: D:\Dev\Portal\liferay-plugins-sdk-6.1.1\portlets\BeamPromotionalNDownloads-portlet\build.xml

sonar:  
[sonar:sonar] Apache Ant™ version 1.9.15 compiled on May 10 2020  
[sonar:sonar] SonarQube Ant Task version: 2.3  
[sonar:sonar] Loaded from: file:/D:/devopssw/apache-ant-1.9.15/lib/sonar-ant-task-2.3.jar  
[sonar:sonar] INFO: Default locale: “en\_GB”, source code encoding: “ISO-8859-1”  
[sonar:sonar] INFO: Work directory: D:\Dev\Portal\liferay-plugins-sdk-6.1.1\portlets\BeamPromotionalNDownloads-portlet.sonar  
[sonar:sonar] INFO: SonarQube Server 8.4.2.36762

BUILD FAILED  
D:\Dev\Portal\liferay-plugins-sdk-6.1.1\portlets\BeamPromotionalNDownloads-portlet\build.xml:28: java.lang.IllegalStateException: Fail to download libraries from server  
at org.sonar.runner.impl.Jars.dowloadFiles(Jars.java:78)  
at org.sonar.runner.impl.Jars.download(Jars.java:57)  
at org.sonar.runner.impl.JarDownloader.download(JarDownloader.java:46)  
at org.sonar.runner.impl.JarDownloader.checkVersionAndDownload(JarDownloader.java:37)  
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:71)  
at java.security.AccessController.doPrivileged(Native Method)  
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)  
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)  
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)  
at org.sonar.runner.api.Runner.execute(Runner.java:100)  
at org.sonar.ant.SonarTask.launchAnalysis(SonarTask.java:51)  
at org.sonar.ant.SonarTask.execute(SonarTask.java:46)  
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)  
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)  
at java.lang.reflect.Method.invoke(Method.java:498)  
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)  
at org.apache.tools.ant.Task.perform(Task.java:352)  
at org.apache.tools.ant.Target.execute(Target.java:437)  
at org.apache.tools.ant.Target.performTasks(Target.java:458)  
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1406)  
at org.apache.tools.ant.Project.executeTarget(Project.java:1377)  
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)  
at org.apache.tools.ant.Project.executeTargets(Project.java:1261)  
at org.apache.tools.ant.Main.runBuild(Main.java:857)  
at org.apache.tools.ant.Main.startAnt(Main.java:236)  
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)  
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)  
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1  
at org.sonar.runner.impl.Jars.dowloadFiles(Jars.java:72)  
… 27 more

Total time: 9 seconds

---

<div class="post-metadata">

**Author:** ![Daniel\_Meppiel](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/daniel_meppiel/32/13047_2.png) [@Daniel\_Meppiel](https://community.sonarsource.com/u/Daniel_Meppiel)\
**Post date:** [November 27, 2020, 1:43pm UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/10 "2020-11-27T13:43:40Z")

</div>

> [@madhumohan](#):
>
> SonarQube Ant Task version: 2.3

Hi Mahumohan,

Please note that you seem to be using SonarScanner for Ant and therefore, the “sonar-scanner-4.4.0.2170-linux” version that you shared with me is irrelevant.

The problem is potentially due to your SonarScanner for Ant version (2.3) which is really old. You will have to [upgrade to SonarScanner for Ant 2.7](https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-ant/) and try scanning again.

Cheers,  
Daniel

---

<div class="post-metadata">

**Author:** ![madhumohan](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@madhumohan](https://community.sonarsource.com/u/madhumohan)\
**Post date:** [December 1, 2020, 11:50am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/11 "2020-12-01T11:50:42Z")

</div>

HI Daniel,

Thanks for your support 👍  
It’s working now

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [December 8, 2020, 11:50am UTC](https://community.sonarsource.com/t/ant-with-sonarqube/34969/12 "2020-12-08T11:50:52Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
