Maven 常用工具與配置
阿新 • • 發佈:2019-01-11
文章目錄
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>