2011-11-16 18 views
1

javacを使用して.classファイルにJavaファイルのセットをコンパイルし、次にiajcを使用してすべてのアスペクトをコンパイルして織り込んでみようとしています。私のant build.xmlはこのように見えます。.ajファイルを既存のjavacコンパイル済みソースに組み込む

コンパイル一部:

<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> 

、私はこれが正しい得ていないのです。 sourcerootsは間違っています! どうすればaspectjで.ajファイルだけをコンパイルし、クラスファイルとコンパイル済み.ajファイルをバイナリで編成できますか?元のJavaソースもすべて再コンパイルする必要はありませんか?

答えて

1

あなたはこれを行うファイルを.aj構築するために.javaファイルとiajcを構築するための定期的なコンパイラを使用する場合:

<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> 

が.ajファイルのリストを含むファイルを構築することで完璧に動作し、それらをコンパイルする。ランタイムORバイナリ織りを使用してプロセスを終了することができます。

+0

あなたは私に助けてくれますか?この質問はhttp://stackoverflow.com/questions/38930247/when-run-ant-script-aspectj-not-import-aspect-source-folder-out-side-java-class – uma

関連する問題