是否可以创建一个 POM,在打包或更高版本中,仅将整个项目组装起来(例如,放入一个 zip 文件)并将其放置在目标中?
在这种情况下,项目中没有任何 Java 代码,它只是一组我想要打包的脚本和文件。为了统一起见(因为我们的商店都是 Maven),我真的很想有一个 POM 来做这件事,因为目前,我们有一个 shell 脚本来做这件事。
例子将不胜感激。
谢谢
所以我最终得到了以下内容,它创建了一个文件并且对我有用ServerSetupTools-0.1-SNAPSHOT.tar.gz
。target
唯一的缺点是我不确定如何让它在根目录中提取文件,所以我将它们全部移动到src/main/resources
,这对我也有用。希望这对其他人有帮助。
POM 文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>ServerSetupTools</artifactId>
<packaging>pom</packaging>
<name>ServerSetupTools</name>
<url>http://maven.apache.org</url>
<groupId>com.mycompany.utilities</groupId>
<version>0.1-SNAPSHOT</version>
<build>
<plugins>
<!-- Run assembly as part of packaging -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>
src/main/assembly/assemble.xml
</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase><!-- append to the packaging phase. -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
src/main/assembly/assemble.xml
:
<assembly xmlns="http://maven.apache.org/xsd/assembly"
xsi:schemaLocation="http://maven.apache.org/xsd/assembly-1.0.0.xsd">
<id>dist</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<includes>
<include>*</include>
</includes>
<directory>src/main/resources</directory>
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
</fileSets>