您的位置:首页 > 运维架构 > Apache

apache-ant编译中出现“includeantruntime was not set”警告的问题?

2017-12-06 11:18 597 查看
最近学习apache-ant运行的时候出现警告:



警告:
D:\>ant run

Buildfile: D:\build.xml

clean:

   [delete] Deleting directory D:\build

compile:

    [mkdir] Created dir: D:\build\classes

    [javac] D:\build.xml:126: warning: 'includeantruntime' was not set, defaulti

ng to build.sysclasspath=last; set to false for repeatable builds

    [javac] Compiling 1 source file to D:\build\classes

run:

     [java] study-apache-ant-Demo

BUILD SUCCESSFUL

Total time: 0 seconds

解决办法:
<project name="javaTest" default="run" basedir=".">
<target name="clean" description="清除目录">
<delete dir="build"/>
</target>

<target name="compile" depends="clean" description="编译">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes"
includeantruntime="on"/>
</target>

<target name="run" depends="compile" description="运行">
<java classname="Demo">
<classpath>
<pathelement path="build/classes"/>
</classpath>
</java>
</target>

</project>

也就是添加 includeantruntime="on" 。有的添加 includeAntRuntime="false",
有的添加includeantruntime="20000"

注:
1.对于includeAntRuntime属性,官方的解释如下:
    Whether to include the Ant run-time libraries in the classpath; defaults to yes, unless build.sysclasspath is set. It is usually best to set
this to false so the script's behavior is not sensitive to the environment in which it is run.
2.此警告在较早的ant版本中可能不会出现,当前用的版本是:Apache Ant(TM) version 1.8.2 compiled on December 20 2010。所以此问题跟ant版本有关。

我用的ant版本:Apache Ant(TM) version 1.9.9 compiled on February 2 2017
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  includeAntRuntime
相关文章推荐