maven assembly 配置詳解

(1)、在pom.xml 文件裏面的配置說明

<plugin>  
    <artifactId>maven-assembly-plugin</artifactId>  
    <executions>  <!--執行器 mvn assembly:assembly-->  
        <execution>  
            <id>make-zip</id><!--名字任意 -->    
        <phase>package</phase><!-- 綁定到package生命週期階段上 -->    
        <goals>    
           <goal>single</goal><!-- 只運行一次 -->    
        </goals>    
            <configuration>  
                     <descriptors> <!--描述文件路徑-->  
                          <descriptor>src/main/resources/zip.xml</descriptor>  
                    </descriptors>  
            </configuration>  
        </execution>  
    </executions>  
 </plugin>  

例:

<span style="white-space:pre">			</span><plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<configuration>
					<!-- not append assembly id in release file name -->
					<appendAssemblyId>false</appendAssemblyId>
					<descriptors>
						<descriptor>src/main/assembly/assembly.xml</descriptor>
					</descriptors>
				</configuration>
				<executions>
					<execution>
						<id>make-assembly</id>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

(2)、zip.xml 文件配置如下

<assembly  
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">  
    <id>release</id>  
    <formats>  
        <format>zip</format>  
    </formats>  
    <fileSets>  
        <fileSet>  
            <directory>${project.basedir}\src\main\config</directory>  
            <!-- 過濾 -->  
            <excludes>  
                <exclude>*.xml</exclude>  
            </excludes>  
            <outputDirectory>\</outputDirectory>  
        </fileSet>  
    </fileSets>  
      
    <dependencySets>  
        <dependencySet>  
            <useProjectArtifact>true</useProjectArtifact>  
            <outputDirectory>lib</outputDirectory><!-- 將scope爲runtime的依賴包打包到lib目錄下。 -->  
            <scope>runtime</scope>  
        </dependencySet>  
    </dependencySets>  
</assembly>  
例:

<assembly>
	<id>assembly</id>
	<formats>
		<format>tar.gz</format>
	</formats>
	<includeBaseDirectory>true</includeBaseDirectory>
	<fileSets>
		<fileSet>
			<directory>${project.build.directory}/resources</directory>
			<outputDirectory>resources</outputDirectory>
			<fileMode>0755</fileMode>
		</fileSet>
		<fileSet>
			<directory>${project.build.directory}/config</directory>
			<outputDirectory>config</outputDirectory>
			<fileMode>0644</fileMode>
		</fileSet>
		<fileSet>
			<directory>${project.build.directory}/bin</directory>
			<outputDirectory>bin</outputDirectory>
			<fileMode>0755</fileMode>
		</fileSet>
	</fileSets>
	<dependencySets>
		<dependencySet>
			<outputDirectory>lib</outputDirectory>
		</dependencySet>
	</dependencySets>
</assembly>





http://blueram.iteye.com/blog/1684070

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章