Maven2 will do what you want, automatically.
(Maven1 was also capable of this, if you explicitly set the
eclipse.dependency property on a dependency.)
This page shows how to setup a multi-module project with dependencies in
Eclipse:
http://maven.apache.org/guides/mini/guide-ide-eclipse.html
So that you can edit your parent POM in Eclipse, I (reluctantly)
recommend creating another module (= Eclipse project), as described in
the "Flat Project Layout" section at the end of the page I linked to. I
called this project 'myproduct-maven' below. (Note: I heard a rumor that
Eclipse 3.2 supports hierarchical projects and doesn't require this
flattening nonsense.)
You will end up with four modules:
myproduct-maven
myproduct-core
myproduct-componentA
myproduct-componentB
myproduct-componentA and myproduct-componentB depend on myproduct-core,
and will thus reference myproduct-core in the dependencies section of
their pom.xml files.
If you then run mvn eclipse:eclipse from the myproduct-maven directory,
the generated Eclipse project files (.project and .classpath) will have
a project reference rather than a dependency on the resulting jar. That
means that changes in myproduct-core will be available immediately in
myproduct-componentA and myproduct-componentB -- you won't have to run
another mvn build to produce a new myproduct-core.jar file.
But note that you MUST run mvn eclipse:eclipse from the myproduct-maven
directory to have these dependencies generated as project dependencies.
If you run mvn eclipse:eclipse in myproduct-componentA, for instance, it
won't know that myproduct-core is another module in your project -- it
just looks like another external dependency.
-Max
Keith Bennett wrote:
All -
I have multiple source projects, each having a source code tree, and
each producing its own jar file.
Currently, I'm using Eclipse, and my eclipse-workspace directory looks
something like this:
myproduct-core
myproduct-componentA
myproduct-componentB
The latter two depend on myproduct-core at compile time and runtime.
How do I implement this in Maven 2.0?
Do I need to have myproduct-core produce a jar file that goes in the
Maven
repository? Or can it work in Maven as seamlessly as it works in
Eclipse,
with some way to indicate that the component source trees depend on the
core source tree?
I looked at dependencies in Maven 2.0, but I only find two
possibilities,
each daunting at best:
1) have the component depend on an artifact (namely, the
myproduct-core jar file). For this to work, I think I'd need to
push the core jar file into the repository whenever it is built.
How would I do this in such a way that it would happen
automatically when building one of the components that rely
on it? And how would Maven know when the core jar file is out of date?
2) have the core source tree in a subdirectory. This is problematic
because I have multiple component source trees that would need to
have this subdirectory. I could use symbolic links in Unix/Cygwin,
but not all developers would have this option available, and anyway
this would be a supreme kludge.
Any help would be greatly appreciated.
Thanks,
Keith Bennett
P.S. My main information resources were:
http://docs.codehaus.org/display/MAVENUSER/Multi-modules+projects
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
"Better Builds with Maven", free Maven 2 book available at
http://www.mergere.com/m2book_download.jsp.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]