Search code examples
javamavenmaven-assembly-plugin

Execute assembly:single goal during package phase


Below is the pom.xml. When I Try running it with mvn package, the fat jar is not getting built. But mvn assembly:single builds the fat jar.

What am I doing wrong here?

<build>
    <sourceDirectory>src</sourceDirectory>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <archive>
                    <manifest>
                    <mainClass>com.xyz.main.MainHandler</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>
    </pluginManagement>
</build>

Solution

  • So, after removing the maven-assembly-plugin from the pluginManagement tags, it worked.

    Need clarity checkout this.