Installation of jacoco ant tasks on CentOS

294 views
Skip to first unread message

Martin Schmude

unread,
Aug 2, 2018, 11:51:34 AM8/2/18
to JaCoCo and EclEmma Users
Hello,

on a CentOS 7 system I want to use jacoco in an ant script.
In the <taskdef> element I want to avoid the nested <classpath> element.
It should not look like

  1. <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
  2. <classpath path="/some/path/jacocoant.jar"/>
  3. </taskdef>
 
but simply
  1. <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml" />
Following the ant documentation this could be achieved by storing the jacocoant.jar in the lib subfolder of $ANT_HOME. On my system this results in/usr/share/ant/lib.

I did the same successfully with other ant addons, e.g. ant-junit. But with jacoco it doesn't work.

The output of the ant script when evaluating the taskdef is:
Buildfile: /tmp/build.xml
 
[taskdef] Could not load definitions from resource org/jacoco/ant/antlib.xml. It could not be found.

When executing ant -diagnostics I find this section in the output:
------------------------------------------- ANT_HOME/lib jar listing -------------------------------------------
ant
.home: /usr/share/ant ant-bootstrap.jar (20919 bytes)
ant
-launcher.jar (19065 bytes)
ant
.jar (1999722 bytes)
ant
-commons-net.jar (91879 bytes)
ant
-antlr.jar (12272 bytes)
ant
-jsch.jar (47207 bytes)
ant
-contrib-1.0b3.jar (196539 bytes)
ant
-junit.jar (113254 bytes)
ant
-junit4.jar (13782 bytes)
junit
.jar (290000 bytes)
hamcrest
-all.jar (122201 bytes)
jacocoant
.jar (31856 bytes)

So ant finds the jacocoant.jar.

Any help welcome! Thanks in advance.

Martin Schmude

unread,
Aug 3, 2018, 1:59:10 AM8/3/18
to JaCoCo and EclEmma Users
I forgot to mention:

The ant version
Apache Ant(TM) version 1.9.2 compiled on June 10 2014

The Java version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)

The jacoco version is  0.8.1.

Also note: when I put the classpath element into the taskdef, the problem is gone.
So as a workaround I could use the builtin ant.home property like this:
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
    <classpath path="${ant.home}/lib/jacocoant.jar"/>
</taskdef>






Evgeny Mandrikov

unread,
Aug 3, 2018, 8:19:52 AM8/3/18
to JaCoCo and EclEmma Users
Hi Martin,

Your "jacocoant.jar" is too small.

"jacocoant.jar" of version 0.8.1 has following size and checksums:

$ ls -g jacoco-0.8.1/lib/jacocoant.jar
-rw-r--r-- 1 wheel 663345 Mar 21 10:39 jacoco-0.8.1/lib/jacocoant.jar

$ sha256sum jacoco-0.8.1/lib/jacocoant.jar
eb375296cb836c202f35b711fee2a41bbeb447b80e54dd1fd05ef6c1d75774e3  jacoco-0.8.1/lib/jacocoant.jar

$ md5sum jacoco-0.8.1/lib/jacocoant.jar
1496c185c62fdea6068096e33bca64fd  jacoco-0.8.1/lib/jacocoant.jar

Martin Schmude

unread,
Aug 3, 2018, 9:26:22 AM8/3/18
to JaCoCo and EclEmma Users
Hello Evgeny,

you are right. I accidentally posted the wrong output of ant -diagnostics - I'm sorry. Here is the correct one:
ant.home: /usr/share/ant
ant
-bootstrap.jar (20919 bytes)
ant
-launcher.jar (19065 bytes)
ant
.jar (1999722 bytes)
ant
-commons-net.jar (91879 bytes)
ant
-antlr.jar (12272 bytes)
ant
-jsch.jar (47207 bytes)
ant
-contrib-1.0b3.jar (196539 bytes)
ant
-junit.jar (113254 bytes)
ant
-junit4.jar (13782 bytes)

sonar
-ant-task-2.1.jar (1842861 bytes)
sonar
-ant-task-2.2.jar (1825821 bytes)

junit
.jar (290000 bytes)
hamcrest
-all.jar (122201 bytes)

catalina
-ant.jar (54802 bytes)
tomcat
-coyote.jar (775617 bytes)
tomcat
-juli.jar (38160 bytes)
tomcat
-util.jar (23078 bytes)
jacocoant
.jar (663345 bytes)

Which conforms to the file size of the jacocoant.jar, that you posted.

Martin Schmude

unread,
Aug 3, 2018, 9:32:43 AM8/3/18
to JaCoCo and EclEmma Users
I just looked at the checksums, and they are also the ones that you posted.
Nevertheless the problem remains.

Evgeny Mandrikov

unread,
Aug 3, 2018, 9:56:06 AM8/3/18
to JaCoCo and EclEmma Users
Can't reproduce using Ant distributions from https://ant.apache.org/bindownload.cgi :

$ java -version
java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

$ cat <<END > build.xml
<project xmlns:jacoco="antlib:org.jacoco.ant">
  <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"/>
  <jacoco:agent property="agentvmparam"/>
  <echo message="\${agentvmparam}"/>
</project>
END


$ sha1sum apache-ant-1.9.2-bin.zip
97b809ae3227d0bec2c250db8f39b9be04d40c3d  apache-ant-1.9.2-bin.zip

$ unzip -q apache-ant-1.9.2-bin.zip

$ ./apache-ant-1.9.2/bin/ant -version
Apache Ant(TM) version 1.9.2 compiled on July 8 2013
$ sha1sum jacoco-0.8.1.zip
2c338443634b58285292af530bf5facc15c614c4  jacoco-0.8.1.zip

$ mkdir jacoco-0.8.1 && unzip -q jacoco-0.8.1.zip -d jacoco-0.8.1

$ cp jacoco-0.8.1/lib/jacocoant.jar apache-ant-1.9.2/lib/

$ ./apache-ant-1.9.2/bin/ant -f build.xml
Buildfile: /private/tmp/jacoco/build.xml
     [echo] -javaagent:/var/folders/3j/gspvyr593lz9379x3gxxdvmm0000gp/T/jacocoagent4881485027556735034.jar=destfile=/private/tmp/jacoco/jacoco.exec

BUILD SUCCESSFUL
Total time: 0 seconds


$ sha1sum apache-ant-1.10.5-bin.zip
1c2fce313b2ee6edfba7d56f2ecaca36e8985d6f  apache-ant-1.10.5-bin.zip

$ unzip -q apache-ant-1.10.5-bin.zip

$ ./apache-ant-1.10.5/bin/ant -version
Apache Ant(TM) version 1.10.5 compiled on July 10 2018

$ cp jacoco-0.8.1/lib/jacocoant.jar apache-ant-1.10.5/lib

$ ./apache-ant-1.10.5/bin/ant -f build.xml
Buildfile: /private/tmp/jacoco/build.xml
     [echo] -javaagent:/var/folders/3j/gspvyr593lz9379x3gxxdvmm0000gp/T/jacocoagent6012838593961832628.jar=destfile=/private/tmp/jacoco/jacoco.exec

BUILD SUCCESSFUL
Total time: 0 seconds

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages