Reputation: 746
I figured that one can easily download all dependencies including transitive ones for a given artifact using the maven dependency plugin command line. For example the below two commands can be used to download & copy all dependencies for artifact atmosphere-runtime, including only the compile & provided dependencies and excluding test ones,
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:get -DgroupId=org.atmosphere -DartifactId=atmosphere-runtime -Dversion=2.3.3 -Dtype=pom
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:copy-dependencies -f <path-to-local-repo>\org\atmosphere\atmosphere-runtime\2.3.3\atmosphere-runtime-2.3.3.pom -DoutputDirectory=<path-to-target-dir> -DincludeScope=compile
But the problem with the above is that it includes dependencies which are tagged as optional. Continuing with the example above, the artifact "grizzly-framework-http" which is tagged as an optional dependency for "atmosphere-runtime" gets downloaded/copied along with all its transitive dependencies.
Is there a way to filter out or exclude such dependencies which are tagged as "(optional)" when downloading dependencies?
Upvotes: 1
Views: 2365
Reputation: 32507
Why are you downloading your dependencies manually? Use a POM file to describe your project. You can add dependency exclusions and the dependencies will be downloaded as you require and will be available from your local repository.
Here are some helpful references: http://maven.apache.org/pom.html#Exclusions
Upvotes: 1