Why does "mvn assembly:single" create a fat jar with just the assemblies and not my code?

Justin Dearing picture Justin Dearing · Oct 22, 2011 · Viewed 16.3k times · Source

I have a maven project I created with spring roo. When I run mvn assembly:single I get a fat jar with all the dependencies, but not the actual code I wrote. Here is my maven-assembly-plugin configuration from my pom.xml:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.2.1</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>net.justaprogrammer.poi.cleanser.Cleanser</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>

What am I doing wrong?

Answer

Justin Dearing picture Justin Dearing · Oct 22, 2011

The solution is to add the single goal to the package phase of the project life cycle. This means you have to add the following xml under the configuration section:

            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>