Search code examples
xmlmavencopyexecute

Execute maven pom script manually


I have an application, which needs some jars from the local maven repository. How should I write and how would I execute a (pom.)xml file that would copy the jars from the repository to my application folder? Is that possible with maven?

UPDATE:

The reason I would require to copy the jars, is due to an old design of the application I'm integrating into maven, so the immediate solution I require is to copy the jars into the application installation folder, so the classes would be imported to the application dynamically, which is how the application is designed.

That been said, should there be any changes to the pom.xml? or just standard pom, plus the maven-dependency-plugin? How would I execute the dependency copy using the pom which will be in the application folder, using CLI?

UPDATE:

I've managed to do as I wanted, now the thing is I'm getting greedy, I would also like to copy the sources with the project jar... how can I achieve that?

Thanks in advance,

Adam Zehavi.


Solution

  • You have to provide a standard maven pom.xml file and declare your needed dependencies in it. You will find enough information on the maven homepage for this.

    After that you can use Maven Dependency plugin to copy the decpendencies from the repository. Just type (without any further pom.xml configuration)

    mvn dependency:copy-dependencies
    

    and the project dependencies will be copied to the folder

    target\dependency