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
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
|
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
Thursday, 02 July 2009, 11:43 GMT
Reason for closing: Implemented
Additional comments about closing: in apache-ant 1.7.1-3
(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.)
Can you add the new junit.jar to your build path when building?
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?
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.
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?
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.
Verified it resolves your test case.