Maven: assembly-plugin is not run at all

I would recommend to create a uberjar by using the maven-shade-plugin, cause it's intention is exactly that purpose. You can do that with the maven-assembly-plugin as well.

So after taking a look into your pom i understand the problem. First you defined the maven-assembly-plugin in the pluginManagement block which will NOT execute a plugin furthermore you have defined the maven-assembly-plugin as a dependency separately which is superfluous. Which means simply remove the following from your pom:

<dependency>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-assembly-plugin</artifactId>
   <version>2.3</version>
   <type>maven-plugin</type>
</dependency>

You should define the maven-assembler-plugin like this:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            ...all your configuration here..
        </plugin>
    </plugins>
</build>

Furthermore i've seen many repository definition which should be handled by repository manager instead. About the repositories in your pom i can recommend reading the sonatype information furthermore you should think about some else will use the project behind a proxy etc. than he has to change you pom to get i working or can't use it cause you defined repositories in your pom he can't reach.


I had one other view on this problem, that helped me to resolve the %subj%. If you dig the articles about how to make executable jar and jar with dependencies, they usually provide code snippets, that a newbie tries to copy paste to their pom.xml. Those, that do not know much about the actual structure of pom.xml file (aka me) it is quite difficult task. I ended with this (not working) solution:

 <project>
  ......

 <build>
   <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>3.2.0</version>
          <configuration>
            ............
          </configuration>

          <executions>
            ..............
          </executions>
        </plugin>
      </plugins>
   </pluginManagement>
  </build>
</project>

If you know what pluginManagement does, you would not do the same mistake. But for me it was a big unknown and if you never used parent projects, make sure you do not fall into the same trap. With some adjustments here is a working maven-assembly-plugin setup (with the right context in pom.xml)

<?xml version="1.0" encoding="UTF-8"?>

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.blah.blah</groupId>
  <artifactId>some-artifact</artifactId>
  <version>1.0-SNAPSHOT</version>

  <dependencies>
   ...
  </dependencies>

  <build>
      <plugins>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>3.2.0</version>
          <configuration>
            <appendAssemblyId>false</appendAssemblyId> <!-- nicer looking jar name -->
            <archive>
              <manifest>
                <addClasspath>true</addClasspath>
                <mainClass>com.blah.blah.YourMainClass</mainClass>
              </manifest>
            </archive>
            <descriptorRefs>
              <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
          </configuration>

          <executions>
            <execution>
              <id>make-assembly</id> 
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
  </build>
</project>

I want to offer one more suggestion of an error that I had: My xml looked like this:

<plugins>
    <plugin>
        <groupId>org.maven...</groupId>
        <artifactId>myArtifact</artifact>
        <configuration>
            <descriptorRefs>....</descriptorRefs>
            ...
            <executions>
                <execution>
                    <phase>package</phase>
                    ....
                </execution>
            </executions>
        </configuration>
    </plugin>
</plugins>

Whereas the <executions> block should be a sibling of the <configuration> block, not a child. Soon as I fixed that, my plugin started executing within my build again.


Maybe you can use the shade plugin instead (that's the one I use).

Note the dependencies are included in the final JAR.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <finalName>standalone-${artifactId}</finalName>
                <archive>
                    <manifest>
                        <mainClass>com.mypckg.Launcher</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

Regards