FS#15229 - [apache-ant] upgrade breaks unit-test compile steps in my build.xml files

Attached to Project: Arch Linux
Opened by David Rosenstrauch (darose) - Tuesday, 23 June 2009, 15:06 GMT
Last edited by Paul Mattal (paul) - Thursday, 02 July 2009, 11:43 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Paul Mattal (paul)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:

The upgrade to 1.7.1-2 is causing the compile steps for the test cases in my project to fail.

In v1.7.1-1, ant was implicitly including junit.jar in the classpath of javac steps. In 1.7.1-2, it's not.

1.7.1-1:
/usr/lib/ant-launcher.jar
/usr/lib/ant.jar
/usr/lib/ant-swing.jar
/usr/lib/junit.jar
/usr/lib/xml-apis.jar
/usr/lib/ant-trax.jar
/usr/lib/ant-jmf.jar
/usr/lib/xercesImpl.jar
/usr/lib/ant-testutil.jar
/usr/lib/ant-junit.jar
/usr/lib/ant-nodeps.jar
/opt/java/lib/tools.jar

1.7.1-2:
/usr/share/java/apache-ant/lib/ant-launcher.jar
/usr/share/java/apache-ant/lib/ant-antlr.jar
/usr/share/java/apache-ant/lib/ant-apache-bcel.jar
/usr/share/java/apache-ant/lib/ant-apache-bsf.jar
/usr/share/java/apache-ant/lib/ant-apache-log4j.jar
/usr/share/java/apache-ant/lib/ant-apache-oro.jar
/usr/share/java/apache-ant/lib/ant-apache-regexp.jar
/usr/share/java/apache-ant/lib/ant-apache-resolver.jar
/usr/share/java/apache-ant/lib/ant-commons-logging.jar
/usr/share/java/apache-ant/lib/ant-commons-net.jar
/usr/share/java/apache-ant/lib/ant-jai.jar
/usr/share/java/apache-ant/lib/ant-javamail.jar
/usr/share/java/apache-ant/lib/ant-jdepend.jar
/usr/share/java/apache-ant/lib/ant-jmf.jar
/usr/share/java/apache-ant/lib/ant-jsch.jar
/usr/share/java/apache-ant/lib/ant-junit.jar
/usr/share/java/apache-ant/lib/ant-netrexx.jar
/usr/share/java/apache-ant/lib/ant-nodeps.jar
/usr/share/java/apache-ant/lib/ant-starteam.jar
/usr/share/java/apache-ant/lib/ant-stylebook.jar
/usr/share/java/apache-ant/lib/ant-swing.jar
/usr/share/java/apache-ant/lib/ant-testutil.jar
/usr/share/java/apache-ant/lib/ant-trax.jar
/usr/share/java/apache-ant/lib/ant-weblogic.jar
/usr/share/java/apache-ant/lib/ant.jar
/usr/share/java/apache-ant/lib/xercesImpl.jar
/usr/share/java/apache-ant/lib/xml-apis.jar
/opt/java/lib/tools.jar


As a result of the junit jar not being found, the build steps for my test cases are failing:

1.7.1-1:
Buildfile: build.xml

init:

build:
[mkdir] Created dir: /mnt/shared/dave/work/code/eventpublish/classes
[javac] Compiling 236 source files to /mnt/shared/dave/work/code/eventpublish/classes
[copy] Copying 1 file to /mnt/shared/dave/work/code/eventpublish/classes

build-tests-unit:
[mkdir] Created dir: /mnt/shared/dave/work/code/eventpublish/test_classes/unit
[javac] Compiling 51 source files to /mnt/shared/dave/work/code/eventpublish/test_classes/unit

test-unit:
[junit] Testsuite: <my test suite>
[junit] Tests run: 9, Failures: 0, Errors: 0, Time elapsed: 0.03 sec
...

1.7.1-2:
Buildfile: build.xml

init:

build:
[mkdir] Created dir: /mnt/shared/dave/work/code/eventpublish/classes
[javac] Compiling 236 source files to /mnt/shared/dave/work/code/eventpublish/classes
[copy] Copying 1 file to /mnt/shared/dave/work/code/eventpublish/classes

build-tests-unit:
[mkdir] Created dir: /mnt/shared/dave/work/code/eventpublish/test_classes/unit
[javac] Compiling 51 source files to /mnt/shared/dave/work/code/eventpublish/test_classes/unit
[javac] /mnt/shared/dave/work/code/eventpublish/test_src/unit/<my test class>.java:3: package junit.framework does not exist
[javac] import junit.framework.Assert;
...


Additional info:
* package version(s)

1.7.1-2

* config and/or log files etc.


Steps to reproduce:
This task depends upon

Closed by  Paul Mattal (paul)
Thursday, 02 July 2009, 11:43 GMT
Reason for closing:  Implemented
Additional comments about closing:  in apache-ant 1.7.1-3
Comment by Paul Mattal (paul) - Thursday, 25 June 2009, 03:51 GMT
Is there some freely available project out there that uses the junit ant task that I can use to experiment with this? I just tried a few searches to find one but have come up empty so far. Once I can replicate this, I can figure out how to fix it.
Comment by David Rosenstrauch (darose) - Thursday, 25 June 2009, 14:18 GMT
I'm attaching a project you can use for test. It builds fine with apache-ant 1.7.1-1, and fails to build with 1.7.1-2.

(Note, btw: the problem is with the build step (javac), not the junit step. Junit.jar used to get automatically placed on the classpath, and now it doesn't, which is why the project now fails to build.)
Comment by Paul Mattal (paul) - Saturday, 27 June 2009, 15:30 GMT
I'm trying to decide if this is really a bug.

Can you add the new junit.jar to your build path when building?
Comment by Paul Mattal (paul) - Sunday, 28 June 2009, 20:55 GMT
Looks to me like you should install the junit package from [extra] and add to your javac target in the build.xml the attribute classpath="/usr/share/java/junit.jar".

This seems like the right behavior, in spite of the fact it wasn't the old behavior. It's not good to have junit on the javac path all the time-- what if someone specifically didn't want it on the path or wanted to use a different version of junit?

Does this make sense?
Comment by David Rosenstrauch (darose) - Monday, 29 June 2009, 15:17 GMT
Makes some sense.

But I'm still wondering: what's the right behavior here? Should junit automatically be on the classpath? What do other distros do and/or do Sun/Apache/etc. have a standard here?

I'll ask on a good Java developers mailing list I'm on and report back.
Comment by David Rosenstrauch (darose) - Wednesday, 01 July 2009, 14:26 GMT
No response from my Java devs list, but I did some research myself.

On Centos (/RHEL) the way it seems to work is that there's separate packages: ant, junit, and ant-junit. And if you have junit and ant-junit installed, then the junit.jar gets automatically added to the classpath whenever you run ant; else not.

Perhaps we can do something similar in Arch?
Comment by David Rosenstrauch (darose) - Thursday, 02 July 2009, 04:22 GMT
Just checked Ubuntu (9), and it supports similar behavior (though packaged differently): if junit is installed then junit.jar automatically winds up on the classpath for ant javac steps. So I'd think we should support this behavior as well. Agree?
Comment by David Rosenstrauch (darose) - Thursday, 02 July 2009, 06:13 GMT
Two potential fixes:

1) Have the apache-ant package create a symlink in /usr/share/java/apache-ant/lib to ../../junit.jar. If junit is installed, then this will link to the junit jar file, and so junit classes will be found in javac steps. If junit is not installed, it'll be a symlink to nowhere, and junit classes won't be found.

2) Exclude /usr/share/java/apache-ant/lib/ant-junit.jar from the apache-ant build. Create a separate package (e.g., apache-ant-junit) dependent upon both ant and junit that provides the ant-junit.jar, as well as the symlink to the junit.jar described above.
Comment by Paul Mattal (paul) - Thursday, 02 July 2009, 11:43 GMT
I've implemented solution #1 in apache-ant 1.7.1-3 on both arches, and added a corresponding optdepend.

Verified it resolves your test case.

Loading...