File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven build dependencies from .classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Maven build dependencies from .classpath" Watch "Maven build dependencies from .classpath" New topic

Maven build dependencies from .classpath

C H Kiran

Joined: May 14, 2005
Posts: 4
1. Can maven create dependencies in pom.xml, taking input as (looking at) the .classpath in eclipse entries of a java project

2. Because, I've a no compile error project in eclipse that depends on another project SharedLibrariesProject (having all jars for a poc, shared by both client and server).
In eclipse i can clean, build all, no issues.
Problem is when I run eclipse's Maven plugin > clean (build success) then when I try Maven plugin> install, I get compile errors. Obviously, I miss all the shared folder's jars that breaks the build.

3. What i'm expecting: when i run maven>build (after clean) in my eclipse > run> i should get a jar (or .esb file archive)

I've used maven for a while (on/off, not consistently used), don't know much about maven, I wish I get simple tutorial what/how part of maven? i get too many too, custom options.. so often i get lost when try to learn maven.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

That's not a straightforward task.

Maven does not work using path-style dependencies, which are what classpaths literally are. Maven's dependencies are all based on a discrete Maven ID (artifactId, groupId and version) which is not directly deducible from the name of the dependency jar or the classpath. In fact, periodically some project or other will make an annoying change about where in the Maven namespace they want to be found and I have to go on a "treasure hunt" to fix things.

The location of Maven dependencies is also very different. In a non-Maven project, the dependency jars are located in one or more designated areas of the project and/or in external directories of unpredictable location (or at least unpredictable if you don't know the classpath, including any ECLIPSE variable substitutions). Maven dependency jars, however, are not kept on a per-project basis, they're fetched on-demand from the Maven cache when building a target and do not otherwise exist in the project.

An IDE is no substitute for an Intelligent Developer.
Peter Johnson

Joined: May 14, 2008
Posts: 5852

1) A tool that I find handy for identifying dependencies is JBoss Tattletale. I typically place all my JARs, including my JAR, into a single directory and point Tattletale at it and get a nice report of who depends on what. This is especially ideal when converting builds to Maven.

2) When using Maven, do not let Eclipse projects depend on each other. If project A depends on project B, then you should ste things up such that project B is always built using "mvn install", and the pom..xml; should depend on the artifact (JAR) generated by project B. Thus you should always gets dependent JAR files out of the repository. I have a number of projects that work this way and I have never had an issue. (I also helps if your Maven projects also build source and javadoc JARs and upload them to the repository, and you configure m2eclipse to also download javadoc and sources if available).

Have you looked at Better Builds with Maven and Maven: The Definitive Reference

JBoss In Action
C H Kiran

Joined: May 14, 2005
Posts: 4
Thanks Both of you.. I'll try it later.. now, I"ve another task chasing to do a poc on JBossESB.. Thanks for your time again.
It is sorta covered in the JavaRanch Style Guide.
subject: Maven build dependencies from .classpath
It's not a secret anymore!