在jar旁边的Maven中创建带有其他文件的zip文件 [英] Create zip in maven with additional files next to the jar
问题描述
我唯一的Maven体验是包括其他库,因此我需要一个非常基本的解释,说明如何使用Eclipse在Maven中实现功能.
The only Maven experience I have is including other libraries so I need a very basic explanation about how I can achieve things in Maven with Eclipse.
我想定期创建我的jar.然后,我想再提取3个文件,并将所有文件放到1个zip文件中.我的zip内容应如下所示:
I want to create my jar regulary. Then I want to take 3 further files and put all files together in 1 zip file. The content of my zip should look like this:
A.jar
B.txt
C.txt
D.bat
我知道我必须在pom.xml
文件中插入某些目标.我已经在Stack Overflow上看到过有关以下内容的帖子(即此处)类似的话题.我还尝试了Maven文档,例如此处.我已经需要任何Maven插件还是仍然是Maven核心的东西吗?
I know I have to insert certain goals in my pom.xml
file. I already saw posts on Stack Overflow (i.e. here) regarding similar topics. I also tried the Maven documentation like here. Do I already need any Maven plugins or is still already Maven-core stuff?
但是我的技能还不足以为我的案例传递此信息.
But my skills are not enough yet to transfer this information for my case.
推荐答案
+ project
+ src/main/java
+ src/main/resources
+ src/main/config
+B.txt
+C.txt
+D.bat
+ src/main/assembly
+bin.xml
+pom.xml
bin.xml
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/config</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
</assembly>
poml.xml
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- append to the packaging phase. -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
输出: mvn清洁程序包
Output : mvn clean package
+ artifactId-version.zip
+ B.txt
+C.txt
+D.txt
+artifactId-version.jar
未在src/main/resources中添加B.txt,C.txt,D.bat,因为将它们放在CLASSSPATH中是不好的
Not added B.txt, C.txt, D.bat in src/main/resources because it's not good to have them in the CLASSSPATH
这篇关于在jar旁边的Maven中创建带有其他文件的zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!