简体   繁体   English

从maven2迁移到buildr时,为什么我的测试无法运行?

[英]Why do my tests fail to run when migrating from maven2 to buildr?

I have a straightforward maven2 java project (JMS relaying system). 我有一个简单的maven2 java项目(JMS中继系统)。 After we released the first version, we found that we spent more time configuring maven than actually coding. 发布第一个版本后,我们发现配置maven花费的时间比实际编码花费的时间更多。

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. 我根据其网站上的文档设置了buildr(1.3.4)。 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. 然后从项目的根目录中键入buildr命令,然后通知buildr根据我的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. 他们的文档并没有说他们需要任何特定的ant库或ant版本。 Although I do have ant 1.7.0 installed (not included in my classpath however). 虽然我确实安装了ant 1.7.0(但是未包含在我的类路径中)。

Has anyone seen this before? 谁看过这个吗?


Update 更新

I located the infamous ant-optional jar on the maven repository. 我在Maven存储库中找到了臭名昭著的ant-optional jar。 Including that in my test.with options did not resolve the issue. 包括在我的test.with选项中不能解决问题。

Running the buildr command with --trace gives this extra information... 使用--trace运行buildr命令可提供此额外信息...

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'

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). 找到了问题...显然需要一个ant-junit.jar,但是由于我的本地存储库中的任何原因,它是root而非我的本地用户帐户(OSX系统)所拥有。 So it wasn't accessible to buildr. 因此构建器无法访问它。 I deleted the items from my local repository and reran buildr (it downloaded the needed items). 我从本地存储库中删除了项目,然后重新运行了buildr(它下载了所需的项目)。


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. 我最终只是存档我的存储库,然后让Maven对其进行重构。 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. 现在,我有一个不错的构建文件,它的代码行数为25行,而我以前的pom.xml文件则超过了100行。

You get that error because JUnitTask isn't on the classpath. 您会收到该错误,因为JUnitTask不在类路径中。 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. 我对Buildr不太熟悉,所以不能说是否需要指定JUnit jar,但是如果Buildr使用系统类路径,请尝试向其添加JUnit并查看会发生什么。

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. 确认您的构建将在JUnit侵入类路径的情况下运行后,您可以尝试更改配置,直到其按预期运行,或者保持不变。

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? 您是否可能没有下载所有的gem? If you run "gem update --system" to update Ruby, then "gem update buildr" you can ensure that the required dependencies have all been installed. 如果您运行“ gem update --system”来更新Ruby,则可以使用“ gem update buildr”来确保已安装所有必需的依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM