我是新来的蚂蚁。我有以下项目结构,
Project
module1
build.xml
module2
build.xml
lib
发生的情况是,我在模块 2 中配置了 build.xml 以构建模块 2 类的 JAR 并将其放在 lib 文件夹中。现在,我从 module1 的 build.xml 调用 module2 的 build.xml。module1 需要 module2 的 JAR 才能编译。我可以在 lib 文件夹中看到 JAR,但模块 1 仍然没有编译。有人可以帮帮我吗?这是我的 build.xml 文件,module1 build.xml,
<?xml version="1.0" encoding="UTF-8"?>
<property name="app.name" value="module1" />
<property name="src.home" value="${basedir}/src/main/java" />
<property name="build.home" value="${basedir}/build" />
<property name="ear.home" value="${basedir}/ear" />
<property name="module2.home" value="../module2" />
<property name="external.lib.dir" value="../lib" />
<path id="lib.path">
<fileset dir="${external.lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<path id="module2.path">
<filelist dir="${module2.home}" />
</path>
<target name="clean">
<delete dir="${build.home}" />
<delete dir="${ear.home}" />
</target>
<target name="prepare" depends ="clean"
description="Create build dirs and copy static files to work dir">
<mkdir dir="${build.home}" />
<mkdir dir="${build.home}/classes" />
</target>
<target name="compile" depends="prepare"
description="Compile Java sources and copy to build/classes dir">
<javac includeantruntime="false" srcdir="${src.home}" destdir="${build.home}/classes">
<classpath refid="lib.path" />
</javac>
<copy todir="${build.home}/classes">
<fileset dir="${src.home}" excludes="**/*.java" />
</copy>
</target>
<target name="includeJar">
<subant target="buildJar">
<fileset dir="../module2/" includes="build.xml" />
</subant>
</target>
<target name="buildEar" depends="includeJar,compile">
<jar destfile="${basedir}/ear/${app.name}.ear" basedir="${build.home}" />
</target>
这是module2 build.xml,
<?xml version="1.0" encoding="UTF-8"?>
<project name="module2">
<property name="app.name" value="module2"/>
<property name="src.home" value="${basedir}/src/main/java"/>
<property name="build.home" value="${basedir}/build"/>
<echo>
module2 build.xml
</echo>
<target name="clean">
<delete dir="${build.home}"/>
</target>
<target name="init" depends="clean"
description="Create build dirs and copy static files to work dir">
<mkdir dir="${build.home}"/>
<mkdir dir="${build.home}/classes"/>
</target>
<target name="compile" depends="init"
description="Compile Java sources and copy to build/classes dir">
<javac includeantruntime="false" srcdir="${src.home}"
destdir="${build.home}/classes">
</javac>
<copy todir="${build.home}/classes">
<fileset dir="${src.home}" excludes="**/*.java"/>
</copy>
</target>
<target name="buildJar" depends="compile">
<echo>Inside buildJar of module2
</echo>
<jar destfile="../lib/${app.name}.jar"
basedir="${build.home}"
/>
</target>