Java 1.6 的 Apt 任务?

发布于 2024-10-09 18:26:43 字数 692 浏览 8 评论 0原文

我有一些自动生成的 Ant 构建脚本,需要使用它们来构建应用程序。我正在使用 Ant 1.8.1 和 Java 1.6。这些脚本使用 Apt Ant 任务,根据任务参考,该任务几乎是在 Java 1.6 中已过时,因为它可以在编译器中处理注释。然而,Apt 目标生成了我的应用程序需要的额外类,并且我无法找到使用 javac 复制它的方法。

问题是,当执行脚本时,Apt 任务失败,抱怨它需要 1.5+ 的 JDK,即使我安装了 1.6 JDK。我尝试用 标签替换 标签,复制尽可能多的属性,但是这样做构建会失败查找应由 任务生成的类。
我还尝试安装 1.5 JDK 并针对它运行 Ant 脚本,虽然 Apt 任务运行良好,但 javac 任务抱怨类文件错误,因为它们是在 1.6 中编译的,但针对 1.5 运行。所以我在 1.5 中完全重建了源代码,但编译器仍然抱怨一个错误的类文件,尽管我注意到在发生这种情况之前它在构建过程中确实取得了明显的进展。

我束手无策,只是想知道是否有任何方法可以让 Apt 任务与 Java 1.6 很好地配合,或者是否有任何其他方法可以与 Apt 完成相同的工作,并处理我可能错过的不同任务?

I have some automatically generated Ant build scripts that I need to use to build an application. I am using Ant 1.8.1 and Java 1.6. The scripts use the Apt Ant task, which according to the task reference is pretty much obsolete in Java 1.6 because it can process annotations in the compiler. However, the Apt targets generate extra classes that my application needs and I haven't been able to find a way to replicate this using javac.

The problem is, when the scripts are executed, the Apt task fails complaining that it needs a JDK of 1.5+ even though I have a 1.6 JDK installed. I have tried replacing the <apt> tags with <javac> tags, copying across as many of the attributes as I can, but doing that the build falls over when looking for classes that should have been generated by the <apt> task.
I have also tried installing a 1.5 JDK and running the Ant script against that, and while the Apt task works happily, the javac tasks complain about bad class files because they were compiled in 1.6 but running against 1.5. So I completely rebuilt the source in 1.5, but still the compiler complains about a bad class file, though I noticed that it did get measurably farther in the build process before this happened.

I am at my wits end and am just wondering if there is any way of getting the Apt task to play nice with Java 1.6, or indeed any other means of doing the same work as Apt with different tasks that I might have missed?

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

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

发布评论

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

评论(1

蓝眼睛不忧郁 2024-10-16 18:26:43

找到了解决方案 - 它比我想象的要简单。

为了修复脚本,我只需切换到旧版本的 Ant。 Weblogic 附带 Ant 1.6.5,在将我的 ANT_HOME 指向此版本而不是 Apache 1.8.1 后,脚本运行时没有任何抱怨。

Found the solution - and it was simpler than I would have thought.

To fix the scripts, I just had to switch to an older version of Ant. Weblogic ships with Ant 1.6.5, and after pointing my ANT_HOME to this version rather than the Apache 1.8.1 the scripts ran without any complaints.

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