Maven-assembly-plugin of Maven Plug-ins

Source: Internet
Author: User

Use MAVEN to package a Web project by default, but there are times when you always want to make a zip package (or other compressed package), and the Maven-war-plugin plugin is powerless, and then you use the Maven-assembly-plugin plugin, Official website:

http://maven.apache.org/plugins/maven-assembly-plugin/

The plug-in can be packaged into a specified format distribution, and more importantly, it is possible to customize the inclusion/exclusion of specified directories or files (in legacy projects, when filtering the configuration file, or simply by publishing a picture or a css/js file of the specified type).

The plug-in is used as follows:

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactid>maven-assembly- plugin</artifactid> <version>2.4</version> <configuration> <APPENDASSEMBL Yid>false</appendassemblyid> <descriptors> <DESCRIPTOR>${BASEDIR}/ASSEMBLY.XM L</descriptor> <!--Assembly Descriptor file--> <!--<descriptor>src/main/assembly/assembly.xml& Lt;/descriptor>--> </descriptors> </configuration> <executions> &  
            Lt;execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </executi On> </executions> </plugin> 

If shown, bind to the package phase, automatically package, and you need to specify a assembly descriptor file that specifies the packaging format, file/filtered files, and so on, and can be assigned multiple descriptor files, packaged into different formats;

The following is the contents of the Assembly.xml file, which indicates that all files under the Web-inf/lib directory are excluded when packaged:

<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>full</id>  
    <formats>  
        <format>zip</format> <!--packaged file format-- >
    </formats>  
    <includeBaseDirectory>true</includeBaseDirectory>  
    <filesets >   
        <fileSet>  
            <outputDirectory>/</outputDirectory>  
            <directory>webroot </directory>  
            <includes>  
                <include>**/*</include>  
            </includes>  
            <excludes>  
                <exclude>WEB-INF/lib/*</exclude>  
            </excludes>  
        </fileset >  
    </fileSets>  
</assembly>

So you can.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.