0

I have read numerous posts regarding this, and I was still not able to find a clear-cut answer.

We have the need to use a proprietary SDK in our maven project and this SDK contains ~315 jar files that are needed for around 30 lines of code (SAP product). Every answer I read dealt with adding individual jars to your local maven repo. That is fine and I understand that, but is it possible to add an entire directory of libraries. These libraries are only needed for compiling the project since they are already on the classpath of the target server (They would all be scoped as provided in a pom).

I've tagged Netbeans 8 since that is the IDE I am using, so if anyone knows a hack to get a maven project in netbeans compiled using libraries on Netbeans classpath that would be a good solution as well...

TXAggie00
  • 45
  • 5
  • The important piece of missing information here is - what is the SAP product? There may be existing solutions for that - for example this post provides a way to use maven to build applications for SAP HANA Cloud - http://scn.sap.com/community/developer-center/cloud-platform/blog/2014/05/27/building-java-applications-with-maven – Nate Sep 22 '16 at 19:59
  • 1
    Isn't this what you need: http://stackoverflow.com/questions/22508433/how-to-add-maven-dependency-jar-file-from-the-lib-folder Also dependency should have "provided" type if it is available on the deployed server – Dennis R Sep 22 '16 at 19:59
  • @DennisR That is a single jar file. Again, wouldn't I need to do that an additional 314 more times? – TXAggie00 Sep 22 '16 at 20:21
  • @Nate - SAP Business Objects 4.2. I used several search tools to see if all of them existed in any repo with no luck... – TXAggie00 Sep 22 '16 at 20:22

2 Answers2

0

JAR's are just java .class organized in folders and Zipped. Extract all those 315 JARs to somewhere, thus merging all of their content, and then Zip it again to one single fat JAR file. Add this fat JAR to your local repository as you have read elsewhere.

This other question can help you with the JAR merging thing: How to combine two Jar files

Community
  • 1
  • 1
Rafael Odon
  • 1,211
  • 14
  • 20
0

Although there are many messy workarounds for this, the ideal would be to let the compilation fail and search for the missing compile jars using a search utility like agent ransack you can search within the jars in that directory for the missing classes referenced in the compiler errors. As you find the jars you need, add them as dependencies with the scope of provided.

A less clean option would be to zip all of the jars, use the dependency plugin to unpack them to a folder and add that folder to the classpath of the build, then remove them or exclude them from the final package.

eisbaer
  • 328
  • 1
  • 3
  • 10