.jar не создается после сборки ANT в Eclipse - PullRequest
0 голосов
/ 26 января 2020

По какой-то причине Eclipse не создает файл .jar, когда я запускаю сборку ANT. xml файл.

Пожалуйста, рассмотрите мой код:

<!-- 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' работают нормально) Каталог / jar создается в Users / MotiveWave / Extensions, как и ожидалось.

Но я не могу найти один файл .jar с определенным мною именем («пример 15») (поэтому «имя цели» jar как-то неверно)

Может кто-нибудь пролить свет на то, почему именно это возможно ?

1 Ответ

0 голосов
/ 26 января 2020

Вы можете заменить

<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">
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...