docker-maven-plugin
docker-maven-plugin copied to clipboard
Packaging docker / docker-build should put something into the maven repository
Description
When doing a "mvn install" for a packaging "docker-build" or "docker", nothing at all is put into the maven repository. Of course, the primary goal is building the docker image, but if you have a multi module build with maven you'd need some way to declare the dependencies to maven so that there is a sensible build order. So, something like the docker-info artifact of the dockerfile-maven-plugin would come handy. That said: a JAR with some basic information is actually generated - it just isn't put into the maven repository yet.
Info
- docker-maven-plugin version : 0.39.1
- Maven version (
mvn -v
) : 3.8.1 - Docker version : 20.10.13, build a224086
Workaround for now, if someone has the same problem: if you add this to the pom.xml, it uploads at least something to the maven repositories - the pom artifact and a docker artifact.
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
If you want the JAR in there, this would help:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.build.finalName}.jar</file>
<type>jar</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
Are there any good practices for making sure the right build order if you've got several docker images built in a multi module reactor project? That workaround works, but it'd be no good for actual releases, as you don't want to litter maven central with such fake artifacts. :-)