Maven 常用工具与配置

版权声明:欢迎转载 https://blog.csdn.net/antony1776/article/details/86014020

assembly插件实现自定义打包

http://maven.apache.org/plugins/maven-assembly-plugin/index.html
https://blog.csdn.net/defonds/article/details/43233131

plugin function
maven-jar-plugin maven 默认打包插件,用来创建 project jar
maven-shade-plugin 用来打可执行包,executable(fat) jar
maven-assembly-plugin 支持定制化打包方式,例如 apache 项目的打包方式
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
               <goal>shade</goal>
            </goals>
                <configuration>
                    <transformers>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>com.demo.App</mainClass>
                        </transformer>
                    </transformers>
                </configuration>
        </execution>
    </executions>
 </plugin>
<build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                   <artifactId> maven-assembly-plugin </artifactId>
                   <configuration>
                        <descriptorRefs>
                             <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                             <manifest>
                                  <mainClass>com.demo.App</mainClass>
                             </manifest>
                        </archive>
                   </configuration>
                   <executions>
                        <execution>
                             <id>make-assembly</id>
                             <phase>package</phase>
                             <goals>
                                  <goal>single</goal>
                             </goals>
                        </execution>
                   </executions>
              </plugin>
            

        </plugins>
    </build>

mvn assembly:assembly

配置 Java 编译器版本

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven‑compiler‑plugin</artifactId>
   <version>3.6.1</version>
   <configuration>
       <source>1.8</source>
       <target>1.8</target>
   </configuration>
</plugin>

猜你喜欢

转载自blog.csdn.net/antony1776/article/details/86014020