gpt4 book ai didi

java - 阴影 joda 时间不包含类

转载 作者:行者123 更新时间:2023-12-01 10:19:27 24 4
gpt4 key购买 nike

我正在尝试使用 Maven 着色插件将 Joda time 2.9.2 着色到我的最终 jar 文件中。但是 Joda time 的类没有添加到最终的 jar 中,一些包和其他文件被添加,但不是 .class 文件。

这是我的 pom.xml;

<?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>me.ninjoh</groupId>
<artifactId>nincore</artifactId>
<version>2.0.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<local.maven.repository>file:///Users/LegitAdmin/.m2/repository</local.maven.repository>
</properties>

<repositories>
<repository>
<id>mcapi</id>
<url>http://build.mc-api.net/plugin/repository/everything/</url>
</repository>

<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>

</repositories>

<dependencies>
<dependency>
<groupId>net.mcapi.uuid</groupId>
<artifactId>uuid-java</artifactId>
<version>1.1.2</version>
</dependency>

<!--Spigot API-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<!--Bukkit API-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<!-- Joda Time-->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.2</version>
</dependency>

<!-- Jbcrypt -->
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.3m</version>
</dependency>

<!-- Jansi (for color in console) -->
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.11</version>
</dependency>

<!-- Jetbrains annotations -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations-java5</artifactId>
<version>15.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>org.jetbrains:annotations-java5</include>
<include>org.fusesource.jansi:jansi</include>
<include>org.mindrot:jbcrypt</include>
<include>net.mcapi.uuid:uuid-java</include>
<include>joda-time:joda-time</include>
</includes>
</artifactSet>
<relocations>

<relocation>
<pattern>org.jetbrains</pattern>
<shadedPattern>me.ninjoh.common.org.jetbrains</shadedPattern>
</relocation>

<relocation>
<pattern>org.fusesource.jansi</pattern>
<shadedPattern>me.ninjoh.common.org.fusesource.jansi</shadedPattern>
</relocation>

<relocation>
<pattern>org.mindrot.jbcrypt</pattern>
<shadedPattern>me.ninjoh.common.org.mindrot.jbcrypt</shadedPattern>
</relocation>

<relocation>
<pattern>net.mcapi.uuid</pattern>
<shadedPattern>me.ninjoh.common.net.mcapi.uuid</shadedPattern>
</relocation>

</relocations>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/license/**</exclude>
<exclude>META-INF/*</exclude>
<exclude>META-INF/maven/**</exclude>
<exclude>LICENSE</exclude>
<exclude>NOTICE</exclude>
<exclude>/*.md</exclude>
<exclude>/.gitignore</exclude>
<exclude>/*.txt</exclude>
<exclude>build.properties</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin>
</plugins>
</build>

<distributionManagement>
<repository>
<id>local-repository</id>
<url>${local.maven.repository}</url>
</repository>
</distributionManagement>

这是最终 jar 文件的内容; http://pastebin.com/TXzB9vTv

为什么 Joda time 的类(class)没有包含在最终的 jar 中?我该如何解决这个问题?

对于 future 的读者:使用时<minimizeJar>true</minimizeJar>您应该在过滤器部分中明确包含依赖项(在本例中为 joda time)。否则它可以被“优化”掉。

最佳答案

v2.9.3 版本尚未发布。最新的是v2.9.2 .

更新:

澄清版本问题后,对m aven-shade-plugin 的描述如下很重要。

Besides user-specified filters, the plugin can also be configured to automatically remove all classes of dependencies that are not used by the project, thereby minimizing the resulting uber JAR

因此,要么确保您的项目确实使用 Joda-Time,要么删除标签条目

<minimizeJar>true</minimizeJar>

关于java - 阴影 joda 时间不包含类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35705889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com