Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maven - Extract a jar from a zip file, and then use it for compile/build.

 
Gaurav Upadhyay
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings,

I have the following scenario :

1) A .rar file that contains jar files, and some of these jars i need to build my project with. The rar file is setup in the remote repository.
2) As a part of the Maven build, I need to extract the .rar file, place the contained jars at some location, and then use these jars to compile the project. There are other <dependencies> mentioned in the pom, and these jars should also be used with them while compiling.
3) I used the maven-dependency-plugin to extract the jars from the .rar, to the project build directory, but cannot get Maven to pick them up as dependencies while compiling (even system scope fails).

Please suggest on how to do extract from the rar, take the jars and use them to build, all in the same maven build.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the addjars plugin: http://code.google.com/p/addjars-maven-plugin/

Personally, I would extract the JARs from the RAR and load them into the remote repository and then reference them as dependencies. If the problem with that is that you are getting an update RAR almost daily from another team, then you can either tell them to also include the JARs in the repository when they do their build (its easy to do using the build-helper:attach-artifact goal - http://mojo.codehaus.org/build-helper-maven-plugin/attach-artifact-mojo.html), or you can create a separate POM that does the JAR extract just like you are doing now and then load the JARs into the repository. Heck, you could even do that in the same POM as for your build, placing the JARs in the local repository and using them from there. That would even work within a Hudson build slave.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic