我正在使用maven-shade-plugin在打包阶段重新定位一些包。同时,我还在使用maven-bundle-plugin生成清单。问题是bundle插件在shade插件之前运行(在process-classes阶段),并且在生成的清单导出时不包括任何经过shade处理的包。
我该如何让这两个插件相互配合,以便我的重新定位的包像其他任何包一样被bundle插件处理?
--
根据请求,以下是我的POM中Shade和bundle部分:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<filters>
<filter>
<artifact>cglib:cglib</artifact>
<includes>
<include>net/sf/cglib/core/**</include>
<include>net/sf/cglib/proxy/**</include>
</includes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>net.sf.cglib</pattern>
<shadedPattern>org.modelmapper.internal.cglib</shadedPattern>
</relocation>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>org.modelmapper.internal.asm</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>
org.modelmapper,
org.modelmapper.builder,
org.modelmapper.config,
org.modelmapper.convention,
org.modelmapper.spi
</Export-Package>
<Private-Package>
org.modelmapper.internal.**
</Private-Package>
<Import-Package>
*
</Import-Package>
<Include-Resource>
{maven-resources},
{maven-dependencies}
</Include-Resource>
</instructions>
</configuration>
</plugin>
取自此处
mvn compile shade:shade bundle:manifest package
,那么清单是否正确生成? - Anthony Accioly<packaging>jar</packaging>
) 还是 Bundle?尝试将这两个插件绑定到package
阶段(确保 Maven Bundle 在插件列表中出现在 Maven Shade 之后)。它是否正确打包了 Bundle 并添加了所需的元数据? - Anthony Accioly