2016-12-03 71 views
1

我的項目具有以下結構:Maven的:建立孩子的泊塢窗圖像投射

pom.xml 
    | 
    x----child1 
    |  | 
    |  x----pom.xml 
    | 
    x----child2 
     | 
     x----pom.xml 

有一個POM父親和兩個孩子勁歌。孩子的構建使用Spotify插件來生成項目的Docker鏡像。我的問題是,我如何從根目錄調用這兩個構建?我基本上需要調用Spotify插件在子模塊上構建。 我試圖用

mvn clean install 

但孩子與Maven的編譯器插件,而不是與泊塢窗 - Maven的插件建。

這是我的孩子們使用的生成:

<build> 
    <plugins> 
     <plugin> 
      <groupId>com.spotify</groupId> 
      <artifactId>docker-maven-plugin</artifactId> 
      <version>${spotify.plugin.version}</version> 
      <configuration> 
       <imageName>childImage</imageName> 
       <dockerDirectory>${project.build.directory}/../src/docker</dockerDirectory> 
       <resources> 
        <resource> 
         <targetPath>/</targetPath> 
         <directory>${project.build.directory}</directory> 
         <include>${project.build.finalName}.jar</include> 
        </resource> 
       </resources> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

在我已經定義的模塊,像這樣的POM父親。

<modules> 
     <module>child1</module> 
     <module>child2</module> 
    </modules> 

謝謝你的建議!

回答

0

您有幾種選擇來解決這個問題:

  1. 配置在父POM的部分插件,但默認情況下,插件配置跳過碼頭工具構建,並覆蓋子模塊中的內容以避免跳過
  2. 僅在子模塊中配置它,並將構建目標綁定到程序包階段。

我一直在使用[2]在孩子的pom.xml如下:

<build> 
    <plugins> 
    ... 
    <plugin> 
     <groupId>com.spotify</groupId> 
     <artifactId>docker-maven-plugin</artifactId> 
     <version>0.4.13</version> 
     <executions> 
     <execution> 
      <goals> 
      <goal>build</goal> 
      </goals> 
      <phase>package</phase> 
     </execution> 
     </executions> 
     <configuration> 
     <imageName>example</imageName> 
     <baseImage>example</baseImage> 
     <resources> 
      <resource> 
      <targetPath>/</targetPath> 
      <directory>target</directory> 
      <include>example.war</include> 
      </resource> 
     </resources> 
     </configuration> 
    </plugin> 
    ... 
    </plugins> 
</build> 
0

嘗試添加以下的插件:

<executions> 
    <execution> 
     <phase>install</phase> 
     <goals> 
      <goal>build</goal> 
     </goals> 
    </execution> 
</executions>