This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I have two Maven projects, A which is the main program and B which is a common library. These projects have a common parent C, which is another Maven project.
I want, during the packaging phase, do the following:
1. Copy the JAR file of project A to a directory "distributable" in the target directory.
2. Copy all the libraries that project A depends on to "distributable/lib".
3. Set the classpath of the JAR file in step 1 to include all libraries copied in step 2.
Problems arise when I try to use the maven-dependency-plugin in step 2, however if I exclude the artifactId of project B, things work fine, except for the JAR file of project B not ending up in the lib directory, of course.
I have read most of "Maven Definitve Guide" and a lot of web pages without finding the solution, so I now ask if anyone here knows how to do this?
Many thanks in advance!
Good question and having answered a fair amount of questions, I should have known better than to omit vital information!
It seems like the plugin is trying to copy from the classes directory of the project B instead of the JAR.
Here is the error message I get when trying to package project A:
The following mojo encountered an error while executing:
brought in via: POM
While building project:
From file: /Somepath/mainproject/pom.xml
Reason: Error copying artifact from /Somepath/libproject/target/classes to /Somepath/mainproject/target/dist/lib/classes
I seem to have solved it by changing the <packaging> of project B, the library project, to "pom" instead of the original value, which was "jar".