使用Maven下载所有依赖项,插件依赖项,编译器等?

我正在烘焙一个在运行时运行Maven任务的Docker镜像。 它看起来像这样:

ADD pom.xml /srv ADD src /srv/src WORKDIR /srv RUN mvn dependencies:go-offline scala:testCompile 

在运行时,我正在运行mvn gatling:execute以运行负载testing实用程序。

我的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 ,我不想下载任何依赖关系,我希望在构build时将它们全部映射到映像中。

但是,即使执行mvn dependencies:go-offline scala:testCompile并没有让我在那里。 运行gatling:execute仍然需要下载更多的依赖关系。

我如何才能将所有 Maven需要的东西下载到我的Docker镜像中,以便在运行时不需要下载?

你不一定非得用maven插件来运行模拟器,是吗? 你可以使用Maven打包一个包含所有依赖关系的jar,并从中执行gatling runner。

您可以使用以下命令下载所有依赖项: mvn dependency:copy-dependencies

在此之后,所有项目的依赖项都将在./target/dependency/文件夹中提供。