classpath和Ant构建

时间:2017-03-20 20:37:37

标签: java ant

下面的ant编译目标编译使用<src path="..."/>标记指定的任何src文件夹中的所有.java文件。您可以看到使用classpath标记向<classpath refid=...>添加了许多项目。

<target name="compile">
        <echo message="${ant.project.name}: ${ant.file}"/>

        <deps-load-path conf="core"   pathid="core.ivy.classpath" />
        <deps-load-path conf="test"   pathid="test.ivy.classpath" />

        <javac debug="true" includeantruntime="false" debuglevel="source,lines,vars" destdir="${bin.path}" source="1.8" target="1.8">
            <src path="${xtext.project.path}/src"/>
          <src path="${xtext.project.path}/src-gen"/>
          <src path="${project.path}/src"/>
          <src path="${project.path}/src-gen-umpletl"/>
          <src path="${project.path}/src-gen-umple"/>
          <src path="${project.path}/test"/>
          <src path="${vendors.path}/jopt-simple/src"/>
          <exclude name="**/.git"/>
          <exclude name="**/*.ump" />
          <exclude name="**/data" />
          <classpath refid="project.classpath"/>
          <classpath refid="validator.project.classpath"/>
          <classpath refid="core.ivy.classpath" />
          <classpath refid="test.ivy.classpath" />
            <!-- Add compiler arguments here, see https://ant.apache.org/manual/using.html#arg for details, example below
                  <compilerarg value="-Xlint:deprecation" />
            -->
        </javac>

        <copy todir="${bin.path}" overwrite="true">
            <fileset dir="${project.path}/src"><include name="**/*.grammar"/></fileset>
            <fileset dir="${project.path}/src"><include name="**/*.error"/></fileset>
        </copy>
        <delete file="cruise.umple/src/rules.grammar"/>
        <delete file="cruise.umple/bin/rules.grammar"/>
</target>

其中一项是project.classpath,它在文件的其他位置定义为与${bin.path}相同的位置,这是编译文件的写入位置(请参阅<copy todir...>标记)。 ${bin.path}如何既是类路径依赖项又是.class文件写入的位置?我知道在每次构建之前${bin.path}被删除的事实,因此在编译目标运行之前文件夹中没有任何内容。生成为编译目标的.class文件是否会动态地添加到类路径中?

0 个答案:

没有答案