• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to avoid using systemPath and make maven read jars from /lib

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am just getting familiar with maven and the project that I'm working on requires me to leave a jar inside of the lib folder. I have accomplished that maven "reads" it when compiling, however, I understand I'm not doing it in the best way. Here is the portion of my POM that does that:

<dependency>
<groupId>org.XLogger</groupId>
<artifactId>XLogger</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/java/lib/XLogger.jar</systemPath>
</dependency>

When I run mvn compile I get the following message:

'dependencies.dependency.systemPath' for org.XLogger:XLogger:jar should not point at files within the project directory, ${project.basedir}/java/lib/XLogger.jar will be unresolvable by dependent projects @ line 84, column 16

Does anybody know a better way to make maven read some jars inside of the lib folder without using systemPath?

Any help will be greatly appreciated!
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not only does systemPath not like having the jars inside of the Maven project subtree, it doesn't like relative paths or (IIRC) variable substitutions in the path root - only plain vanilla absolute filesystem paths.

This can be annoying, but Maven does have its reasons.

You will be far better off not fighting them. Install the JAR to a Maven repository and make a normal dependency of it.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why does the project require you to leave the JAR in the lib folder? What would happened if it was not there? Saying that the resulting code will not run because of a missing class exception is not a valid reason, by the way - there is a huge difference between dealing with the classpath for a build, which Maven handles automatically, and for packaging/runtime.

Last year, when I migrated a number of projects to use Maven (also migrated the sources form CVS to Subversion), the first thing I did was to get rid of the lib directory. No one has missed it.
 
Ranch Hand
Posts: 53
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of placing the jar file in the system path you can check out that particular Xlogger maven context from SVN or CVS and do clean install(skip tests) on your local, by doing this you will get the XLogger.jar in your local repository.
 
Eric Lopez-Fernandez
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all very much for your help!
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic