java - Eclipse 运行 ANT 两次,甚至只发送运行一次

标签 java eclipse ant jar

在 Netbeans 中,经过一些研究,我设法编辑文件 build.xml 以自定义 IDE 生成我的 jar 和 list 文件的方式。我不得不为 Eclipse 迁移一个项目,甚至找到了构建 jar 的选项,但我需要使用一些个性化信息构建我的 jar。

我在 eclipse 的项目中将文件 build.xml 作为构建文件 ANT 添加,但是当我发送执行它时,eclipse 运行两次,一次生成 2 个 jars 文件。

按照我的文件build.xml:

<?xml version="1.0" encoding="UTF-8"?>

<project name="GerOficios" default="makejar" basedir='.'>

    <target name="makejar">

        <property file="version_info.properties" />

        <property name="application.title" value="GerOficios_v6" />

        <property name="main.class" value="com/dfmachado/geroficios/View/ListaDeOficiosUI" />

        <buildnumber file="build.num" />

        <property name="build.version.num" value="${version.number}.${build.number}" />

        <tstamp>
            <format property="TODAY" pattern="dd/MM/yyyy - HH:mm:ss" />
        </tstamp>

        <property name="store.jar.name" value="GerOficios ${build.version.num}" />

        <property name="store.dir" value="store" />
        <property name="store.jar" value="${store.dir}/${store.jar.name}.jar" />

        <echo message="Packaging ${application.title} into a single JAR at ${store.jar}" />

        <mkdir dir="${store.dir}" />

        <jar destfile="${store.dir}/temp_final.jar" basedir="bin" filesetmanifest="skip">
            <zipgroupfileset dir="lib" includes="*.jar" />

            <manifest>
                <attribute name="Main-Class" value="${main.class}" />
                <attribute name="SplashScreen-Image" value="com/dfmachado/geroficios/View/image/minerva.png" />

                <attribute name="Build-OS" value="${os.name} version ${os.version} on ${os.arch}" />
                <attribute name="Java-Version" value="${javac.source}" />
                <attribute name="Implementation-Title" value="${application.title}" />
                <attribute name="Implementation-Version" value="${build.version.num}" />
                <attribute name="Built-By" value="${user.name}" />
                <attribute name="Built-Date" value="${TODAY}" />
            </manifest>
        </jar>

        <zip destfile="${store.jar}">
            <zipfileset src="${store.dir}/temp_final.jar" excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA" />
        </zip>
        <delete file="${store.dir}/temp_final.jar" />

    </target>

</project>

只是指出,eclipse 生成一个 jar 的方式与它在 netbeans 中生成的方式相同,问题是 ANT 运行两次并生成 2 个 jar,即使我只给出一次命令,如下面的打印所示:

enter image description here

在同一项目中通过命令行运行 ant,但只创建了一个文件,显然问题出在 eclipse 中的某些配置,但到目前为止我还没有找到。

最佳答案

ANT 是您在项目构建器中添加的构建器。请在这里查看:

Project -> Right Click -> Properties -> Builders

您可以将它与 Eclipse 的工作区设置为“自动构建”一起启用 - 这将触发自动构建。

或者,您可以从构建器列表中取消选择构建器并在需要时手动运行它!

This SO Q+A is worth a quick (further) read

关于java - Eclipse 运行 ANT 两次,甚至只发送运行一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40633385/

相关文章:

java - joptionpane 确认对话框无法识别 no 选项

java - 为什么我会从 Apache Derby 收到这些错误?

java - 如何在 Eclipse 中正确更新类

html - XSLT 作为从 ant 运行的多个文件上的简单 HTML 模板引擎

java - Android线程获取参数

java - 为什么 UserGroupInformation 类的 setConfiguration(Configuration conf) 方法是静态的?

Java Reflection - 将形式参数列表与实际参数列表匹配

java - Eclipse (Java) 中的文件路径

java - 如何使用 Ant 删除目录集?

java - 使用 ant 构建后,线程主 java.lang.noclassdeffounderror 中出现异常