I have a multi-module project where I want to download all dependencies for offline use. I do this using the mvn dependency:go-offline
goal. In the project, there is one module X that depends on another module Y. Since the dependency:go-offline
command does not build the modules, there is an error when building X that the dependency Y is not found:
$ mvn dependency:go-offline -Dmaven.artifact.threads=30
Failure to find se.cust.id:Y:jar:1.2.3-SNAPSHOT in https://mvn.com.com/repository/com-snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of com-snapshots has elapsed or updates are forced
I've tried to make Maven ignore this dependency by running
$ mvn dependency:go-offline -DexcludeArtifactIds=Y
But this results in the same error. What is the proper way of excluding dependencies here?
You can use Exclude command from the context menu in the Maven dependency diagram to quickly exclude the specified dependency from POM and the respective tool windows. The dependency is also excluded from the Project and Maven tool windows.
There we can exclude all transitive dependencies without specifying groupId and artifactId of the dependencies. So need to use astric(*) character as groupid and artifactid of the dependency. This wildcard transitive dependencies ignoring is available with maven 3.2.
The go-offline goal of the Maven Dependency plugin downloads all the required dependencies and plugins for the project, based on the pom file. The –o option tells Maven to work offline and not check ...
You could change those classes and define them in a different jar/module which should be included as a dependency before the jar that supplies the dependency where your class to be excluded resides (Marker. class). Maven remembers the classpath ordering from version 2.0.
Adding maven-dependency-plugin
to the parent pom.xml
worked for me
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
</plugin>
I ran across the problem while encapsulating a maven build with a Dockerfile (like so: http://whitfin.io/speeding-up-maven-docker-builds/)
My workaround so far is to just let the dependency-fetch fail, which looks like this in my Dockerfile:
RUN mvn -B dependency:go-offline -DexcludeGroupIds=my.company || true
I can tell that the -DexcludeGroupIds
doesn't work because I get an error:
Failure to find my.company:subproject-built-here:jar:1-SNAPSHOT in http://packages.confluent.io/maven/ was cached in the local repository, resolution will not be reattempted until...
Enough of the dependencies are downloaded and cached that I still see a speedup later on, but I'd prefer to prevent the error rather than ignoring it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With