我尝试将其maven-shade-plugin用于模块化jar:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>javax.xml.bind:jaxb-api</include>
<include>com.sun.xml.bind:jaxb-impl</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>javax.xml.bind</pattern>
<shadedPattern>org.update4j.javax.xml.bind</shadedPattern>
</relocation>
<relocation>
<pattern>com.sun.xml.bind</pattern>
<shadedPattern>org.update4j.com.sun.xml.bind</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但是Maven会module-info.class从阴影罐中删除我,并发出警告:
[WARNING] Discovered module-info.class. Shading will break its strong encapsulation.
Run Code Online (Sandbox Code Playgroud)
我如何配置它离开它?
编辑:警告实际上是在删除阴影jar的模块描述符而不是我自己的模块描述符时发生的。