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

Naf*_*Kay 7 maven gatling docker

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

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

WORKDIR /srv
RUN mvn dependencies:go-offline scala:testCompile
Run Code Online (Sandbox Code Playgroud)

在运行时,我正在运行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>
Run Code Online (Sandbox Code Playgroud)

我想要发生的是,当我最终运行时mvn gatling:execute,我不想下载任何依赖项,我希望它们都在构建时加入到映像中.

然而,即使执行mvn dependencies:go-offline scala:testCompile也不会让我一路走来.运行gatling:execute仍需要下载更多依赖项.

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

Myk*_*rov 1

您不一定需要使用 Maven 插件来运行模拟,对吗?您可以使用 maven 打包包含所有依赖项的 jar 并从中执行 gatting 运行程序。