1

I asked a question earlier, that was asking how to have maven automatically compile my dependencies sources into my build's .jar, and I was directed to the Maven Shade plugin, however I can't seem to get it to work. The build hasn't change at all, I've already cleaned->updated-> rebuilt the project a few times.

Here's my 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>

Not sure what I'm doing wrong, the results of the compilation are

[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] ------------------------------------------------------------------------

and the file size is about 80kb, it's about 5mb with the dependencies added (Which I've had to do manually and it's annoying)

EDIT: Please note that eclipse put the <plugin> outside of the <pluginManagement>, I thought this could have been the issue and moved it manually, but it didn't change anything

Community
  • 1
  • 1
Hobbyist
  • 15,888
  • 9
  • 46
  • 98
  • 1
    You should read [the documentation](http://maven.apache.org/plugins/maven-shade-plugin/usage.html) your pom is missing the "configuration part" –  Dec 03 '14 at 16:33
  • @RC - Been there, done that, no results. I've tried numerous different 'routes' as-well. I'll change my pom back to how the 'usage' page (Which I basically linked to in my question) shows the implementation. – Hobbyist Dec 03 '14 at 16:36
  • Question modified, producing the same result./ – Hobbyist Dec 03 '14 at 16:38
  • http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html --- I don't understand which one of these would be required, either. – Hobbyist Dec 03 '14 at 16:39
  • None, those are advanced use. The pom in you question looks good to me, you should try on the command line: `mvn clean package` and if that produce a jar with deps then your question is how to make eclipse run maven package goal after a build –  Dec 03 '14 at 16:42
  • I'm using eclipse directly for handling maven, I can't execute mvn commands on the command line. `mvn`is not recognized as an internal or external command, also, in my run configurations in eclipse I have "package" specified as the goal. – Hobbyist Dec 03 '14 at 17:03
  • see http://stackoverflow.com/questions/14026248/run-mvn-package-on-build-project-in-eclipse –  Dec 03 '14 at 17:08
  • @RC - Nope, didn't work. – Hobbyist Dec 03 '14 at 17:35
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/66143/discussion-between-rc-and-christian-tucker). –  Dec 03 '14 at 17:44
  • 1
    Silimar to `` vs ``, `` does not really declare a plugin to run. It should be under `project->build->plugins->plugin` instead of `project->build->pluginManagement->plugins->plugin` – Adrian Shum Dec 30 '16 at 02:33

0 Answers0