Reputation: 677
I'm using the ms-data-core-api library for a project. So I made a few tweaks around, recompiled it using mvn package
which gave me a different .jar file, and installed it using mvn install:install-file
so I could use it in my project's pom
file. So far, so good. However, when I tried to use it on my project, I got some cannot be resolved
issues.
By unpacking the 2.0.5 release jar, which correctly works however doesn't have my modifications, I realized that it has all the dependencies inside of it, although mine doesn't (it has only the compiled library).
I'm not experienced with Maven, so what I did is:
2.0.5
jar content, containing all files2.0.6
build folder (created with mvn instal:install-file
)ms-data-core-api
part with my compiled binariesjar cf myJar.jar tweaked-2.0.5-folder
. It still doesn't work, giving me the same cannot be resolved
error on the classes that I need.
By unpacking the latest jar created in step 4, I realized that it has all the 2.0.5
content enclosed in a folder (with the same name as tweaked-2.0.5-folder
.
Am I missing something obvious here? Am I packaging back to jar
wrongly? Or maybe is there a correct way to mvn package
the library so that it builds all the dependencies together?
Upvotes: 0
Views: 193
Reputation: 2801
Yes, there is a correct way to do it. I suggest here 2 options
You should run mvn install
instead of mvn install:install-file
. It will maintain the pom.xml
of ms-data-core-api in your PC's Maven repo .m2
, and when your project refers to ms-data-core-api, your project will know all of its dependencies (transitive dependencies)
If you still want to make a fat Jar file which contains all dependencies, you can use the Maven Assembly Plugin. As I see from this pom.xml
, they already had <artifactId>maven-assembly-plugin</artifactId>
.
Instead of mvn package
, you need to run: mvn clean assembly:single
Upvotes: 2