Binary 将.aj文件编织到现有的javac编译源代码中

Binary 将.aj文件编织到现有的javac编译源代码中,binary,aspectj,javac,Binary,Aspectj,Javac,我试图使用javac将一组java文件编译成.class文件,然后使用iajc编译和编织所有方面。我的ant build.xml如下所示 编译部分: <target name="compile" depends="init" description="compile the source "> <!-- Compile the java code from ${src} into ${target} --> <javac srcdir="${src}

我试图使用javac将一组java文件编译成.class文件,然后使用iajc编译和编织所有方面。我的ant build.xml如下所示

编译部分:

<target name="compile" depends="init" description="compile the source ">
    <!-- Compile the java code from ${src} into ${target} -->
    <javac srcdir="${src}" destdir="${target}" debug="true">
        <classpath refid="project.class.path" />
    </javac>
</target>

iajc部分:

<target name="aspects">
    <mkdir dir="dist"/>     
    <iajc source="1.6" target="${asptarget}">
        <inpath>
            <pathelement location="${target}"/>
        </inpath>
        <sourceroots>
            <fileset dir="${src}">
                <include name="**/*.aj"/>
            </fileset>
        </sourceroots>
         <classpath>
              <pathelement location="${aspectj.home}/lib/aspectjrt.jar"/>
        </classpath>
    </iajc>
</target>

从错误信息判断,我没有得到正确的答案。源根是错误的!
如何使用aspectj编译.aj文件,然后对类文件和编译的.aj文件进行二进制编织?在不重新编译所有原始java源代码的情况下也可以这样做吗?

如果要使用常规编译器构建.java文件和iajc构建.aj文件,请执行以下操作:

<target name="aspects" depends="compile" description="build binary aspects">
    <fileset id="ajFileSet" dir="${src}" includes="**/*.aj"/>
    <pathconvert pathsep="${line.separator}" property="ajFiles" refid="ajFileSet"/>
    <echo file="${src}/aj-files.txt">${ajFiles}</echo>

    <iajc source="1.6" target="${asptarget}">
        <argfiles>
            <pathelement location="${src}/aj-files.txt"/>
        </argfiles>

        <classpath>             
            <pathelement path="${target}"/>
            <fileset dir="lib" includes="**/*.jar"/>
        </classpath>
         <classpath>
              <pathelement location="${aspectj.home}/lib/aspectjrt.jar"/>
        </classpath>
    </iajc>
</target>

${ajFiles}

通过构建一个包含.aj文件列表的文件并编译它们,可以完美地工作。然后,您可以使用运行时或二进制编织来完成此过程。

如果您想使用常规编译器来构建.java文件,并使用iajc来构建.aj文件,请执行以下操作:

<target name="aspects" depends="compile" description="build binary aspects">
    <fileset id="ajFileSet" dir="${src}" includes="**/*.aj"/>
    <pathconvert pathsep="${line.separator}" property="ajFiles" refid="ajFileSet"/>
    <echo file="${src}/aj-files.txt">${ajFiles}</echo>

    <iajc source="1.6" target="${asptarget}">
        <argfiles>
            <pathelement location="${src}/aj-files.txt"/>
        </argfiles>

        <classpath>             
            <pathelement path="${target}"/>
            <fileset dir="lib" includes="**/*.jar"/>
        </classpath>
         <classpath>
              <pathelement location="${aspectj.home}/lib/aspectjrt.jar"/>
        </classpath>
    </iajc>
</target>

${ajFiles}

通过构建一个包含.aj文件列表的文件并编译它们,可以完美地工作。然后,您可以使用运行时或二进制编织来完成该过程。

您能帮我吗,这个问题您能帮我吗,这个问题