iajc 无法从 jar 中编织方面,但从类文件中编织成功

发布于 2024-11-29 02:50:03 字数 1126 浏览 4 评论 0原文

因此,我为我的项目定义了 iajc 任务,该任务可以很好地执行类型间声明,然后有一个单独的 jar 任务来创建 project.jar。

然后是 junit 测试目标的 iajc 任务,该任务引用project.jar,其目标是将其 ITD 编织到测试类中,如下所示:

<aspectpath>
<pathelement path="${dist}/project.jar"/>
<fileset dir="${lib.aspect}">
    <include name="**/*.jar" />
    <include name="**/*.zip" />
</fileset>
</aspectpath>

这不起作用 - 编译器会产生类似 class 的错误“com....Foo”必须实现接口 Bar 中定义的方法 doThings()

然后我将 更改为:

<aspectpath>
<pathelement location="${build.dir}"/>
<fileset dir="${lib.aspect}">
    <include name="**/*.jar" />
    <include name="**/*.zip" />
</fileset>
</aspectpath>

这基本上是使用生成的中间类文件由编译器执行,效果很好。

然后我发现,如果我在 iajc 任务中使用 outjar 选项而不是 destdir ,那么该 jar 就可以在 中使用。方面路径>

那么一个问题和评论:

问:是否有一些参数可以使其与常规 任务一起使用?

C. 我必须使用 outjar 的事实根本没有记录 - 提到了输出 jar 的选项,但没有任何地方说这是生成可以工作的 jar 的唯一方法。

So I defined iajc task for my project that does intertype declarations just fine, then there is a separate jar task that creates a project.jar.

Then there is iajc task for junit test target, this task references the project.jar with the goal of weaving its ITDs into test classes like so:

<aspectpath>
<pathelement path="${dist}/project.jar"/>
<fileset dir="${lib.aspect}">
    <include name="**/*.jar" />
    <include name="**/*.zip" />
</fileset>
</aspectpath>

That does not work - compiler produces errors like class "com....Foo" has to implement method doThings() defined in interface Bar

Then I change the <aspectpath> to this:

<aspectpath>
<pathelement location="${build.dir}"/>
<fileset dir="${lib.aspect}">
    <include name="**/*.jar" />
    <include name="**/*.zip" />
</fileset>
</aspectpath>

which is basically using the intermediate class files generated by the compiler and it works great.

Then I find that if I use the outjar option instead of destdir in my iajc task then that jar can be used in <aspectpath>.

So a question and a comment then:

Q. is there some parameter that would make it work with the regular <jar> task?

C. the fact that I have to use outjar is not documented at all - the option to output a jar is mentioned but nowhere does it say that that is the only way to produce a jar that will work.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文