Home > database >  Disable spotify docker-maven-plugin in parent pom
Disable spotify docker-maven-plugin in parent pom

Time:02-01

I am using a parent POM like below

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.spotify</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <version>${docker-maven-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- for docker -->
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                    ...
                </configuration>
            </plugin>
        </plugins>
    </build>

I use M1 Mac, and spotify docker-maven-plugin has errors while build dockerfile.
So, child POM uses fabric8 docker-maven-plugin like below.

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.groupExample</groupId>
        <artifactId>parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <!-- Docker maven plugin -->
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.40.3</version>
                <configuration>
                   ...
                </configuration>

                <!-- activation -->
                <dependencies>
                    <dependency>
                        <groupId>javax.activation</groupId>
                        <artifactId>activation</artifactId>
                        <version>1.1.1</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>

But when I use commands like mvn clean install docker:build docker:push, maven uses spotify docker plugin, not fabric8 docker plugin. So, it makes errors and dockerfile failed to build.
I applied solutions in this site also, but it does not work neither. Such as,

            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default</id>
                        <phase>none</phase>
                    </execution>
                </executions>
                <inherited>false</inherited>
            </plugin>
 <configuration>
      <skip>true</skip>
 </configuration>

How can I build dockerfile without changing parent POM at M1 Mac?

CodePudding user response:

  <build>
   <plugins>
      <!-- Docker maven plugin -->
      <plugin>
        <groupId>io.fabric8</groupId>
      <artifactId>docker-maven-plugin</artifactId>
     <version>0.40.3</version>
     <executions>
        <execution>
           <phase>package</phase>
           <goals>
              <goal>build</goal>
              <goal>push</goal>
           </goals>
        </execution>
     </executions>
     <configuration>
        ...
     </configuration>

     <!-- activation -->
     <dependencies>
        <dependency>
           <groupId>javax.activation</groupId>
           <artifactId>activation</artifactId>
           <version>1.1.1</version>
        </dependency>
     </dependencies>
  </plugin>

CodePudding user response:

Finally, I found the solution to build dockerfile.
It should skip execution by spotify and also execute fabric8 plugin.

   <build>
        <plugins>

            <!-- disable spotify -->
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                    <skipDocker>true</skipDocker>
                </configuration>
            </plugin>

            <!-- Docker maven plugin -->
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.40.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                            <goal>push</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    ...
                </configuration>

                <!-- activation -->
                <dependencies>
                    <dependency>
                        <groupId>javax.activation</groupId>
                        <artifactId>activation</artifactId>
                        <version>1.1.1</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
  • Related