蚂蚁目标中的编译顺序

Order of compilation in ant target

下面的 ant compile 目标编译使用 <src path="..."/> 标记指定的任何 src 文件夹中的所有 .java 文件。我的问题是关于编译的顺序。 ant 是否首先编译第一个 src 标记引用的文件(即是否首先编译 ${xtext.project.path}/src 中的 Java 文件),然后是第二个 src 标记, ETC。?文件的编译顺序是什么?我试图找出文件夹之间的依赖关系,想知道它们列出的顺序是否告诉了我任何信息。

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

您可以看到 <javac> 如何通过带有 -verbose 选项的 运行 Ant 编译文件。

例如下面的Ant脚本...

<javac debug="true" includeantruntime="false">
    <src path="src1"/>
    <src path="src2"/>
</javac>

...在 Windows 机器上使用 ant -verbose 运行 输出以下内容...

[javac] Compilation arguments:
[javac] '-classpath'
[javac] ''
[javac] '-sourcepath'
[javac] '.....\src1;.....\src2'
[javac] '-g'

在上面的示例中,Ant 将 <src> 元素合并到以分号分隔的 -sourcepath 参数中。

-sourcepathOracle's javac tool的一个选项:

-sourcepath sourcepath

Specifies the source code path to search for class or interface definitions. As with the user class path, source path entries are separated by colons (:) on Oracle Solaris and semicolons on Windows and can be directories, JAR archives, or ZIP archives.

注意 Ant 的 <javac> 任务和 Oracle 的 javac 工具之间的区别。 Ant <javac> 任务调用 Oracle javac 工具。

对于你的问题"What order are the files compiled in?",答案基本上是:Java个文件都是同时编译的。