简体   繁体   English

Maven 阴影仅将依赖项(3 个中的 2 个)中的某些类着色为最终 jar

[英]Maven shade is only shading some classes from the dependency (2 of 3) into final jar

I am using Jitpack to get one of my github repositories as a dependency, and then using maven shade to include said dependency in the compiled output of the project.我正在使用 Jitpack 获取我的 github 存储库之一作为依赖项,然后使用 maven 阴影将所述依赖项包含在项目的已编译 output 中。 However, only 2 of the 3 classes in the dependency are being shaded into the final jar.但是,依赖项中的 3 个类中只有 2 个被隐藏到最终的 jar 中。 There seem to be no compilation issues (syntax or maven), yet at runtime the missing class causes a NoClassDefFoundError to be thrown.似乎没有编译问题(语法或 maven),但在运行时缺少 class 会导致抛出 NoClassDefFoundError。 Decompiling the jar shows that ConfigManager and Utils are shaded, but Logger is ignored.反编译 jar 显示 ConfigManager 和 Utils 被遮蔽,但 Logger 被忽略。

Dependency: https://github.com/Benlewis9000/PluginToolsAPI依赖: https://github.com/Benlewis9000/PluginToolsAPI

Project pom:项目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>com.github.benlewis9000</groupId>
    <artifactId>PluginToolsAPITestPlugin</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <repositories>
        <!-- This adds the Spigot Maven repository to the build -->
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>

        <!-- Access github repositories -->
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>

    <dependencies>
        <!--This adds the Spigot API artifact to the build -->
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.13.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.github.Benlewis9000</groupId>
            <artifactId>PluginToolsAPI</artifactId>
            <version>82aaa66bbf</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                          <minimizeJar>false</minimizeJar>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

Please let me know if any info is lacking, Thank you如有信息不足请告知,谢谢

I didn't know about Jitpack, it does look rather useful!我不知道 Jitpack,它看起来确实很有用!

I've used this config in the past for shade:我过去曾将此配置用于阴影:

<configuration>
  <filters>
    <filter>
      <artifact>*:*</artifact> 
    </filter>
  </filters>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM