Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download all dependencies, plugin dependencies, compilers, etc. with Maven?

I'm baking a Docker image which runs a Maven task at runtime. It looks kind of like this:

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

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

At runtime, I'm running mvn gatling:execute to run a load testing utility.

My POM looks like this:

<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>

What I want to have happen is that when I ultimately run mvn gatling:execute, I don't want to have to download any dependencies, I'd like them all baked into the image at build time.

However, even executing mvn dependencies:go-offline scala:testCompile doesn't get me all of the way there. Running gatling:execute still requires downloading more dependencies.

How can I download absolutely everything that Maven requires into my Docker image, so that no downloads at runtime are required?

like image 302
Naftuli Kay Avatar asked Oct 28 '15 01:10

Naftuli Kay


People also ask

How do I download all dependencies of a project?

Summary. You can use the Maven Dependency Plugin to download dependencies. Run mvn dependency:copy-dependencies , to download all your dependencies and save them in the target/dependency folder. You can change the target location by setting the property outputDirectory .

How do I re download all Maven dependencies in eclipse?

In Maven, you can use Apache Maven Dependency Plugin, goal dependency:purge-local-repository to remove the project dependencies from the local repository, and re-download it again.

Does Maven download dependencies of dependencies?

When you run a Maven build, then Maven automatically downloads all the dependency jars into the local repository. It helps to avoid references to dependencies stored on remote machine every time a project is build.


1 Answers

You don't necessarily have to run the simulation with the maven plugin, do you? You can use maven to package a jar with all dependencies and execute the gatling runner from it.

like image 101
Mykola Gurov Avatar answered Sep 28 '22 06:09

Mykola Gurov