11) Generate executable jar file Maven-shade-plugin

Source: Internet
Author: User

Search site:maven.apache.org Maven-assembly-plugin

Http://maven.apache.org/plugins/maven-assembly-plugin/usage.html

All goals except Assembly:single has been deprecated.

The above cannot be used, the following can be.

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

Examples

Executable JAR

1. Pom.xml

<Projectxmlns= "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/maven-4.0.0.xsd">    <modelversion>4.0.0</modelversion>    <groupId>Cn.zno</groupId>    <Artifactid>Executable</Artifactid>    <version>1.0</version>    <Build>        <Plugins>            <plugin>                <groupId>Org.apache.maven.plugins</groupId>                <Artifactid>Maven-shade-plugin</Artifactid>                <version>2.4</version>                <executions>                    <Execution>                        <Phase>Package</Phase>                        <Goals>                            <goal>Shade</goal>                        </Goals>                        <Configuration>                            <Transformers>                                <TransformerImplementation= "Org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">                                    <MainClass>Cn.zno.commandline.Test</MainClass>                                </Transformer>                            </Transformers>                        </Configuration>                    </Execution>                </executions>            </plugin>        </Plugins>    </Build></Project>

2. Test.java

 Package Cn.zno.commandline; Import java.lang.management.ManagementFactory;  Public class Test {    publicstaticvoid  main (string[] args) {        System.out.println ("VM arguments:" + Managementfactory.getruntimemxbean (). getinputarguments ());        SYSTEM.OUT.PRINTLN ("program arguments:");          for (String Arg:args) {            System.out.println (ARG);     }}}

Packaged

We'll see a entry like this in the meta-inf/manifest. MF file of the resulting JAR:

Manifest-version:1.0build-jdk:1.7.0_15built-by:administratorcreated-by:apache MavenMain-Class: Cn.zno.commandline.testarchiver-version:plexus archiver

Test executable jar File

java [-options]-jar jarfile [args ...]

E:\e\workspace\executable\target>java-xms32m-xmx32m-jar executable-1.0. Jar a BVM arguments:[- xms32m,-xmx32m]program arguments:ab

11) Generate executable jar file Maven-shade-plugin

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.