You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Thomas Van de Velde <th...@accenture.com> on 2005/09/30 13:33:20 UTC
Re: [M2] Recommended Project Layout and Eclipse
I ment to send this to the users list. Sorry for the double post!
Cheers,
Thomas
On 9/30/05, Thomas Van de Velde <th...@accenture.com> wrote:
>
> Hi,
>
> I am wondering what the best way is to setup a project layout with M2 and
> Eclipse for multiple modules. The documentation<http://maven.apache.org/maven2/getting-started.html>recommends the following:
>
> +- pom.xml
> +- my-app
> | +- pom.xml
> +- my-webapp
> | +- pom.xml
>
>
> The only way I can see this work with Eclipse is to add the entire
> structure to a single Eclipse project. However this is not something I'd
> want to do because I don't want to have a single Eclipse classpath that is
> exposed to my-app and my-webapp.
>
> The only way around this, that I can currently see, is to do this:
>
> +- my-master
> | +- pom.xml
> +- my-app
> | +- pom.xml
> +- my-webapp
> | +- pom.xml
>
> In this scenario; my-master, my-app, and my-webapp are all seperate
> Eclipse projects. To make this work, I need to change the master POM's
> modules element to the following:
>
> <modules>
> <module>../my-app</module>
> <module>../my-webapp</module>
> </modules>
>
> Have I missed something or is this the recommended way?
>
> Thanks!
>
> Thomas
>
Re: [M2] Recommended Project Layout and Eclipse
Posted by Jesse McConnell <je...@gmail.com>.
http://jira.codehaus.org/browse/MNG-743
that jira issue has a pretty good layout in my opinion...it has a sample jar
that builds out everything into empty artifacts and can be a good way of
getting going.
On 9/30/05, Thomas Van de Velde <th...@accenture.com> wrote:
>
> I ment to send this to the users list. Sorry for the double post!
>
> Cheers,
> Thomas
>
> On 9/30/05, Thomas Van de Velde <th...@accenture.com> wrote:
> >
> > Hi,
> >
> > I am wondering what the best way is to setup a project layout with M2
> and
> > Eclipse for multiple modules. The documentation<
> http://maven.apache.org/maven2/getting-started.html>recommends the
> following:
> >
> > +- pom.xml
> > +- my-app
> > | +- pom.xml
> > +- my-webapp
> > | +- pom.xml
> >
> >
> > The only way I can see this work with Eclipse is to add the entire
> > structure to a single Eclipse project. However this is not something I'd
> > want to do because I don't want to have a single Eclipse classpath that
> is
> > exposed to my-app and my-webapp.
> >
> > The only way around this, that I can currently see, is to do this:
> >
> > +- my-master
> > | +- pom.xml
> > +- my-app
> > | +- pom.xml
> > +- my-webapp
> > | +- pom.xml
> >
> > In this scenario; my-master, my-app, and my-webapp are all seperate
> > Eclipse projects. To make this work, I need to change the master POM's
> > modules element to the following:
> >
> > <modules>
> > <module>../my-app</module>
> > <module>../my-webapp</module>
> > </modules>
> >
> > Have I missed something or is this the recommended way?
> >
> > Thanks!
> >
> > Thomas
> >
>
>
--
jesse mcconnell
Re: [M2] Recommended Project Layout and Eclipse
Posted by Kenney Westerhof <ke...@apache.org>.
On Fri, 30 Sep 2005, Stephen Duncan wrote:
> I'm not at all clear on what the suggestion is. Is there a base
> assumption here that you should never have your projects in your
> Eclipse "workspace" folder, but always outside it?
Well, you can have the projects in the workspace folder, but that doesn't
mean eclipse sees those projects! The actual 'enabled' projects
are all defined in .metadata/...somewhere. The projects can be located
anywhere, in the workspace and outside.
> Within the
> workspace, Eclipse won't even support (so far as I can tell) using the
> modules as projects if you have:
>
> workspace/my-project
> /my-app
> /my-webapp
>
> Right?
>
If this were the 'enabled' projects list you see in the package explorer
etc., no. If you imported those projects using either eclipse 3.1 or the
multi-project import module, from the my-projects folder on, it would
recurse down and flattens the tree so:
- my-project
- my-app
- my-webapp
Still, this doesn't even work, since my-app and my-webapp are located
in the project space of my-project (on disk).
Usually however, this isn't a problem, since most of the times only
leaf projects have artifacts, and the eclipse plugin skips creating
project files for poms.
> And, even if you have your stuff in a seperate location from your
> workspace, you can never havve the "my-project" folder as a project in
> Eclipse, because it overlaps with my-app and my-webapp. So to manage
Right - should've read on before replying above ;)
> updates to the aggregating pom you'd have to open up the file
> manually, since you can't have an Eclipse project containing it. And
> if I want to use Eclipse as my only CVS client, I'm stuck entirely,
> right? I can try to manage the subprojects with CVS seperately
> (though I'd rather manage the whole my-project at once), but I can't
> at all manage the CVS'ing of the aggregating pom.
Well, you can use the -Declipse.workspace=/somewhere/else option.
It will create a folder for each project in /somewhere/else, containing
a file link to the pom and folder links to the (re)source directories.
That circumvents the problem.
However, with clearcase, eclipse doesn't see that the pom file
is under version control, but it might work with subversion/cvs
(if the plugin checks the <target directory for the link>/(.svn|CVS)/
instead of the directory where the .project file is).
> For now my current system for a multi-project is to put it all in one
> Eclipse project. I set my source locations manually to have different
> output locations to go into each module/sub-project. And of course, I
> have to manually manage my classpath, because the Eclipse plug-in
> doesn't work in this mode. I just have to avoid circular dependencies
> manually.
That's a PITA.. maybe the -Declipse.workspace=* helps? Otherwise,
change the directory structure so that only leaf projects produce
artifacts.. those are the only options I can think of.
-- Kenney
> --
> Stephen Duncan Jr
> www.stephenduncanjr.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] Recommended Project Layout and Eclipse
Posted by Stephen Duncan <st...@gmail.com>.
I'm not at all clear on what the suggestion is. Is there a base
assumption here that you should never have your projects in your
Eclipse "workspace" folder, but always outside it? Within the
workspace, Eclipse won't even support (so far as I can tell) using the
modules as projects if you have:
workspace/my-project
/my-app
/my-webapp
Right?
And, even if you have your stuff in a seperate location from your
workspace, you can never havve the "my-project" folder as a project in
Eclipse, because it overlaps with my-app and my-webapp. So to manage
updates to the aggregating pom you'd have to open up the file
manually, since you can't have an Eclipse project containing it. And
if I want to use Eclipse as my only CVS client, I'm stuck entirely,
right? I can try to manage the subprojects with CVS seperately
(though I'd rather manage the whole my-project at once), but I can't
at all manage the CVS'ing of the aggregating pom.
For now my current system for a multi-project is to put it all in one
Eclipse project. I set my source locations manually to have different
output locations to go into each module/sub-project. And of course, I
have to manually manage my classpath, because the Eclipse plug-in
doesn't work in this mode. I just have to avoid circular dependencies
manually.
--
Stephen Duncan Jr
www.stephenduncanjr.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] Recommended Project Layout and Eclipse
Posted by Kenney Westerhof <ke...@apache.org>.
On Fri, 30 Sep 2005, Thomas Van de Velde wrote:
> > > - Check in the entire tree as a single SCM module.
> >
> > Correct. You can also use different scm repositories for each module if
> > you want, as long as you specify the scm repository in the pom for that
> > module.
>
> How could that work? Your master POM is not aware of where in SCM its
> modules are located, right? Or is the master POM looking at the list of
> modules to find a corresponding pom in the repository, and use that SCM info
> to checkout the modules?
The master pom knows it's own location, say $REPO_LOCATION/
Each module defined in that pom will have a scm location of
$REPO_LOCATION/module-name (recursively).
However, i see your problem, if the module you check out is a grandchild
of the root pom. AFAIK there's no <module> traversal done from the root
pom onwards to the section you check out. However, what will work is
if each module has the project defining that module as a parent-pom.
So:
root/pom.xml defines module a, scm location $REPO_LOCATION
a/pom.xml defines module b, parent=root
b/pom.xml defines module c, parent = a
etc..
If you check out b the scm location should be calculated as being
$REPO_LOCATION/a/b/
Since it is good practise to define the parent pom as the pom that defines
the current pom as a module (i.e. b defines a as it's parent since a
defines b as a module), there should be no problem.
Though scm urls are calculated from the grandchild back to the root pom
using the <parent> tags, not the other way around using <module> tags.
-- Kenney
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] Recommended Project Layout and Eclipse
Posted by Thomas Van de Velde <th...@accenture.com>.
>
> > - Check in the entire tree as a single SCM module.
>
> Correct. You can also use different scm repositories for each module if
> you want, as long as you specify the scm repository in the pom for that
> module.
How could that work? Your master POM is not aware of where in SCM its
modules are located, right? Or is the master POM looking at the list of
modules to find a corresponding pom in the repository, and use that SCM info
to checkout the modules?
Re: [M2] Recommended Project Layout and Eclipse
Posted by Kenney Westerhof <ke...@apache.org>.
On Fri, 30 Sep 2005 eric.starr@wachovia.com wrote:
> I think we are having a problem with terminology... Especially when
> talking about a "module"
> Comments and questions are embedded.
Yeah - too much terminology from different contexts come clashing together
:)
> > > Is the following hypothesis correct?
> > >
> > > - Setup the recommended M2 structure for multiple modules.
>
> As specified before, the recommended structure is:
>
> +- pom.xml
> +- my-app
> | +- pom.xml
> +- my-webapp
> | +- pom.xml
>
Yup.
> The next two answers from Kenny are the confusing and apparently
> conflicting part that need more clarification.
>
> >
> > > - Check in the entire tree as a single SCM module.
> >
> > Correct. You can also use different scm repositories for each module if
> > you want, as long as you specify the scm repository in the pom for that
> > module.
> >
>
> Kenny answers that it is correct that you can check in the entire tree as
> a single SCM Module. This seems to conflict with what Kenny says next.
Correct, you can check in the entire project tree as a single SCM Module
(CVS uses that term; in subversion it would be a 'sub-tree in a
repository' i guess).
> > > - To work on an individual module: Check out the subsection of
> thestructure
module = a project (and subprojects), i.e. my-app + subdirs, as I
understand this.
> > > that holds the module and Eclipse project for that module.
>
> > never check in eclipse projects! Generate them. If you work on a
> > subsection of the structure, you don't have project references to other
> > sections. If you were to check in eclipse project files you would have
> to
> > decide beforehand wheter to use project references or not (in this last
> > case you would have to run m2 eclipse:eclipse for each module
> seperately).
>
> Kenny says to "never checkin eclipse projects"... Well then, if you never
What i meant was 'never check in eclipse project files'
(.project/.classpath/.settings etc..).
> check in eclipse projects, then you are not checking in the entire tree as
> a single SCM Module. This is confusing. Wouldn't you need to check in
> the eclipse project to get the master POM (the top level POM) into SCM?
eclipse is a way of looking at/working with a maven project. I merely
meant the eclipse-aspect of the project, since it can be generated, and
it depends on what part of the project tree is checked out what the
contents of the eclipse project files are.
> So... for clarification...to be as specific as possible
>
> Given this structure in SCM
>
> MyProject
> +- pom.xml (master POM)
> +- my-app
> | +- pom.xml
> +- my-webapp
> | +- pom.xml
Ok, the above is the SCM structure.
> Within Eclipse wouldn't I right click on the "MyProject" project and
This SCM project structure is impossible to have in eclipse,
unless you have one single project in your workspace named 'MyProject',
containing 'pom.xml', 'my-app/' and 'my-webapp/' subdirectories.
You'd have to manually add all the source paths and merge dependencies
from all maven2 sub-projects (pom files). I didn't recommend this,
so I didn't mention it.
> choose Team-->Commit
> If not, then please clarify.
Hm.. interesting problem. You can only do that if you 'share project'
first, in which case you'd have to manually enter an SCM Url. If we
take the structure above, with 1 project in eclipse, then the eclipse
project structure == the scm project structure.
There's currently no support to write SCM settings in the .project files,
we assume the project being in SCM already and rely on eclipse detecting
CVS and .svn directories.
If there is a split-up (one eclipse project for each pom file), i'm not
sure how you'd approach this - probably manually entering an SCM url for
each project.
But I wouldn't know - I hate GUI's (RSI and all). I usually just
create a repository on the commandline, check out revision 0, and 'import'
that directory into eclipse. Then eclipse takes care of marking new files
(pom.xml etc). But i actually first setup the project structure on the
commandline, create some sourcefiles and then later on I import the
projects in eclipse. I always commit on the commandline since the eclipse
SCM plugins are usually buggy (especially for SVN).
-- Kenney
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] Recommended Project Layout and Eclipse
Posted by er...@wachovia.com.
I think we are having a problem with terminology... Especially when
talking about a "module"
Comments and questions are embedded.
Kenney Westerhof <ke...@apache.org> wrote on 09/30/2005 09:06:39 AM:
> On Fri, 30 Sep 2005, Thomas Van de Velde wrote:
>
> Hi Thomas,
>
> > Kenney,
> >
> > Thanks for your reply. I am still a bit puzzled though when SCM is
brought
> > into the picture.
> >
> > Is the following hypothesis correct?
> >
> > - Setup the recommended M2 structure for multiple modules.
As specified before, the recommended structure is:
+- pom.xml
+- my-app
| +- pom.xml
+- my-webapp
| +- pom.xml
The next two answers from Kenny are the confusing and apparently
conflicting part that need more clarification.
>
> > - Check in the entire tree as a single SCM module.
>
> Correct. You can also use different scm repositories for each module if
> you want, as long as you specify the scm repository in the pom for that
> module.
>
Kenny answers that it is correct that you can check in the entire tree as
a single SCM Module. This seems to conflict with what Kenny says next.
> > - To work on an individual module: Check out the subsection of
thestructure
> > that holds the module and Eclipse project for that module.
>
> never check in eclipse projects! Generate them. If you work on a
> subsection of the structure, you don't have project references to other
> sections. If you were to check in eclipse project files you would have
to
> decide beforehand wheter to use project references or not (in this last
> case you would have to run m2 eclipse:eclipse for each module
seperately).
Kenny says to "never checkin eclipse projects"... Well then, if you never
check in eclipse projects, then you are not checking in the entire tree as
a single SCM Module. This is confusing. Wouldn't you need to check in
the eclipse project to get the master POM (the top level POM) into SCM?
So... for clarification...to be as specific as possible
Given this structure in SCM
MyProject
+- pom.xml (master POM)
+- my-app
| +- pom.xml
+- my-webapp
| +- pom.xml
Within Eclipse wouldn't I right click on the "MyProject" project and
choose Team-->Commit
If not, then please clarify.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] Recommended Project Layout and Eclipse
Posted by Kenney Westerhof <ke...@apache.org>.
On Fri, 30 Sep 2005, Thomas Van de Velde wrote:
Hi Thomas,
> Kenney,
>
> Thanks for your reply. I am still a bit puzzled though when SCM is brought
> into the picture.
>
> Is the following hypothesis correct?
>
> - Setup the recommended M2 structure for multiple modules.
>
> - Generate an Eclipse project + class path per module by running the Eclipse
> plugin from the root of this structure.
Correct - the internal dependencies are resolved using the reactor,
so if my-webapp depends on my-app you get a project reference in eclipse,
not a classpath entry for the my-app artifact in your local repository.
> - Check in the entire tree as a single SCM module.
Correct. You can also use different scm repositories for each module if
you want, as long as you specify the scm repository in the pom for that
module.
> - To work on an individual module: Check out the subsection of the structure
> that holds the module and Eclipse project for that module.
never check in eclipse projects! Generate them. If you work on a
subsection of the structure, you don't have project references to other
sections. If you were to check in eclipse project files you would have to
decide beforehand wheter to use project references or not (in this last
case you would have to run m2 eclipse:eclipse for each module seperately).
> - To build the entire application: Check out the entire SCM module and run
> the build from the structure's root.
Correct. You can also build a subsection of the structure; you don't need
to check out the entire project, as long as the repository where the
missing poms and artifacts can be found is specified in the pom.
This can cause a problem though: you usually define the artifact
repository in the root pom; if you check out a submodule, m2 might not
find the root pom in the correct repository; kinf of a chicken and egg
problem. A solution is to specify a company wide (or project
local) repository in your settings.xml.
-- Kenney
> Thanks
>
> Thomas
>
>
> On 9/30/05, Kenney Westerhof <ke...@apache.org> wrote:
> >
> > On Fri, 30 Sep 2005, Thomas Van de Velde wrote:
> >
> > Hi,
> >
> > > I ment to send this to the users list. Sorry for the double post!
> > >
> > > Cheers,
> > > Thomas
> > >
> > > On 9/30/05, Thomas Van de Velde <th...@accenture.com>
> > wrote:
> > > >
> > > > Hi,
> > > >
> > > > I am wondering what the best way is to setup a project layout with M2
> > and
> > > > Eclipse for multiple modules. The documentation<
> > http://maven.apache.org/maven2/getting-started.html>recommends the
> > following:
> > > >
> > > > +- pom.xml
> > > > +- my-app
> > > > | +- pom.xml
> > > > +- my-webapp
> > > > | +- pom.xml
> >
> > Yes, this is the recommended way. The topmost pom.xml is the parent pom,
> > containing <module> sections for subdirectories.
> >
> > > > The only way I can see this work with Eclipse is to add the entire
> > > > structure to a single Eclipse project. However this is not something
> > I'd
> > > > want to do because I don't want to have a single Eclipse classpath
> > that is
> > > > exposed to my-app and my-webapp.
> >
> > Why? Separate projects work fine. It's just nested non-pom projects that
> > don't work well in eclipse.
> >
> > > > The only way around this, that I can currently see, is to do this:
> >
> > I don't see a problem..
> >
> > > > +- my-master
> > > > | +- pom.xml
> > > > +- my-app
> > > > | +- pom.xml
> > > > +- my-webapp
> > > > | +- pom.xml
> >
> > You're still missing the parent pom that defies my-master, my-app and
> > my-webapp as modules.
> >
> > > > In this scenario; my-master, my-app, and my-webapp are all seperate
> > > > Eclipse projects. To make this work, I need to change the master POM's
> > > > modules element to the following:
> > > > <modules>
> > > > <module>../my-app</module>
> > > > <module>../my-webapp</module>
> > > > </modules>
> >
> > You don't, you just need to specify dependencies from my-webapp and
> > my-app to my-master.
> >
> > Modules are normally located UNDER the project that defines them.
> > The project that defines them usually has packaging 'pom'.
> > So the only projects that produce artifacts tend to be leaf projects
> > (no nested modules). Maven2 doesn't require this at all, but if
> > you want to have in-place eclipse .project/.classpath this is recommended.
> >
> > If, in the maven2 recommended structure (the first one you mentioned),
> > the root pom would produce an artifact, eclipse would break. What you
> > can do in that case is run m2 eclipse:eclipse
> > -Declipse.workspace=some/other/location; the plugin then creates a
> > flattened project structure to overcome eclipse's nesting limitation.
> >
> > Also, never ever join all your subprojects in one eclipse project!
> > That will require adding dependencies manually, and will break the
> > separation of classpaths. Your code might end up requiring circular
> > dependencies, breaking an m2 build.
> >
> > > > Have I missed something or is this the recommended way?
> >
> > Hope the above answers your question?
> >
> > -- Kenney
> >
> > > >
> > > > Thanks!
> > > >
> > > > Thomas
> > > >
> > >
> >
> > --
> > Kenney Westerhof
> > http://www.neonics.com
> > GPG public key: http://www.gods.nl/~forge/kenneyw.key
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: [M2] Recommended Project Layout and Eclipse
Posted by Thomas Van de Velde <th...@accenture.com>.
Kenney,
Thanks for your reply. I am still a bit puzzled though when SCM is brought
into the picture.
Is the following hypothesis correct?
- Setup the recommended M2 structure for multiple modules.
- Generate an Eclipse project + class path per module by running the Eclipse
plugin from the root of this structure.
- Check in the entire tree as a single SCM module.
- To work on an individual module: Check out the subsection of the structure
that holds the module and Eclipse project for that module.
- To build the entire application: Check out the entire SCM module and run
the build from the structure's root.
Thanks
Thomas
On 9/30/05, Kenney Westerhof <ke...@apache.org> wrote:
>
> On Fri, 30 Sep 2005, Thomas Van de Velde wrote:
>
> Hi,
>
> > I ment to send this to the users list. Sorry for the double post!
> >
> > Cheers,
> > Thomas
> >
> > On 9/30/05, Thomas Van de Velde <th...@accenture.com>
> wrote:
> > >
> > > Hi,
> > >
> > > I am wondering what the best way is to setup a project layout with M2
> and
> > > Eclipse for multiple modules. The documentation<
> http://maven.apache.org/maven2/getting-started.html>recommends the
> following:
> > >
> > > +- pom.xml
> > > +- my-app
> > > | +- pom.xml
> > > +- my-webapp
> > > | +- pom.xml
>
> Yes, this is the recommended way. The topmost pom.xml is the parent pom,
> containing <module> sections for subdirectories.
>
> > > The only way I can see this work with Eclipse is to add the entire
> > > structure to a single Eclipse project. However this is not something
> I'd
> > > want to do because I don't want to have a single Eclipse classpath
> that is
> > > exposed to my-app and my-webapp.
>
> Why? Separate projects work fine. It's just nested non-pom projects that
> don't work well in eclipse.
>
> > > The only way around this, that I can currently see, is to do this:
>
> I don't see a problem..
>
> > > +- my-master
> > > | +- pom.xml
> > > +- my-app
> > > | +- pom.xml
> > > +- my-webapp
> > > | +- pom.xml
>
> You're still missing the parent pom that defies my-master, my-app and
> my-webapp as modules.
>
> > > In this scenario; my-master, my-app, and my-webapp are all seperate
> > > Eclipse projects. To make this work, I need to change the master POM's
> > > modules element to the following:
> > > <modules>
> > > <module>../my-app</module>
> > > <module>../my-webapp</module>
> > > </modules>
>
> You don't, you just need to specify dependencies from my-webapp and
> my-app to my-master.
>
> Modules are normally located UNDER the project that defines them.
> The project that defines them usually has packaging 'pom'.
> So the only projects that produce artifacts tend to be leaf projects
> (no nested modules). Maven2 doesn't require this at all, but if
> you want to have in-place eclipse .project/.classpath this is recommended.
>
> If, in the maven2 recommended structure (the first one you mentioned),
> the root pom would produce an artifact, eclipse would break. What you
> can do in that case is run m2 eclipse:eclipse
> -Declipse.workspace=some/other/location; the plugin then creates a
> flattened project structure to overcome eclipse's nesting limitation.
>
> Also, never ever join all your subprojects in one eclipse project!
> That will require adding dependencies manually, and will break the
> separation of classpaths. Your code might end up requiring circular
> dependencies, breaking an m2 build.
>
> > > Have I missed something or is this the recommended way?
>
> Hope the above answers your question?
>
> -- Kenney
>
> > >
> > > Thanks!
> > >
> > > Thomas
> > >
> >
>
> --
> Kenney Westerhof
> http://www.neonics.com
> GPG public key: http://www.gods.nl/~forge/kenneyw.key
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: [M2] Recommended Project Layout and Eclipse
Posted by Kenney Westerhof <ke...@apache.org>.
On Fri, 30 Sep 2005, Thomas Van de Velde wrote:
Hi,
> I ment to send this to the users list. Sorry for the double post!
>
> Cheers,
> Thomas
>
> On 9/30/05, Thomas Van de Velde <th...@accenture.com> wrote:
> >
> > Hi,
> >
> > I am wondering what the best way is to setup a project layout with M2 and
> > Eclipse for multiple modules. The documentation<http://maven.apache.org/maven2/getting-started.html>recommends the following:
> >
> > +- pom.xml
> > +- my-app
> > | +- pom.xml
> > +- my-webapp
> > | +- pom.xml
Yes, this is the recommended way. The topmost pom.xml is the parent pom,
containing <module> sections for subdirectories.
> > The only way I can see this work with Eclipse is to add the entire
> > structure to a single Eclipse project. However this is not something I'd
> > want to do because I don't want to have a single Eclipse classpath that is
> > exposed to my-app and my-webapp.
Why? Separate projects work fine. It's just nested non-pom projects that
don't work well in eclipse.
> > The only way around this, that I can currently see, is to do this:
I don't see a problem..
> > +- my-master
> > | +- pom.xml
> > +- my-app
> > | +- pom.xml
> > +- my-webapp
> > | +- pom.xml
You're still missing the parent pom that defies my-master, my-app and
my-webapp as modules.
> > In this scenario; my-master, my-app, and my-webapp are all seperate
> > Eclipse projects. To make this work, I need to change the master POM's
> > modules element to the following:
> > <modules>
> > <module>../my-app</module>
> > <module>../my-webapp</module>
> > </modules>
You don't, you just need to specify dependencies from my-webapp and
my-app to my-master.
Modules are normally located UNDER the project that defines them.
The project that defines them usually has packaging 'pom'.
So the only projects that produce artifacts tend to be leaf projects
(no nested modules). Maven2 doesn't require this at all, but if
you want to have in-place eclipse .project/.classpath this is recommended.
If, in the maven2 recommended structure (the first one you mentioned),
the root pom would produce an artifact, eclipse would break. What you
can do in that case is run m2 eclipse:eclipse
-Declipse.workspace=some/other/location; the plugin then creates a
flattened project structure to overcome eclipse's nesting limitation.
Also, never ever join all your subprojects in one eclipse project!
That will require adding dependencies manually, and will break the
separation of classpaths. Your code might end up requiring circular
dependencies, breaking an m2 build.
> > Have I missed something or is this the recommended way?
Hope the above answers your question?
-- Kenney
> >
> > Thanks!
> >
> > Thomas
> >
>
--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org