简体   繁体   中英

Maven Dependency Plugin command line option to EXCLUDE optional dependencies when downloading dependencies to local directory

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM