1. wiki
由 pom.xml 和 assembly.xml 组成,前者声明插件,后者是具体执行配置
2. pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>3.1.0</version> <finalName>${project.name}</finalName> <configuration> <descriptors> <descriptor>src/main/assembly/assembly.xml</descriptor> </descriptors> <finalName>outter</finalName> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin>
|
3. assembly.xml 打包配置文件
其中可以使用 pom.xml 中的变量和属性
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd http://maven.apache.org/ASSEMBLY/2.0.0 ">
<id>${profileActive}-${project.version}</id>
<formats> <format>tar.gz</format>
</formats> <includeBaseDirectory>true</includeBaseDirectory> <fileSets> <fileSet> <directory>${basedir}/src/bin</directory> <outputDirectory>bin</outputDirectory> <fileMode>0755</fileMode> <includes> <include>*.sh</include> </includes> <excludes> <exclude>*.no_need</exclude> </excludes> </fileSet>
<fileSet> <directory>${basedir}/target/classes</directory> <outputDirectory>config</outputDirectory> <fileMode>0644</fileMode> <includes> <include>application.yml</include> <include>application-${profileActive}.yml</include> <include>mapper/**/*.xml</include> <include>static/**</include> <include>templates/**</include> <include>*.xml</include> <include>*.properties</include> </includes> </fileSet>
<fileSet> <directory>${basedir}/target</directory> <outputDirectory>libs/</outputDirectory> <fileMode>0755</fileMode> <includes> <include>${artifactId}-${version}.jar</include> </includes> </fileSet> </fileSets> <files> <file> <source>pom.xml</source> <outputDirectory>.</outputDirectory> <fileMode>0755</fileMode> <destName>pom.xml</destName> </file> </files> <dependencySets> <dependencySet> <outputDirectory>lib</outputDirectory> <useProjectArtifact>false</useProjectArtifact> <scope>runtime</scope> <excludes> <exclude>log4j:log4j</exclude> <exclude>org.slf4j:slf4j-log4j12</exclude> </excludes> </dependencySet> </dependencySets>
</assembly>
|