Maven 项目中各包单独打成jar包

最近项目中有个需求就是把其中某几个包单独打成jar包发布。

项目结构如下:

使用 插件maven-jar-plugin  

pom.xml 配置如下:

	<build>
		<sourceDirectory>src/main/java</sourceDirectory>
		<outputDirectory>target/classes</outputDirectory>
		<resources>
			<resource>
				<directory>src/main/resources</directory>
				<includes>
					<include>*.properties</include>
					<include>*.xml</include>
					<include>**/*.*</include>
				</includes>
			</resource>
		</resources>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>3.1.0</version>
				<executions>
					<execution>
						<id>bpm</id>
						<goals>
							<goal>jar</goal>
						</goals>
						<phase>compile</phase>
						<configuration>
							<finalName>${bpm.finalName}</finalName>
							<classifier>bpm-${bpm.version}</classifier>
							<includes>
								<include>*/*/bpm/**</include>
							</includes>
						</configuration>
					</execution>
					<execution>
						<id>core</id>
						<goals>
							<goal>jar</goal>
						</goals>
						<phase>compile</phase>
						<configuration>
							<finalName>${bpm.finalName}</finalName>
							<classifier>core-${bpm.version}</classifier>
							<includes>
								<include>*/*/core/**</include>
							</includes>
							<excludes>
								<exclude>mybatis/**</exclude>
							</excludes>
						</configuration>
					</execution>
					<execution>
						<id>saweb</id>
						<goals>
							<goal>jar</goal>
						</goals>
						<phase>compile</phase>
						<configuration>
							<finalName>${bpm.finalName}</finalName>
							<classifier>saweb-${bpm.version}</classifier>
							<includes>
								<include>*/*/saweb/**</include>
							</includes>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.0</version>
				<configuration>
					<target>1.8</target>
					<source>1.8</source>
					<encoding>UTF-8</encoding>
					<showDeprecation>true</showDeprecation>
					<compilerArgs>
						<arg>-Xlint:unchecked</arg>
						<arg>-Xlint:deprecation</arg>
					</compilerArgs>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.22.1</version>
				<configuration>
					<skipTests>true</skipTests>
				</configuration>
			</plugin>
		</plugins>
	</build>

最终生成:

posted @ 2018-12-07 14:03  骑猪上高速_D  阅读(397)  评论(0编辑  收藏  举报