zoukankan      html  css  js  c++  java
  • 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>
    

    最终生成:

  • 相关阅读:
    C#4.0,支持动态语言?
    宁波.NET俱乐部第二次聚会WCF讲稿
    在线学习新编程
    mysql常用函数
    PHP 连接Mysql数据库
    Unix网络编程进阶计划
    RabbitMQ 安装
    Golang 变量
    Golang 结构体
    Golang 指针
  • 原文地址:https://www.cnblogs.com/xinting/p/12536130.html
Copyright © 2011-2022 走看看