我收到以下警告:
[javac] build.xml:9: warning: 'includeantruntime' was not set,
defaulting to build.sysclasspath=last; set to false for repeatable builds
这是什么意思?
我收到以下警告:
[javac] build.xml:9: warning: 'includeantruntime' was not set,
defaulting to build.sysclasspath=last; set to false for repeatable builds
这是什么意思?
当前回答
如果你喜欢我从命令行工作,快速的答案是执行
export ANT_OPTS=-Dbuild.sysclasspath=ignore
然后再次运行ant脚本。
其他回答
使用<property name="build. "在build.xml文件中Sysclasspath " value="last"/>
欲了解更多细节,请在Ant javac中搜索includeAntRuntime
在这里可以找到其他可能的值
Ant运行时
简单地设置includeantruntime="false":
<javac includeantruntime="false" ...>...</javac>
如果你必须多次使用javac-task,你可能会考虑使用PreSetDef来定义你自己的javac-task,它总是设置includeantruntime="false"。
额外的细节
从http://www.coderanch.com/t/503097/tools/warning-includeantruntime-was-not-set:
这是由特征错误引起的 在Ant 1.8中引入。只要加一个 将该名称的属性添加到javac Task,设置为false,然后忘记它 没有发生过。
从http://ant.apache.org/manual/Tasks/javac.html:
是否包含Ant运行时 类路径中的类库;违约 要是的,除非建造。sysclasspath是 集。通常最好将此设置为 False表示脚本的行为不是 对所处环境敏感 它在运行。
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.
丹尼尔的回答非常完美。下面是我添加到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>
我面对同样的情况,我在程序和功能中进行了检查。有一个更新已经安装了jdk1.8,这是不兼容我的旧设置(jdk1.6.0) ant在eclipse中。 我安装了更新。 现在,我的蚂蚁项目是构建成功。
试试吧,希望这对你有所帮助。