如何在maven中捆绑第三方jar?
问题描述:
我想使用maven bundle插件将tibjms.jar和javax.jms-api-2.0.jar捆绑到一个包中。由于tibjms.jar不是在Maven回购我第一次把它添加到我的本地回购:如何在maven中捆绑第三方jar?
mvn install:install-file -Dfile=/home/riyafa/Documents/Workspace/Support/NNINSURANCESUB-17/tibco/libs/jms-2.0.jar -DgroupId=com.tibco -DartifactId=tibjms -Dversion=4.4.0 -Dpackaging=jar -DgeneratePom=false
然后,我创建了以下POM文件,并建立了它:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.riyafa</groupId>
<artifactId>tibco</artifactId>
<packaging>bundle</packaging>
<version>1</version>
<dependencies>
<dependency>
<groupId>com.tibco</groupId>
<artifactId>tibjms</artifactId>
<version>4.4.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>
com.tibco.tibjms.*,
com.tibco.tibjms.naming.*,
com.tibco.tibjms.naming.tibjmsnaming.*,
</Export-Package>
<Import-Package>
*,
!javax.jms.*,
</Import-Package>
<Embed-Dependency>
javax.jms-api;scope=compile|runtime;inline=false;
</Embed-Dependency>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
构建成功,但我只看到生成的jar中的javax.jms-api-2.0.jar:
我想捆绑两个罐子。当其中一个罐子是一个thirparty罐子时,我怎么能做到这一点?我也尝试添加jar到pom文件作为外部库,它不起作用。
答
难道你没有忘记为tibjms
添加EmbedDependency
?您还可以嵌入所有的编译和运行时depenedencies:
<Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
请注意,javax.jms-api
已经打包成捆。如果tibco
工件的唯一用途是将tibjms
和jms-api
捆绑在一起,则可以考虑完全跳过它,而是将tibjms
作为捆绑包进行打包。然后,您可以将tibjms
和jms-api
作为单独的捆绑包进行部署。
谢谢!我希望它们在单个包中,因为我希望由jms-api公开的方法仅对tibjms.jar可见,因为它与另一个jar冲突。 –
关于能见度的好处! – gjoranv