aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes How to avoid using systemPath and make maven read jars from /lib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "How to avoid using systemPath and make maven read jars from /lib" Watch "How to avoid using systemPath and make maven read jars from /lib" New topic
Author

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

Eric Lopez-Fernandez
Greenhorn

Joined: Oct 13, 2011
Posts: 17
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

Joined: Jun 25, 2001
Posts: 16019
    
  20

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

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.


JBoss In Action
Gopi Chella
Ranch Hand

Joined: Apr 26, 2010
Posts: 53
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.


SCJP 1.5
Eric Lopez-Fernandez
Greenhorn

Joined: Oct 13, 2011
Posts: 17
Thank you all very much for your help!
 
 
subject: How to avoid using systemPath and make maven read jars from /lib