是否有可能创建一个POM,在包或更大,只是组装整个项目(例如,一个zip文件),并将其放置在目标?POM拉动项目
在这种情况下,项目中没有任何Java代码,它仅仅是我想打包的一组脚本和文件。为了统一起见(因为我们的商店都是Maven),我真的希望有一个POM来做这件事,因为目前我们有一个shell脚本。
例子会很赞赏。
感谢
是否有可能创建一个POM,在包或更大,只是组装整个项目(例如,一个zip文件),并将其放置在目标?POM拉动项目
在这种情况下,项目中没有任何Java代码,它仅仅是我想打包的一组脚本和文件。为了统一起见(因为我们的商店都是Maven),我真的希望有一个POM来做这件事,因为目前我们有一个shell脚本。
例子会很赞赏。
感谢
所以我结束了以下,这在target
创建一个文件ServerSetupTools-0.1-SNAPSHOT.tar.gz
和对我的作品。唯一的缺点是,我不知道如何让它在根目录下获取文件,所以我将它们全部移到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>
您应该坚持[Maven标准目录布局](http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html)。这意味着你的脚本应该在'src/main/scripts'而不是'src/main/resources'中。你不应该使用['maven-assembly-plugin'](http://mvnrepository.com/artifact/org.apache.maven.plugins/maven-assembly-plugin/2.3)的beta版本,使用版本'2.3 '这是最新的可用。 – maba
这是一个伟大的观点。不幸的是,这个项目中包含的文件并不是所有的脚本(这里面有一些jar包和什么)。为了简单起见(以组织为代价),我会坚持'资源'。我会根据你的建议切换到2.3 –
像这样的事情? http://stackoverflow.com/q/1500758/422353 – madth3
是的,虽然这比我想要的稍微复杂一些。我即将发布自己想出的东西(很好,很简单)。感谢您的帮助:) –