Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Eric Lopez-Fernandez
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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!
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Likes 2
  • Mark post as helpful
  • send pies
  • 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.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
Gopi Chella
Ranch Hand
Posts: 53
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thank you all very much for your help!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic