There are very few documentations and examples on this (those exists are useless).
I would like to copy all the dependencies of a given pom.xml file. Usually, I can use mvn dependency:copy-dependencies
on command line or use maven-dependecy-plugin
configuration in the pom file.
However, I would like to do it programmatically on a given pom.xml file. So far, I figured that I will need to use MavenCli
MavenCli cli = new MavenCli();
cli.doMain(new String[]{"clean", "dependency:copy-dependencies", "-DincludeScope=runtime"}, "C:\\workspace\\gui", null, null);
where "C:\\workspace\\gui"
is a directory containing a pom.xml
but the above code gives me the following error:
[ERROR] Failed to execute goal on project test-pom: Could not resolve dependencies for project gigadot:test-pom:jar:0.5-SNAPSHOT: Failed to collect dependencies for [commons-lang:commons-lang:jar:2.6 (compile), commons-io:commons-io:jar:2.0.1 (compile), org.apache.commons:commons-exec:jar:1.1 (compile), org.apache.commons:commons-math:jar:2.2 (compile), xom:xom:jar:1.2.5 (compile), log4j:log4j:jar:1.2.16 (provided)]: Failed to read artifact descriptor for org.apache.commons:commons-math:jar:2.2: Could not transfer artifact org.apache.commons:commons-math:pom:2.2 from/to central (http://repo1.maven.org/maven2): No connector available to access repository central (http://repo1.maven.org/maven2) of type default using the available factories -> [Help 1]
Does anyone know how to solve this problem?