简介
Assembly 插件使开发人员能够将项目输出组合到一个可分发的存档中,该存档还包含依赖项、模块、站点文档和其他文件。目前它可以创建以下格式的发行版:
- zip
- tar
- tar.gz(or tgz)
- tar.bz2 (or tbz2)
- tar.snappy
- tar.xz (or txz)
- jar
- dir
- war
- and any other format that the ArchiveManager has been configured for
程序集和组件描述符模式 (XSD)
xsd描述对应各自版本:
描述符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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
| <assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <!--schemaLocation与assembly版本对应关系如上 --> xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.1 https://maven.apache.org/xsd/assembly-2.1.1.xsd">
<id/>
<formats/>
<includeBaseDirectory/>
<baseDirectory/>
<includeSiteDirectory/>
<containerDescriptorHandlers> <containerDescriptorHandler> <handlerName/> <configuration/> </containerDescriptorHandler> </containerDescriptorHandlers>
<moduleSets> <moduleSet> <useAllReactorProjects/> <includeSubModules/> <includes/> <excludes/> <sources> <useDefaultExcludes/> <outputDirectory/> <includes/> <excludes/> <fileMode/> <directoryMode/> <fileSets> <fileSet> <useDefaultExcludes/> <outputDirectory/> <includes/> <excludes/> <fileMode/> <directoryMode/> <directory/> <lineEnding/> <filtered/> <nonFilteredFileExtensions/> </fileSet> </fileSets> <includeModuleDirectory/> <excludeSubModuleDirectories/> <outputDirectoryMapping/> </sources> <binaries> <outputDirectory/> <includes/> <excludes/> <fileMode/> <directoryMode/> <attachmentClassifier/> <includeDependencies/> <dependencySets> <dependencySet> <outputDirectory/> <includes/> <excludes/> <fileMode/> <directoryMode/> <useStrictFiltering/> <outputFileNameMapping/> <unpack/> <unpackOptions> <includes/> <excludes/> <filtered/> <nonFilteredFileExtensions/> <lineEnding/> <useDefaultExcludes/> <encoding/> </unpackOptions> <scope/> <useProjectArtifact/> <useProjectAttachments/> <useTransitiveDependencies/> <useTransitiveFiltering/> </dependencySet> </dependencySets> <unpack/> <unpackOptions> <includes/> <excludes/> <filtered/> <nonFilteredFileExtensions/> <lineEnding/> <useDefaultExcludes/> <encoding/> </unpackOptions> <outputFileNameMapping/> </binaries> </moduleSet> </moduleSets>
<fileSets> <fileSet> <useDefaultExcludes/> <outputDirectory/> <includes/> <excludes/> <fileMode/> <directoryMode/> <directory/> <lineEnding/> <filtered/> <nonFilteredFileExtensions/> </fileSet> </fileSets> <files> <file> <source/> <sources/> <outputDirectory/> <destName/> <fileMode/> <lineEnding/> <filtered/> </file> </files>
<dependencySets> <dependencySet> <outputDirectory/> <includes/> <excludes/> <fileMode/> <directoryMode/> <useStrictFiltering/> <outputFileNameMapping/> <unpack/> <unpackOptions> <includes/> <excludes/> <filtered/> <nonFilteredFileExtensions/> <lineEnding/> <useDefaultExcludes/> <encoding/> </unpackOptions> <scope/> <useProjectArtifact/> <useProjectAttachments/> <useTransitiveDependencies/> <useTransitiveFiltering/> </dependencySet> </dependencySets>
<repositories> <repository> <outputDirectory/> <includes/> <excludes/> <fileMode/> <directoryMode/> <includeMetadata/> <groupVersionAlignments> <groupVersionAlignment> <id/> <version/> <excludes/> </groupVersionAlignment> </groupVersionAlignments> <scope/> </repository> </repositories>
<componentDescriptors/> </assembly>
|
插件引入
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
| <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>build-bin</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <tarLongFileMode>gnu</tarLongFileMode> <descriptors> <descriptor>assembly.xml</descriptor> </descriptors> <outputDirectory>target</outputDirectory> <finalName>platform-notify</finalName> <appendAssemblyId>false</appendAssemblyId> </configuration> </execution> </executions> </plugin> </plugins>
|
最后输出的文件名称由pom.xml中的finalName+assembly配置文件中的id,是否追加id取决于配置文件中的appendAssemblyId
常用到的两个变量:
- ${project.build.finalName} : 采用项目的artifactId-version
- ${basedir}:采用项目的根目录