在要导入的其他项目中不显示着色类(来自uber jar)

时间:2017-09-13 02:05:20

标签: java maven maven-3 uberjar

我试图隐藏依赖(构建超级jar)并导入其他项目。在超级jar我可以看到类但是当我尝试导入着色文件夹/包时不显示。我是pom.xmls

具有着色依赖性和超级jar的Test1

<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>test</groupId>
  <artifactId>test</artifactId>
  <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>


  <properties>
        <jdk.version>1.8</jdk.version>
        <jodatime.version>2.5</jodatime.version>
    </properties>

  <dependencies>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>${jodatime.version}</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>test</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                </configuration>
            </plugin>

            <!-- Set a compiler level -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.7.0</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                </configuration>
            </plugin>

        <!-- Maven Shade Plugin -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>3.1.0</version>
          <executions>
             <!-- Run shade goal on package phase -->
            <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
              <relocations>
                <relocation>
                    <pattern>org.joda</pattern>
                    <shadedPattern>test.shaded.org.joda</shadedPattern>
                </relocation>
                </relocations>

            </configuration>
              </execution>
          </executions>
        </plugin>

        </plugins>
    </build>


</project>

测试2我将test1添加为依赖

    <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>test2</groupId>
      <artifactId>test2</artifactId>
      <version>0.0.1-SNAPSHOT</version>

        <dependencies>
            <dependency>
                <groupId>test</groupId>
                <artifactId>test</artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </dependency>
        </dependencies>
    </project>

但是当我在Test2项目中尝试import test.shaded.org.joda时,依赖性没有显示。

0 个答案:

没有答案