Maven首页 Maven常用插件:maven-bundle-plugin的使用及详解

该插件可以把项目依赖的jar包打包到项目的根目录,前提是必须加上必须加上<EmbedDependency>*;scope=compile|runtime;inline=false</Embed-Dependency>这个配置

<groupId>com.ht.maventest</groupId>
<artifactId>meventest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- 必须加上packaging这个节点 -->
<packaging>bundle</packaging>

<plugin>
	<groupId>org.apache.felix</groupId>
	<artifactId>maven-bundle-plugin</artifactId>
	<version>3.2.0</version>
	<extensions>true</extensions>
	<configuration>
		<instructions>
			<Embed-Dependency>*;scope=compile|runtime;inline=false</Embed-Dependency>
		</instructions>
		<archive>
			<manifestEntries>
				<Bundle-ManifestVersion>2</Bundle-ManifestVersion>
				<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
				<Bundle-SymbolicName>${project.groupId}.${project.artifactId}
				</Bundle-SymbolicName>
				<Bundle-Version>${project.version}</Bundle-Version>
				<Bundle-Vendor>${project.groupId}</Bundle-Vendor>
				<Bundle-Activator>com.ht.pojo.Activator</Bundle-Activator>
				<Export-Package>com.ht.pojo</Export-Package>
				<Import-Package>org.osgi.framework</Import-Package>
			</manifestEntries>
		</archive>
	</configuration>
</plugin>

打包成功后的解压目录如下所示:

Maven常用插件:maven-bundle-plugin的使用及详解-图片-1