欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

maven常用插件-打包

程序员文章站 2022-03-04 17:21:33
...

 

jar包

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-jar-plugin</artifactId>
	<version>2.4</version>
	<configuration>
		<archive>
			<manifest>
				<addClasspath>true</addClasspath>
				<classpathPrefix>lib/</classpathPrefix>
				<mainClass>com.xxx.windfarmconfigtool.FrontConfigMain</mainClass>
				<!-- <useUniqueVersions>false</useUniqueVersions> -->
			</manifest>
			<manifestEntries>
				<Class-Path>./</Class-Path>
			</manifestEntries>
		</archive>
	</configuration>
</plugin>

 

归档文件:

<plugin>
	<artifactId>maven-assembly-plugin</artifactId>
	<configuration>
		<appendAssemblyId>false</appendAssemblyId>
		<descriptors>
			<descriptor>src/main/resources/config/package-frontconfig.xml</descriptor>
		</descriptors>
	</configuration>
	<executions>
		<execution>
			<id>make-assembly</id>
			<phase>package</phase>
			<goals>
				<goal>single</goal>
			</goals>
		</execution>
	</executions>
</plugin>

 

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
	<id>package</id>
	<formats>
		<format>zip</format>
	</formats>
	<includeBaseDirectory>true</includeBaseDirectory>
	<fileSets>
		<fileSet>
			<directory>src/main/resources</directory>
			<outputDirectory>/</outputDirectory>
			<!-- <includes>
				<include>config/log4j.properties</include>
				<include>frontconfig/*</include>
			</includes> -->
		</fileSet>
		<fileSet>
			<directory>${project.build.directory}</directory>
			<outputDirectory>/</outputDirectory>
			<includes>
				<include>*.exe</include>
				<include>*.jar</include>
			</includes>
		</fileSet>
	</fileSets>
	<dependencySets>
		<dependencySet>
			<outputDirectory>lib</outputDirectory>
			<scope>runtime</scope>
			<!-- <unpack>false</unpack> -->
			<excludes>
				<!-- <exclude>${project.name}-${project.version}</exclude> -->
				<exclude>${groupId}:${artifactId}</exclude>
			</excludes>
		</dependencySet>
	</dependencySets>
</assembly>

 

exe:

<plugin>
	<groupId>org.bluestemsoftware.open.maven.plugin</groupId>
	<artifactId>launch4j-plugin</artifactId>
	<version>1.5.0.0</version>
	<executions>
		GUI exe
		<execution>
			<id>l4j-gui</id>
			<phase>package</phase>
			<goals>
				<goal>launch4j</goal>
			</goals>
			<configuration>
				<headerType>gui</headerType>
				<outfile>target/${artifactId}-${version}.exe</outfile>
				<downloadUrl>https://java.com/en/download/manual.jsp</downloadUrl>
				<jar>target/${artifactId}-${version}.jar</jar> 'shaded' is the value set on shadedClassifierName above
				<errTitle>App Err</errTitle>
				<classPath>
					<mainClass>com.xxx.windfarmconfigtool.Main</mainClass>
					<addDependencies>true</addDependencies>
					<jarLocation>target/lib</jarLocation>
					<preCp>lib/*.jar</preCp>
				</classPath>
				<icon>src/main/resources/icons/application.ico</icon>
				<jre>
					<minVersion>1.8.0</minVersion>
					<maxVersion>1.6.0</maxVersion>
					<initialHeapSize>128</initialHeapSize>
					<maxHeapSize>1024</maxHeapSize>
					<path>C:\Program Files\Java\jre1.8.0_101\bin</path>
					<bundledJre64Bit>true</bundledJre64Bit>
					<bundledJreAsFallback>true</bundledJreAsFallback>
					<jdkPreference>jdkOnly</jdkPreference>
					<runtimeBits>64</runtimeBits>
				</jre>
				<versionInfo>
					<fileVersion>1.0.0.0</fileVersion>
					<txtFileVersion>1.0.0.0</txtFileVersion>
					<fileDescription>xxx</fileDescription>
					<copyright>xxx</copyright>
					<productVersion>1.0.0.0</productVersion>
					<txtProductVersion>1.0.0.0</txtProductVersion>
					<productName>${artifactId}-${version}</productName>
					<internalName>${artifactId}-${version}</internalName>
					<originalFilename>${project.name }.exe</originalFilename>
				</versionInfo>
				<messages>
				<startupErr>text</startupErr>
				<bundledJreErr>text</bundledJreErr>
				<jreVersionErr>text</jreVersionErr>
				<launcherErr>text</launcherErr>
				Used by console header only.
				<instanceAlreadyExistsMsg>text</instanceAlreadyExistsMsg>
			  </messages>
			</configuration>
		</execution>
	</executions>
</plugin>