Apache ant 清单类路径? [英] Apache ant manifest class-path?
问题描述
我有一个 Java 项目的标准项目布局:
I have a standard project layout for a java project:
project /
src /
source_file_1.java
...
source_file_N.java
build /
classes /
source_file_X.class
...
jar /
MyJar.jar
lib /
SomeLibrary.jar
SomeOtherLibrary.jar
据我所知,我正在使用 Ant 正确构建项目.我需要在 Manifest 文件中设置 class-path 属性,以便我的类可以使用所需的库.
As far as I can tell, I am building the project correctly with Ant. I need to set the class-path attribute in the Manifest file so my classes can use the required libraries.
以下相关信息来自build.xml
The following relevant information from build.xml
<target name="compile" depends="init">
<javac srcdir="src" destdir="build\classes">
<classpath id="classpath">
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="jar" depends="compile">
<jar destfile="build\jar\MyJar.jar" basedir="build\classes" >
<manifest>
<attribute name="Built-By" value="${user.name}" />
</manifest>
</jar>
</target>
任何朝正确方向的推动都值得赞赏.谢谢
Any push in the right direction is appreciated. Thanks
推荐答案
查看我的 NetBeans 生成的构建文件,我在 -do-jar-with-libraries
任务中发现了这个片段:
Looking at my NetBeans-generated build file, I found this snippet in the -do-jar-with-libraries
task:
<manifest>
<attribute name="Main-Class" value="${main.class}"/>
<attribute name="Class-Path" value="${jar.classpath}"/>
</manifest>
换句话说,您似乎只需要向已有的清单任务添加另一个属性.
So in other words, it looks like you just need to add another attribute to the manifest task that you already have.
另请参阅清单任务文档.
这篇关于Apache ant 清单类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!