[。jar在Eclipse中构建ANT后未创建

问题描述 投票:0回答:1

由于某些原因,当我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目录中的文件显示得很好(所以我相信“干净”和“编译”部分可以正常工作)正在按预期在Users / MotiveWave / Extensions中创建目录/ jar。

但是我找不到具有我定义的名称的单个.jar文件(“示例15”)(因此'目标名称'jar'某种程度上有问题)

有人能阐明为什么会这样吗?

java eclipse build ant
1个回答
0
投票

您可以替换

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

with

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

但是,它不能解决您的问题。为了解决问题,请替换

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

with

<target name="deploy" depends="deploy_jar">
© www.soinside.com 2019 - 2024. All rights reserved.