Maven打zip包

maven三种打包插件

maven有多种可以打包的插件,如下:

plugin function 官网
maven-jar-plugin maven 默认打包插件,用来创建 project jar
maven-shade-plugin 用来打可执行包,executable(fat) jar http://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html
maven-assembly-plugin 支持定制化打包方式,例如 apache 项目的打包方式 http://maven.apache.org/plugins/maven-assembly-plugin/usage.html

我们主要是要打zip包,也就是要使用maven-assembly-plugin插件。

maven-assembly-plugin pom配置

 <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-assembly-pluginartifactId>
                <version>2.2.1version>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/package.xmldescriptor>
                    descriptors>
                configuration>
                <executions>
                    <execution>
                        <id>make-assemblyid>
                        <phase>packagephase> 
                        <goals>
                            <goal>singlegoal> 
                        goals>
                    execution>
                executions>
  plugin>

指定打包文件 src/main/package.xml,在该配置文件内指定打包操作。

配置文件

<assembly 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/xsd/assembly-1.0.0.xsd">
    <id>fullid> 
    
    <formats>
    
        <format>zipformat>
    formats>

    <dependencySets>
        
        <dependencySet>
            <outputDirectory>/libsoutputDirectory> 
            <useProjectArtifact>falseuseProjectArtifact>


             <includes> 
             

                <include>net.sf.jsi:jsiinclude>
                <include>net.sf.trove4j:trove4jinclude>

            includes>



        dependencySet>
    dependencySets>

    <includeBaseDirectory>trueincludeBaseDirectory>
    <fileSets>
        <fileSet>
        
            <outputDirectory>/outputDirectory> 
            <directory>targetdirectory>
            <includes>
                <include>*.jarinclude>  
            includes>
        fileSet>

        <fileSet>
            <outputDirectory>/shelloutputDirectory>
            <directory>src/main/resources/shelldirectory>
            <includes>
                <include>*/*.shinclude>  
               <include>*/*.confinclude>  
            includes>
        fileSet>

    fileSets>
assembly>

这个xml的配置属性及其说明参见:http://gitlab.tenddata.com/data-process/gp-etl/blob/spark2.3test/src/main/package.xml

你可能感兴趣的:(其他)