Nom*_*meN 10 maven-2 build maven-assembly-plugin
我有我要建设成一个罐子,这是通过提供JAR-具有依赖性descriptorRef在pom.xml很容易一个Maven化Java项目(Maven2的).
但是,我还需要在一个带有一些.exe和.bat文件的zip文件中部署我的项目,其中包括调用jar的bin文件夹.(我正在使用Tanuki,但对于我认为的用例并不重要)
换句话说,我需要一个构建,其中首先将我的源(和依赖项)打包到一个jar中,然后将该jar放入带有bin文件夹中的一些附加文件的zip.
我应该把什么放在我的pom.xml和'assembly'.xml中?
Maven-assembly-plugin是正确的工具.
您必须在pom的"build"部分声明此插件,并在项目的根目录中创建另一个配置文件"assembly.xml".在此文件中,您将定义zip文件的内容.
配置选项在官方网站上有描述:http://maven.apache.org/plugins/maven-assembly-plugin/
以下是此插件的基本配置示例,可以满足您的需求.
POM配置:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>zipfile</finalName>
<descriptors>
<descriptor>${basedir}/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
装配配置:
<assembly>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>to_complete</directory>
<outputDirectory />
<includes>
<include>**/*.jar</include>
<include>**/*.bat</include>
<include>**/*.exe</include>
</includes>
</fileSet>
</fileSets>
</assembly>
Run Code Online (Sandbox Code Playgroud)