views:

183

answers:

2

I have a straightforward maven2 java project (JMS relaying system). After we released the first version, we found that we spent more time configuring maven than actually coding.

For the next release we wanted to clean up the build process and someone suggested migrating to builder. So I was tasked with doing just that.

I setup buildr (1.3.4) according to the documentation on their website. And then from the root of the project I typed the buildr command and then informed buildr to create the build file based upon my pom.xml. That processed fine and compiled all the code. All was gravy until buildr started running the tests. Here is the ouput:

Test framework error: taskdef class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found

Obviously the class specified isn't in my classpath. However, the buildr documentation says that all the required items needed for basic testing are included. Their documentation doesn't say that they need any specific libraries for ant or a version of ant. Although I do have ant 1.7.0 installed (not included in my classpath however).

Has anyone seen this before?


Update

I located the infamous ant-optional jar on the maven repository. Including that in my test.with options did not resolve the issue.

Running the buildr command with --trace gives this extra information...

Tests failed!
/pathtoruby/buildr-1.3.4/lib/buildr/core/test.rb:455:in `run_tests'
/pathtoruby/buildr-1.3.4/lib/buildr/core/test.rb:199:in `initialize'
+1  A: 

You get that error because JUnitTask isn't on the classpath. I'm not very familiar with Buildr so can't say if it is required for you to specify the JUnit jars or not, but if Buildr uses the system classpath, try adding JUnit to it and see what happens.

Once you've confirmed your builds will run with JUnit hacked in to the classpath, you can then try varying your configuration until it runs as you expected, or leave it as is.

Can you post the reference to the relevant part of the documentation? I didn't see anything (in my very brief reading of the site) that says required items are included.

Is it possible that you've not downloaded all the gems? If you run "gem update --system" to update Ruby, then "gem update buildr" you can ensure that the required dependencies have all been installed.

Rich Seller
"The test.compile task will run the compile task first, then use the same dependencies to compile the test classes. That much you already assumed. It also adds the test framework (e.g. JUnit, TestNG) and JMock to the dependency list. Less work for you.If you need more dependencies, the best way to add them is by calling test.with. This method adds dependencies to both compile.dependencies (for compiling) and test.dependencies (for running). You can manage these two dependency lists separately, but using test.with is good enough in more cases." found http://buildr.apache.org/testing.html
predhme
thanks for the reference.
Rich Seller
I have verified that ruby is up-to-date and have uninstalled and reinstalled buildr several times.
predhme
It also seems that org.apache.tools.ant.taskdefs.optional.junit.JUnitTask isn't available on the maven repository. This isn't a junit library but more of an ant wrapper for junit tasks.
predhme
I'm not sure what your point is, Maven doesn't need to use any ant wrapper for JUnit, so it missing from the repository doesn't impact Maven's execution.
Rich Seller
Maven doesn't, but buildr needed it when it was calling its test task class.
predhme
Yes Buildr needs it, from my original answer "You get that error because JUnitTask isn't on the classpath". However I don't see the relevance of your point that JUnitTask isn't available on the Maven repository. As Maven doesn't need it what is the problem there?
Rich Seller
The problem is that buildr needed access to the jar file which due to permission errors it couldn't but when a dependency check was done the required jar file was already in the local repository. My original comment about it not being on the repository is slightly incorrect as it is, but under a different group id.
predhme
+2  A: 

Found the issue... Apparently there is an ant-junit.jar that is needed but for whatever reason in my local repository it was owned by root and not my local user account (OSX system). So it wasn't accessible to buildr. I deleted the items from my local repository and reran buildr (it downloaded the needed items).


Update

Also this caused a few other issues. It seems that a few other items in my local repository had strange permissions. I ended up just archiving my repository and letting maven reconstruct it. This resolved all my issues. I now have a nice build file that is 25 lines of code compared to my previous pom.xml file that was over 100 lines.

predhme