I have both deploy plugin and dockerize plugin in my Maven project.
Deploy plugin,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
</execution>
</executions>
</plugin>
Dockerize plugin,
<profiles>
<profile>
<id>docker</id>
<properties>
<assembly.skipAssembly>true</assembly.skipAssembly>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>${version.docker.plugin}</version>
<executions>
<execution>
<id>dockerize-app</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${docker.image-prefix}${project.artifactId}</repository>
<tag>${project.version}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.artifactId}.war</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I have following use cases.
To achieve this, I added Docker plugin under profile. So that, Docker image will be deployed on passing the profile name.
mvn deploy
The above command will deploy just the artifacts.
mvn deploy -P docker
The above command will deploy artifacts & Docker image.
But, I am unable to just deploy the Docker image.
To just deploy the Docker image, I am adding the below config in the deploy plugin,
<configuration>
<skip>true</skip>
</configuration>
Or, setting default-deploy to none.
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
The above 2 approaches needs pom change.
Is there any other better approach? Or, is it possible with the Maven arguments to skip deploy?
I think you can do what you want by using properties instead of profiles.
Just remove the docker
profile and put the configuration directly inside your POM, and the following commands should work :
mvn -Dmaven.deploy.skip deploy
to deploy only Docker images (default deploy
phase is skipped)mvn -Ddockerfile.skip deploy
to deploy only artifacts to your repository manager. Options to skip goals (like dockerfile.skip
) are described on the dockerfile-maven-plugin
documentation
mvn deploy
to deploy both (artifacts and Docker images)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With