蚂蚁警告:““includeantruntime”未设置”

发布于 2024-10-19 04:02:22 字数 195 浏览 4 评论 0原文

我收到以下警告:

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

这是什么意思?

I receive the following warning:

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

What does this mean?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

枯寂 2024-10-26 04:02:22

Ant Runtime

只需设置 includeantruntime="false"

<javac includeantruntime="false" ...>...</javac>

如果您必须多次使用 javac 任务,您可能需要考虑使用 PreSetDef 定义您自己的 javac -task,该任务始终设置 <代码>includeantruntime="false"。

其他详细信息

来自 http://www.coderanch.com/ 的 t/503097/tools/warning-includeantruntime-was-not-set

这是由错误功能引起的
Ant 1.8 中引入。只需添加一个
该名称的属性到 javac
任务,将其设置为 false,然后忘记它
曾经发生过。

来自 http://ant.apache.org/manual/Tasks/javac.html

是否包含Ant运行时
类路径中的库;默认值
是,除非 build.sysclasspath 是
放。通常最好将其设置为
false 所以脚本的行为不是
对所处环境敏感
它已运行。

Ant Runtime

Simply set includeantruntime="false":

<javac includeantruntime="false" ...>...</javac>

If you have to use the javac-task multiple times you might want to consider using PreSetDef to define your own javac-task that always sets includeantruntime="false".

Additional Details

From http://www.coderanch.com/t/503097/tools/warning-includeantruntime-was-not-set:

That's caused by a misfeature
introduced in Ant 1.8. Just add an
attribute of that name to the javac
task, set it to false, and forget it
ever happened.

From http://ant.apache.org/manual/Tasks/javac.html:

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.

闻呓 2024-10-26 04:02:22

正如 @Daniel Kutik 提到的, presetdef 是一个很好的选择选项。特别是如果您正在处理一个包含许多 build.xml 文件的项目,而这些文件无法或不愿意编辑(例如,来自第三方的文件)。

要使用 presetdef,将这些行添加到您的顶级 build.xml 文件中:

  <presetdef name="javac">
    <javac includeantruntime="false" />
  </presetdef>

现在,所有后续 javac 任务本质上都会继承 includeantruntime="false"。如果您的项目确实需要 ant 运行时库,您可以将它们显式添加到构建文件中或设置 includeantruntime="true"。后者也将消除警告。

如果需要,后续的 javac 任务仍然可以显式更改此设置,例如:

<javac destdir="out" includeantruntime="true">
  <src path="foo.java" />
  <src path="bar.java" />
</javac>

我建议不要使用 ANT_OPTS。它有效,但它违背了警告的目的。该警告告诉人们,一个人的构建可能在另一个系统上表现不同。使用 ANT_OPTS 使这种情况变得更有可能,因为现在每个系统都需要以相同的方式使用 ANT_OPTS。此外,ANT_OPTS 将全局应用,在您的所有项目中随意抑制警告

As @Daniel Kutik mentioned, presetdef is a good option. Especially if one is working on a project with many build.xml files which one cannot, or prefers not to, edit (e.g., those from third-parties.)

To use presetdef, add these lines in your top-level build.xml file:

  <presetdef name="javac">
    <javac includeantruntime="false" />
  </presetdef>

Now all subsequent javac tasks will essentially inherit includeantruntime="false". If your projects do actually need ant runtime libraries, you can either add them explicitly to your build files OR set includeantruntime="true". The latter will also get rid of warnings.

Subsequent javac tasks can still explicitly change this if desired, for example:

<javac destdir="out" includeantruntime="true">
  <src path="foo.java" />
  <src path="bar.java" />
</javac>

I'd recommend against using ANT_OPTS. It works, but it defeats the purpose of the warning. The warning tells one that one's build might behave differently on another system. Using ANT_OPTS makes this even more likely because now every system needs to use ANT_OPTS in the same way. Also, ANT_OPTS will apply globally, suppressing warnings willy-nilly in all your projects

月下客 2024-10-26 04:02:22

Chet Hosey 写了一个很好的解释< a href="http://ant.1045680.n5.nabble.com/warning-includeantruntime-was-not-set-tp2639463p2639765.html" rel="noreferrer">此处:

从历史上看,Ant 始终将其自己的运行时包含在可供 javac 任务使用的类路径中。因此,无论您是否喜欢,Ant 中包含的任何库以及 ant 可用的任何库都会自动位于您构建的类路径中。

我们认为这可能不是大多数人想要的。所以现在有一个选择。

如果您选择“true”(对于 includeantruntime),那么至少您知道您的构建类路径将包含 Ant 运行时。如果您选择“false”,那么您就接受了构建行为在旧版本和 1.8+ 之间会发生变化的事实。

尽管您看到此警告会很恼火,但如果您的构建完全崩溃,您会更不高兴。保持此默认行为允许未修改的构建文件在 Ant 版本之间一致地工作。

Chet Hosey wrote a nice explanation here:

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.

耀眼的星火 2024-10-26 04:02:22

丹尼尔的回答非常完美。以下是我添加到 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>

The answer from Daniel works just perfect. Here is a sample snippet that I added to my 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>
最丧也最甜 2024-10-26 04:02:22

如果您像我一样从命令行工作,那么快速的答案是执行

export ANT_OPTS=-Dbuild.sysclasspath=ignore

然后再次运行您的 ant 脚本。

If you like me work from commandline the quick answer is executing

export ANT_OPTS=-Dbuild.sysclasspath=ignore

And then run your ant script again.

一向肩并 2024-10-26 04:02:22

在 build.xml 文件中使用

有关更多详细信息,请在 Ant javac

可以找到其他可能的值 此处

Use <property name="build.sysclasspath" value="last"/> in your build.xml file

For more details search includeAntRuntime in Ant javac

Other possible values could be found here

極樂鬼 2024-10-26 04:02:22

我也遇到了同样的问题,我检查了程序和功能。安装了 jdk1.8 的更新,它与 eclipse 中 ant 的旧设置(jdk1.6.0)不兼容。
我安装该更新。
现在,我的ant项目正在构建成功。

尝试一下,希望这会有所帮助。

i faced this same, i check in in program and feature. there was an update has install for jdk1.8 which is not compatible with my old setting(jdk1.6.0) for ant in eclipse.
I install that update.
right now, my ant project is build success.

Try it, hope this will be helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文