• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

How to include a local JAR file in maven build?

 
Bartender
Posts: 1832
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried the suggestion I saw online to include a local JAR in the IntelliJ's "libs" folder using this technique:



So, please, what's the trick to simply include a local JAR, right in the project itself, in the output "fat JAR" using Maven?

Spent hours researching this basic configuration issue ...

Thanks in advance,

- mike
 
Mike London
Bartender
Posts: 1832
17
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The only apparent solution to this issue is to add the JAR file to the local repository in the .m2 directory.

I did that and it worked.

It's amazing that the IDEs don't warn you that the entry in the pom.xml file won't be included, or, better yet, abstract the whole process and add the JAR file to the local .m2 repo for you (with appropriate dialogs for version and such).

- mike
 
Saloon Keeper
Posts: 13369
295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, never use the system scope.

Secondly, why do you want to create a fat jar?

If you *really* want to create one anyway, check out the Maven Shade Plugin.
 
Mike London
Bartender
Posts: 1832
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:First of all, never use the system scope.

Secondly, why do you want to create a fat jar?

If you *really* want to create one anyway, check out the Maven Shade Plugin.



I'm using the SpringBoot framework so naturally I would want a fat jar, that is, a jar with all the dependencies resolved.

How else would you build such an application?

Thanks,
 
Stephan van Hulst
Saloon Keeper
Posts: 13369
295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you can build the application just like you would regularly, and then release it as an archive containing the application and the dependencies separately. There's no need to pack all the dependencies into the application jar, especially since that makes the class loading process much more difficult.

In the Class-Path entry of the application manifest, you can specify the relative location of all dependencies. You can easily let Maven do this for you.
 
Mike London
Bartender
Posts: 1832
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Well, you can build the application just like you would regularly, and then release it as an archive containing the application and the dependencies separately. There's no need to pack all the dependencies into the application jar, especially since that makes the class loading process much more difficult.

In the Class-Path entry of the application manifest, you can specify the relative location of all dependencies. You can easily let Maven do this for you.



I thought the whole thing with SpringBoot and other micro-services is that you just have the single JAR you can ship here, ship there, run here, run there?

I'm sure there are all kinds of expert things you can do at some point, but I haven't read about what you're describing or seen it in a video (yet at least).

Thanks.

- mike
 
Stephan van Hulst
Saloon Keeper
Posts: 13369
295
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The point of Spring Boot is that you can bundle a web server with your application, regardless of whether or not you embed the web server in the application JAR.

Anyway, this page describes what you want: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html
 
Mike London
Bartender
Posts: 1832
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:The point of Spring Boot is that you can bundle a web server with your application, regardless of whether or not you embed the web server in the application JAR.

Anyway, this page describes what you want: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-build.html



Wow, lots of great info on that page, thanks!

Thanks,

- mike
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic