阴影joda时间不包含类
Shaded joda time does not contain classes
我正在尝试使用 maven shade 插件将 Joda time 2.9.2 着色到我的最终 jar 文件中。但是 Joda time 的 classes 没有被添加到最终的 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 的 classes 没有包含在最终的 jar 中?我该如何解决这个问题?
致未来的读者:
使用 <minimizeJar>true</minimizeJar>
时,您应该在过滤器部分明确 包含 依赖项(在本例中为 joda 时间)。否则可以'optimized'离开。
v2.9.3 版本尚未发布。最新的是 v2.9.2.
更新:
版本问题弄清楚后,下面maven-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>
我正在尝试使用 maven shade 插件将 Joda time 2.9.2 着色到我的最终 jar 文件中。但是 Joda time 的 classes 没有被添加到最终的 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 的 classes 没有包含在最终的 jar 中?我该如何解决这个问题?
致未来的读者:
使用 <minimizeJar>true</minimizeJar>
时,您应该在过滤器部分明确 包含 依赖项(在本例中为 joda 时间)。否则可以'optimized'离开。
v2.9.3 版本尚未发布。最新的是 v2.9.2.
更新:
版本问题弄清楚后,下面maven-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>