As far as I understand the build flow:
maven-assembly-plugin
builds/target/my-artifact-1.0-SNAPSHOT-jar-with-dependencies.jar
maven-jar-plugin
builds/target/my-artifact-1.0-SNAPSHOT.jar
(not sure why we need it)docker-maven-plugin
suppose to assembleartifact-with-dependencies
/target/my-artifact-1.0-SNAPSHOT-jar-with-dependencies.jar
Nevertheless, for some reason, it picks up the wrong jar artefact.
What am I missing? How to make it work?
pom.xml
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.20.1</version>
<extensions>true</extensions>
<configuration>
<images>
<image>
<name>my-artifact</name>
<build>
<from>java:8-jre</from>
<volumes>
<volume>/target</volume>
</volumes>
<entryPoint>
<exec>
<arg>java</arg>
<arg>-jar</arg>
<arg>/target/my-artifact-1.0-SNAPSHOT-jar-with-dependencies.jar</arg>
</exec>
</entryPoint>
<assembly>
<descriptorRef>artifact-with-dependencies</descriptorRef>
<targetDir>/target</targetDir>
<mode>dir</mode>
<!--<basedir>/target</basedir>-->
</assembly>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>docker-build</id>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>docker:start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker:stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>Client</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>Client</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
To cite the documentation, :
Which is not what you want.
What you want I think is to customize the assembly to something like this:
Bonus point: Have a look at Jib, it may better suit your needs if your are building an image for a Java project.