在 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'-部分工作正常)
正在按预期在 Users/MotiveWave/Extensions 中创建目录 /jar。
但是我找不到一个带有我定义的名称 ("example 15") 的 .jar 文件(所以'目标名称 '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">
由于某些原因,当我 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'-部分工作正常) 正在按预期在 Users/MotiveWave/Extensions 中创建目录 /jar。
但是我找不到一个带有我定义的名称 ("example 15") 的 .jar 文件(所以'目标名称 '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">