'Maven is downloading jars of its dependency
I have a pom file that has a single dependency. I want maven to download the dependency and wrap it in a new jar. However, when I run mvn clean package, it looks for the dependency, finds the dependency, and then looks at it's pom file and attempts to download all dependency of that dependency. How do I tell maven to not look at that dependencies' pom file and just download it?
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.eddie.app</groupId>
<artifactId>app-wrapper</artifactId>
<version>1.0.0</version>
<repositories>
<repository>
<id>eddie</id>
<url>https://gitlab.com/api/v4/projects/22513588/packages/maven</url>
</repository>
<repository>
<id>eddie-snapshots</id>
<url>https://gitlab.com/api/v4/projects/32301501/packages/maven</url>
</repository>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.nxtech.batch.Processor</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<goals>install</goals>
<preparationGoals>install</preparationGoals>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.eddie.myApp</groupId>
<artifactId>myAwesomeReusableApp</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>eddie</id>
<url>https://gitlab.com/api/v4/projects/30591404/packages/maven</url>
</repository>
<snapshotRepository>
<id>eddie-snapshots</id>
<url>https://gitlab.com/api/v4/projects/32301501/packages/maven</url>
</snapshotRepository>
</distributionManagement>
</project>
Error that gets generated:
Here is the error that gets generated:
$ mvn clean package
Apache Maven 3.8.3 (ff8e977a158738155dc465c6a97ffaf31982d739)
Maven home: C:\apache-maven-3.8.3
Java version: 1.8.0_292, vendor: Red Hat, Inc., runtime: C:\java-1.8.0-openjdk-1.8.0.292-2.b10.dev.redhat.windows.x86_64\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.eddie.app:app-wrapper >-----------------
[INFO] Building app-wrapper 1.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/3.2.0/maven-dependency-plugin-3.2.0.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/3.2.0/maven-dependency-plugin-3.2.0.pom (18 kB at 35 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/34/maven-plugins-34.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/34/maven-plugins-34.pom (11 kB at 114 kB/s)
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/3.2.0/maven-dependency-plugin-3.2.0.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/3.2.0/maven-dependency-plugin-3.2.0.jar (205 kB at 888 kB/s)
[INFO] Downloading from eddie: https://gitlab.com/api/v4/projects/22513588/packages/maven/com/ivans/connect/Connect/8.6.4g-SNAPSHOT/maven-metadata.xml
[INFO] Downloading from eddie-snapshots: https://gitlab.com/api/v4/projects/32301501/packages/maven/com/ivans/connect/Connect/8.6.4g-SNAPSHOT/maven-metadata.xml
[INFO] Downloaded from eddie-snapshots: https://gitlab.com/api/v4/projects/32301501/packages/maven/com/ivans/connect/Connect/8.6.4g-SNAPSHOT/maven-metadata.xml (954 B at 1.5 kB/s)
[INFO] Downloading from central: https://repo1.maven.org/maven2/io/grpc/grpc-api/maven-metadata.xml
[INFO] Downloading from eddie-snapshots: https://gitlab.com/api/v4/projects/32301501/packages/maven/io/grpc/grpc-api/maven-metadata.xml
[INFO] Downloading from eddie: https://gitlab.com/api/v4/projects/22513588/packages/maven/io/grpc/grpc-api/maven-metadata.xml
[INFO] Downloaded from central: https://repo1.maven.org/maven2/io/grpc/grpc-api/maven-metadata.xml (2.1 kB at 7.2 kB/s)
[INFO] Downloading from eddie: https://gitlab.com/api/v4/projects/22513588/packages/maven/com/google/errorprone/error_prone_annotations/maven-metadata.xml
[INFO] Downloading from eddie-snapshots: https://gitlab.com/api/v4/projects/32301501/packages/maven/com/google/errorprone/error_prone_annotations/maven-metadata.xml
[INFO] Downloading from central: https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/maven-metadata.xml
[INFO] Downloaded from central: https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/maven-metadata.xml (1.6 kB at 20 kB/s)
[INFO] Downloading from eddie: https://gitlab.com/api/v4/projects/22513588/packages/maven/org/apache/commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.pom
[INFO] Downloading from eddie-snapshots: https://gitlab.com/api/v4/projects/32301501/packages/maven/org/apache/commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.pom
[INFO] Downloading from central: https://repo1.maven.org/maven2/org/apache/commons/com.springsource.org.apache.commons.httpclient/3.1.0/com.springsource.org.apache.commons.httpclient-3.1.0.pom
[WARNING] The POM for org.apache.commons:com.springsource.org.apache.commons.httpclient:jar:3.1.0 is missing, no dependency information available
[WARNING] The artifact javax.xml:jaxrpc:jar:1.1 has been relocated to javax.xml:jaxrpc-api:jar:1.1
[INFO] Downloading from eddie: https://gitlab.com/api/v4/projects/22513588/packages/maven/org/springframework/boot/spring-boot-starter-parent/1.2.1.RELEASE/spring-boot-starter-parent-1.2.1.RELEASE.jar
[INFO] Downloading from eddie-snapshots: https://gitlab.com/api/v4/projects/32301501/packages/maven/org/springframework/boot/spring-boot-starter-parent/1.2.1.RELEASE/spring-boot-starter-parent-1.2.1.RELEASE.jar
[INFO] Downloading from central: https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-parent/1.2.1.RELEASE/spring-boot-starter-parent-1.2.1.RELEASE.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.727 s
[INFO] Finished at: 2022-01-13T09:48:53-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project com.eddie.app:app-wrapper Could not resolve dependencies for project com.eddie.app:app-wrapper:jar:1.0.0: Could not find artifact org.springframework.boot:spring-boot-starter-parent:jar:1.2.1.RELEASE in eddie (https://gitlab.com/api/v4/projects/22513588/packages/maven) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project test-dl-carrier: Could not resolve dependencies for project com.ivans.download:test-dl-carrier:jar:1.1.3: Could not find artifact org.springframework.boot:spring-boot-starter-parent:jar:1.2.1.RELEASE in eddie (https://gitlab.com/api/v4/projects/22513588/packages/maven)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:269)
at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies (LifecycleDependencyResolver.java:147)
Solution 1:[1]
You can use exclusions on the dependency to avoid the download of the transitive dependencies.
But usually, these transitive dependencies are needed to run your JAR, so you should be really be sure you don't need them.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | J Fabian Meier |
