[英]Create directory structures during Ant jar task
I want to create a jar with the following directory structure: 我想创建一个具有以下目录结构的jar:
thejar.jar/
classes/ --> where all classes go
lib/ --> where all dependencies go
res/ --> where all non-classpath resources go (scripts, etc.)
META-INF/
Here's my ant task: 这是我的蚂蚁任务:
<jar destfile="dist/main/thejar.jar">
<!-- Create the manifest -->
<manifest>
<!-- JAR should be sealed. -->
<attribute name="Sealed" value="true" />
</manifest>
<!-- Copy main build directory to classes/ directory in JAR. -->
<fileset dir="dist/main/classes" includes="build/main"/>
<!-- Copy main library directory to lib/ directory in JAR. -->
<fileset dir="dist/main/lib" includes="lib/main"/>
<!-- Copy main resources directory to res/ in JAR. -->
<fileset dir="dist/main/res" includes="res/main"/>
</jar>
If I am understanding this correctly, it should be: 如果我正确理解这一点,它应该是:
build/main
to dist/main/classes
build/main
所有构建(.class)文件复制到dist/main/classes
lib/main
dependencies to dist/main/lib
lib/main
依赖项复制到dist/main/lib
res/main
files to dist/main/res
res/main
文件复制到dist/main/res
dist/main/*
into thejar.jar
dist/main/*
thejar.jar
到thejar.jar
The JAR task executes without errors, but when I go to view the contents of thejar.jar
I just see META-INF/ (none of the subdirectories I mentioned above). JAR任务执行没有错误,但当我去查看
thejar.jar
的内容时,我只看到META-INF /(我上面提到的子目录都没有)。
What's going on here? 这里发生了什么? Thanks in advance!
提前致谢!
You want jar
task to copy files in build/main
into jar's dist/main/lib
, but 您希望
jar
任务将build/main
文件复制到jar的dist/main/lib
,但是
<fileset dir="dist/main/classes" includes="build/main"/>
means to pack files in dist/main/classes/build/main
into the jar file. 意味着将
dist/main/classes/build/main
的文件打包到jar文件中。
Take a look at the example from the Ant-Jar task doc: 看一下Ant-Jar任务文档中的示例:
<jar destfile="${dist}/lib/app.jar">
<fileset dir="${build}/classes"
excludes="**/Test.class"
/>
<fileset dir="${src}/resources"/>
</jar>
(The code above) jars all files in the ${build}/classes directory and also in the ${src}/resources directory together into a file called app.jar in the ${dist}/lib directory.
(上面的代码)将$ {build} / classes目录中的所有文件以及$ {src} / resources目录中的所有文件一起放入$ {dist} / lib目录中名为app.jar的文件中。
To achieve your request, I think you can copy the classes, resources and dependencies with <copy>
task into the directory structure that you want and then jar the directory. 为了实现您的请求,我认为您可以使用
<copy>
任务将类,资源和依赖项<copy>
到所需的目录结构中,然后对目录进行jar操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.