I like to skip a maven plugin by setting the skip-docker-build
property via a profile.
<profiles>
<profile>
<id>skip-docker-build</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<skip-docker-build>true</skip-docker-build>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<configuration>
<skip>${skip-docker-build}</skip>
</configuration>
</plugin>
</plugins>
</build>
This all works well, when I activate the profile, the docker build is skipped. However, when I put the profiles section in the parent pom it's no longer working. How to make this work when the profile is defined in the parent pom?
I solved the problem by swapping the logic. I don't have a skip-docker-build
, but a docker-build
profile. The plugin is wrapped in this profile and if I don't want to run it then I disable it as follows
mvn clean install -P !docker-build
<profiles>
<profile>
<id>docker-build</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>