问题
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.
来源:https://stackoverflow.com/questions/7035604/iajc-fails-to-weave-aspects-from-a-jar-but-succeedes-from-class-files