2015-10-28 74 views
7

我正在烘焙一個在運行時運行Maven任務的Docker鏡像。它看起來有點像這樣:使用Maven下載所有依賴項,插件依賴項,編譯器等?

ADD pom.xml /srv 
ADD src /srv/src 

WORKDIR /srv 
RUN mvn dependencies:go-offline scala:testCompile 

在運行時,我跑mvn gatling:execute運行一個負載測試工具。

我POM看起來是這樣的:

<project> 
    <dependencies> 
     <dependency> 
      <groupId>io.gatling</groupId> 
      <artifactId>gatling-core</artifactId> 
      <version>${gatling.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>io.gatling</groupId> 
      <artifactId>gatling-http</artifactId> 
      <version>${gatling.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>io.gatling</groupId> 
      <artifactId>gatling-app</artifactId> 
      <version>${gatling.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>io.gatling.highcharts</groupId> 
      <artifactId>gatling-charts-highcharts</artifactId> 
      <version>${gatling.version}</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>net.alchim31.maven</groupId> 
       <artifactId>scala-maven-plugin</artifactId> 
       <version>${scala-maven-plugin.version}</version> 
      </plugin> 
      <plugin> 
       <groupId>io.gatling</groupId> 
       <artifactId>gatling-maven-plugin</artifactId> 
       <version>${gatling-plugin.version}</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>execute</goal> 
         </goals> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

我希望有發生的是,當我最終運行mvn gatling:execute,我不想下載任何依賴關係,我希望他們全部出爐在構建時進入圖像。

但是,即使執行mvn dependencies:go-offline scala:testCompile也不會讓我一路走到那裏。運行gatling:execute仍然需要下載更多的依賴關係。

我該如何下載絕對一切 Maven需要到我的Docker鏡像中,以便在運行時不需要下載?

+0

您是否嘗試過將Gatling執行綁定到某個階段,並查看是否存在依賴關係:go-offline將其提取出來? –

+0

你有什麼建議?對不起,漫長的一天,不確定你的意思。 –

+0

喜歡的東西集成測試執行

回答

1

你不一定非得用maven插件來運行模擬,是嗎?您可以使用maven打包一個包含所有依賴項的jar並從中執行gatling runner。

+0

我知道。我需要一些東西_fast_,我不想整天使用maven assembly插件試圖讓Scala應用程序打包並正常運行。 –

0

您可以通過下載所有的依賴關係:mvn dependency:copy-dependencies

此之後,你所有項目的依賴將在./target/dependency/文件夾可用。