相关疑难解决方法(0)

为什么Maven Shade插件会删除module-info.class?

我尝试将其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的模块描述符而不是我自己的模块描述符时发生的。

java maven maven-shade-plugin java-9 java-module

7
推荐指数
1
解决办法
3054
查看次数

标签 统计

java ×1

java-9 ×1

java-module ×1

maven ×1

maven-shade-plugin ×1