我收到以下警告:

[javac] build.xml:9: warning: 'includeantruntime' was not set, 
defaulting to build.sysclasspath=last; set to false for repeatable builds

这是什么意思?


当前回答

丹尼尔的回答非常完美。下面是我添加到build.xml中的一个示例代码片段:

<target name="compile">
    <mkdir dir="${classes.dir}"/>
    <javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false">
                                                 <!--   ^^^^^^^^^^^^^^^^^^^^^^^^^  -->
        <classpath>
            <path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
            <path id="junit" location="${lib.dir}/junit-4.9b2.jar"/>
        </classpath>
    </javac>
</target>

其他回答

丹尼尔的回答非常完美。下面是我添加到build.xml中的一个示例代码片段:

<target name="compile">
    <mkdir dir="${classes.dir}"/>
    <javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false">
                                                 <!--   ^^^^^^^^^^^^^^^^^^^^^^^^^  -->
        <classpath>
            <path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
            <path id="junit" location="${lib.dir}/junit-4.9b2.jar"/>
        </classpath>
    </javac>
</target>

如果你喜欢我从命令行工作,快速的答案是执行

export ANT_OPTS=-Dbuild.sysclasspath=ignore

然后再次运行ant脚本。

我面对同样的情况,我在程序和功能中进行了检查。有一个更新已经安装了jdk1.8,这是不兼容我的旧设置(jdk1.6.0) ant在eclipse中。 我安装了更新。 现在,我的蚂蚁项目是构建成功。

试试吧,希望这对你有所帮助。

使用<property name="build. "在build.xml文件中Sysclasspath " value="last"/>

欲了解更多细节,请在Ant javac中搜索includeAntRuntime

在这里可以找到其他可能的值

Chet Hosey在这里写了一个很好的解释:

Historically, Ant always included its own runtime in the classpath made available to the javac task. So any libraries included with Ant, and any libraries available to ant, are automatically in your build's classpath whether you like it or not. It was decided that this probably wasn't what most people wanted. So now there's an option for it. If you choose "true" (for includeantruntime), then at least you know that your build classpath will include the Ant runtime. If you choose "false" then you are accepting the fact that the build behavior will change between older versions and 1.8+. As annoyed as you are to see this warning, you'd be even less happy if your builds broke entirely. Keeping this default behavior allows unmodified build files to work consistently between versions of Ant.