【问题标题】:Download all dependencies, plugin dependencies, compilers, etc. with Maven?使用 Maven 下载所有依赖项、插件依赖项、编译器等?
【发布时间】:2016-01-27 15:31:46
【问题描述】:

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

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 映像中,这样就不需要在运行时进行下载?

【问题讨论】:

  • 您是否尝试过将 Gatling 执行绑定到一个阶段,并查看 dependencies:go-offline 是否能够接受它?
  • 你有什么建议?很抱歉,漫长的一天,不确定您的意思。
  • 类似于 integration-testexecute
  • 问题是我不能运行gatling:execute 没有大量pwning 端点;)
  • 这是可以理解的,但如果您不经过 mvn package 阶段,这不是问题。不管怎样,如果 Gatling 依赖项绑定到一个阶段,maven 依赖插件是否找到了它们?

标签: maven docker gatling


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

    您不一定必须使用 maven 插件运行模拟,是吗?您可以使用 maven 打包一个包含所有依赖项的 jar,并从中执行 gatling runner。

    【讨论】:

    • 我知道。我需要 fast 的东西,我不想整天忙于使用 maven 程序集插件来尝试将 Scala 应用程序打包并正常运行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-22
    • 2020-04-30
    • 1970-01-01
    • 2018-08-29
    • 2016-09-30
    • 2015-11-05
    相关资源
    最近更新 更多