簡體   English   中英

在 Eclipse 中構建 ANT 后未創建 .jar

[英].jar not being created after ANT build in Eclipse

出於某種原因,當我 ANT 運行我的 build.xml 文件時,Eclipse 沒有創建 .jar 文件。

請考慮我的代碼:

<!-- language: lang-xml -->

<project default="deploy">

    <!-- user.home is C:\Documents and Settings\<user name> or C:\Users\<user 
        name> (Windows) or /Users/<user name> (Mac OSX) -->
    <property name="ext.dir"
        value="${user.home}/MotiveWave Extensions" />
    <property name="dev.dir" value="${ext.dir}/dev" />
    <property name="jar.dir" value="${ext.dir}/jar" />
    <property name="src.dir" value="../src/" />
    <property name="bin.dir" value="../bin/" />
    <property name="lib.dir" value="../lib/" />

    <!-- Name of the jar file (created in the 'jar' target) -->
    <property name="jar.name" value="example15" />

    <!-- removes all files generated by the build process -->
    <target name="clean">
        <!-- <delete dir="classes"/> <delete dir="jar"/> -->
    </target>


    <!-- Compiles the source putting the generated class files in the 'classes' 
        subdirectory. -->
    <target name="compile" depends="clean">
        <mkdir dir="classes" />
        <javac includeantruntime="false" srcdir="${src.dir}"
            destdir="classes" debug="true" debuglevel="lines,source">
            <classpath refid="classpath" />
        </javac>
    </target>

    <!-- Creates a jar file (for distribution). -->
    <target name="jar" depends="compile">
        <!-- <delete dir="jar"/> -->
        <jar destfile="${ext.dir}/jar/${jar.name}.jar"
            manifest="Manifest.MF" level="9">
            <fileset dir="classes" includes="**/*.class" />
            <fileset dir="${src.dir}" includes="**/*.properties" />
            <!-- Uncomment the following line to include the source in the jar file. -->
            <fileset dir="${src.dir}" includes="**/*.java" />
        </jar>
    </target>

    <!-- Creates and deploys the jar file to the extensions directory. This 
        is the default task. -->
    <target name="deploy_jar" depends="jar">
        <!-- We will place this jar file in a 'lib' directory. -->
        <mkdir dir="${ext.dir}/jar" />
        <copy file="jar/${jar.name}.jar" todir="${ext.dir}/jar"
            overwrite="true" />
        <!-- This tells MotiveWave to check for any modified files and load them. -->
        <touch file="${ext.dir}/.last_updated" />
    </target>

    <!-- This alternative deployment task, copies all class and properties files 
        to the extensions directory (instead of creating the jar file). -->
    <target name="deploy" depends="compile">
        <!-- Copy all .class and .properties files. These files are placed in a 
            subdirectory called 'dev' in the extensions directory. This directory is 
            first deleted in case you have moved or renamed any of the files. -->
        <delete dir="${dev.dir}" />
        <mkdir dir="${dev.dir}" />
        <mkdir dir="${jar.dir}" />
        <!-- <copy todir="${dev.dir}" overwrite="true"> <fileset dir="classes" 
            includes="**/*.class"/> <fileset dir="${src.dir}" includes="**/*.properties"/> 
            </copy> -->
        <!-- This tells MotiveWave to check for any modified files and load them. -->
        <touch file="${ext.dir}/.last_updated" />
    </target>

    <!-- This class path includes all of the jars in the lib directory. -->
    <path id="classpath">
        <fileset dir="${lib.dir}" includes="**/*.jar" />
        <pathelement path="classes" />
    </path>
</project>

/build/classes/study_examples 目錄中的文件顯示得很好(所以我相信 'clean' 和 'compile'-parts 工作正常)目錄 /jar 正在按預期在 Users/MotiveWave/Extensions 中創建。

但是我找不到具有我定義的名稱的單個 .jar 文件(“示例 15”)(因此“目標名稱”“jar”在某種程度上是錯誤的)

誰能解釋一下為什么會這樣?

你可以更換

<jar destfile="${ext.dir}/jar/${jar.name}.jar" manifest="Manifest.MF" level="9">

<jar destfile="${jar.dir}/${jar.name}.jar" manifest="Manifest.MF" level="9">

但是,它不會解決您的問題。 為了解決這個問題,更換

<target name="deploy" depends="compile">

<target name="deploy" depends="deploy_jar">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM