Maven shade插件没有将依赖项推送到.jar

时间:2014-12-03 16:30:19

标签: java eclipse maven

我之前问了一个question,那就是询问如何让maven自动将我的依赖源编译到我的build的.jar中,然后我被引导到Maven Shade插件,但是我似乎无法看到让它工作。构建完全没有变化,我已经清理过 - >更新 - >几次重建项目。

这是我的pom.xml

    <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>net.example.net</groupId>
      <artifactId>example-framework</artifactId>
      <version>1.0-SNAPSHOT</version>
      <name>exampleFramework</name>
      <description>http://examplenet/</description>
      <url>http://example.net/</url>
      <organization>
        <name>example</name>
        <url>http://example.net/</url>
      </organization>
      <build>
      <pluginManagement>
         <plugins>
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-compiler-plugin</artifactId>
               <version>3.1</version>
               <configuration>
                  <source>1.8</source>
                  <target>1.8</target>
               </configuration>
            </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <!-- put your configurations here -->
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
         </plugins>
      </pluginManagement>
      </build>
      <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-all</artifactId>
            <version>4.0.24.Final</version>
        </dependency>
        <dependency>
        <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20090211</version>
        </dependency>

      </dependencies>
    </project>

不确定我做错了什么,编译的结果是

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.229 s
[INFO] Finished at: 2014-12-03T10:22:45-06:00
[INFO] Final Memory: 16M/93M
[INFO] ------------------------------------------------------------------------

并且文件大小约为80kb,添加了依赖项大约为5mb(我必须手动完成,这很烦人)

编辑:请注意,eclipse将<plugin>放在<pluginManagement>之外,我认为这可能是问题并手动移动,但它没有改变任何东西

0 个答案:

没有答案