2

I have a appassembler-maven-plugin in my pom file and it used to work just fine - I can create a deployable package foe both windows and unix by running mvn assembly:assembly.

However it stop working for the new Spring boot project, complaining:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.6:single (default) on project rest: Failed to create assembly: Error creating assembly archive bin: You must set at least one file. -> [Help 1]

what went wrong? and what's difference b/w appassembler-maven-plugin and maven-assembly-plugin? I tried the latter, it seems throwing the same error (I don't recall the error details for that).

the plugin in my pom looks like:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>appassembler-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>assemble</goal>
                    </goals> 
                </execution>
            </executions>
            <configuration>
                <configurationSourceDirectory>src/main/resources</configurationSourceDirectory>
                <configurationDirectory>config</configurationDirectory>
                <copyConfigurationDirectory>true</copyConfigurationDirectory>
                <includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
                <assembleDirectory>${project.build.directory}/${project.name}</assembleDirectory>
                <extraJvmArguments>
                    -Xms128m -Xmx128m 
                </extraJvmArguments>
                <platforms>
                  <platform>unix</platform>
                </platforms>

                <programs>
                    <program>
                        <mainClass>com.mycompany.Application</mainClass>
                        <name>gs_rest.sh</name>
                    </program>
                </programs>
            </configuration>
        </plugin> 
J.E.Y
  • 1,173
  • 2
  • 15
  • 37
  • Your build still seems to be invoking maven-assembly-plugin and for that you need an assembly file. – Manish Oct 11 '16 at 03:02
  • First you are using an extreme old version of [appassembler-maven-plugin](http://www.mojohaus.org/appassembler/appassembler-maven-plugin/) current version is 1.10... – khmarbaise Oct 11 '16 at 06:30
  • *I have a appassembler-maven-plugin in my pom file and it used to work [...] by running mvn assembly:assembly.* This isn't possible. `mvn assembly:assembly` will use the `maven-assembly-plugin`, not the `appassembler-maven-plugin`. It will also use a deprecated goal of the Assembly Plugin. And if you're using Spring Boot, [take care of this](http://stackoverflow.com/a/39932921/1743880). You probably don't need either of them. – Tunaki Oct 11 '16 at 07:24

1 Answers1

0

For those hitting this page from a search engine:

The appassembler-maven-plugin is abandoned since 2015.

Please use the maven-assembly-plugin.

Below are 2 examples - with an explicit descriptor file, and one relying on a pre-defined descriptor.

        <!-- The executable JAR(s) -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>3.4.2</version>
            <executions>
                <execution>
                    <id>assembleDistZip</id><goals><goal>single</goal></goals><phase>package</phase>
                    <configuration>
                        <finalName>${project.artifactId}-${project.version}-dist</finalName>
                        <archive>
                            <manifest>
                                <mainClass>${mainClass}</mainClass>
                                <addClasspath>false</addClasspath>
                                <classpathPrefix>lib/</classpathPrefix>
                            </manifest>
                        </archive>
                        <descriptors><descriptor>src/build/assembly-dist.xml</descriptor></descriptors>
                    </configuration>
                </execution>

                <execution><phase>package</phase><goals><goal>single</goal></goals>
                    <configuration>
                        <appendAssemblyId>false</appendAssemblyId>
                        <finalName>${project.artifactId}</finalName>
                        <outputDirectory>${project.build.directory}/dist</outputDirectory>
                        <descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs>
                        <archive>
                            <manifest> <!-- Jar - MANIFEST.MF options. -->
                                <addClasspath>false</addClasspath>
                                <mainClass>${mainClass}</mainClass>
                                <classpathPrefix>lib/</classpathPrefix>
                            </manifest>
                            <manifestEntries>
                                <Release-Version>${project.version}</Release-Version>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </execution>
            </executions>
        </plugin>
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277