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

发布于 2024-07-27 21:26:35 字数 886 浏览 3 评论 0原文

我有一个简单的 maven2 java 项目(JMS 中继系统)。 在我们发布第一个版本后,我们发现我们花在配置maven上的时间比实际编码的时间还要多。

对于下一个版本,我们希望清理构建过程,有人建议迁移到构建器。 所以我的任务就是这样做。

我根据他们网站上的文档设置了 buildr (1.3.4)。 然后从项目的根目录输入 buildr 命令,然后通知 buildr 根据我的 pom.xml 创建构建文件。 处理得很好并编译了所有代码。 一切都很顺利,直到构建者开始运行测试。 这是输出:

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

显然指定的类不在我的类路径中。 然而,构建者文档表示,基本测试所需的所有必需项目都已包含在内。 他们的文档没有说他们需要任何特定的 ant 库或 ant 版本。 虽然我确实安装了 ant 1.7.0(但未包含在我的类路径中)。

有没有人见过这个?


更新

我在 Maven 存储库中找到了臭名昭著的 ant-可选 jar。 在我的 test.with 选项中包括这一点并没有解决问题。

使用 --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'

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'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最初的梦 2024-08-03 21:26:35

发现问题...显然需要一个 ant-junit.jar,但无论出于何种原因,在我的本地存储库中,它由 root 用户拥有,而不是我的本地用户帐户(OSX 系统)。 所以构建者无法访问它。 我从本地存储库中删除了这些项目并重新运行构建器(它下载了所需的项目)。


更新

这还导致了一些其他问题。 我的本地存储库中的其他一些项目似乎具有奇怪的权限。 我最终只是归档我的存储库并让 Maven 重建它。 这解决了我所有的问题。 我现在有一个不错的构建文件,它有 25 行代码,而之前的 pom.xml 文件有 100 多行代码。

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.

迷鸟归林 2024-08-03 21:26:35

您收到该错误是因为 JUnitTask 不在类路径上。 我对 Buildr 不太熟悉,所以不能说是否需要指定 JUnit jar,但如果 Buildr 使用系统类路径,请尝试向其中添加 JUnit 并看看会发生什么。

一旦您确认您的构建将在 JUnit 侵入类路径的情况下运行,您就可以尝试改变您的配置,直到它按您的预期运行,或者保持原样。

您可以发布文档相关部分的参考吗? 我没有看到任何内容(在我对该网站的简短阅读中)表明包含必需的项目。

难道你还没有下载所有的宝石吗? 如果运行“gem update --system”来更新 Ruby,然后运行“gem update buildr”可以确保所需的依赖项已全部安装。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文