• 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>
    

    最终生成:

  • 相关阅读:
    【PE/Codecs】YUV文件比较的两种方法
    【Python】删除非空目录的方法shutil.rmtree()以及空目录的方法os.rmdir()
    【SVAC】国家视频编解码标准SVAC的特色和优势
    【SVAC】国标SVAC对飙通行标准,优势何在?
    【SVAC】SVAC推广应用进入关键期和高峰期
    【SVAC】SVAC 2.0安全系统组成
    【SVAC】期待国标视频编解码标准SVAC2.0应用推广!
    【Python】python取整函数和获取文件大小的方法
    【Python】Python中的正则表达式教程
    【Python】 整型数与字符串相互转换
  • 原文地址:https://www.cnblogs.com/xinting/p/12536130.html
Copyright © 2020-2023  润新知