gpt4 book ai didi

xml - Ant |试图覆盖任务 javac 错误的旧定义

转载 作者:数据小太阳 更新时间:2023-10-29 02:30:47 25 4
gpt4 key购买 nike

我正在尝试在 ANT 中构建一个 jar。下面是我生成 jar 文件的代码。我不知道为什么会发生此错误(“尝试覆盖任务 javac 的旧定义”)。有时它不会生成 jar。

<?xml version="1.0" ?> 
<project name="HelloWorld" default="compress">

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

<target name="init">
<mkdir dir="build/classes" />
<mkdir dir="dist" />
</target>

<target name="compile" depends="init">
<javac srcdir="src" destdir="build/classes"/>
</target>

<target name="compress" depends="compile">
<jar destfile="dist/sample.jar" basedir="build/classes" />

</target>

<target name="execute" depends="compile">
<java classname="src" classpath="build/classes" />
</target>

<target name="clean">

</target>

</project>

输出如下:

Buildfile: E:\GAD project\project\GAD\build.xml
Trying to override old definition of task javac
init:
[mkdir] Created dir: E:\GAD project\project\GAD\dist
compile:
compress:
[jar] Building jar: E:\GAD project\project\GAD\dist\sample.jar
BUILD SUCCESSFUL
Total time: 1 second

让我知道如何纠正错误消息。?

最佳答案

让我们试试这个

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


<target name="compile" depends="init">
<my.javac srcdir="src" destdir="build/classes"/>
</target>

关于xml - Ant |试图覆盖任务 javac 错误的旧定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18485604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com