You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Matthias Dorfner <Ma...@psylock.com> on 2009/03/09 09:39:03 UTC

Questions about using Maven in a multi-module environment

Hi everybody,

 

I have a multi-moduled project that looks like this:

 

-parent

--submodule1

--submodule2

--submodule3

 

My questions are now:

 

1. How can I retrieve the name of the compiled jar from submodule2 & 3
in the parent's pom? (I think it's the finalname of submodule2 & 3)

Maybe I need an Ant-Script for this?

 

2. Can I forbid deploying on a submodules' level? I only want to allow
deploying the files from the parent's level. Can I let Maven throw an
error message or something like this if someone tries to deploy from a
submodule?

 

Thank you very much!

Matthias


AW: Questions about using Maven in a multi-module environment

Posted by Matthias Dorfner <Ma...@psylock.com>.
Thank you very much for your detailed answer, I think it helps a lot!

MD

-----Ursprüngliche Nachricht-----
Von: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com] 
Gesendet: Montag, 9. März 2009 10:15
An: Maven Users List
Betreff: Re: Questions about using Maven in a multi-module environment

I would forget your second concern...

Once you are using the copy-dependencies goal of the maven-dependency-plugin
you will actually *need* the sub-modules to deploy when running as far as
ehe deploy phase of the maven lifecycle...

By the way, the deploy phase does not do what you think it does... the
deploy phase pushes the artifacts to the Maven repository.... that is what
it is for.... it is *nothing* to do with deploying your artifacts to a
tomcat server... do not try to use it for such.

By default you should be trying to avoid running the lifecycle past verify
unless you are doing a release.

If you are working in one sub-module and want quicker builds it *may* be
useful for you to run as far as install (which puts the artifacts in your
local repository) in order to make rebuilding the module you are working on
quicker

parent# mvn clean install
parent# cd submodule3
// do some stuff
submodule3# mvn verify
// do some more stuff
submodule3# mvn verify
// do some more stuff
submodule3# mvn verify
// etc

may be quicker than
parent# mvn verify
parent# cd submodule3
// do some stuff
submodule3# cd ..
parent# mvn verify
parent# cd submodule3
// do some more stuff
submodule3# cd ..
parent# mvn verify
parent# cd submodule3
// do some more stuff
submodule3# cd ..
parent# mvn verify
// etc

(in the above case submodule3 has dependencies on submodule1 & 2... since
"verify" does not install anything into the local repo you have to run the
lifecycle from the aggregator pom so that submodule3 can find the build
artifacts from the reactor)

By the way, you should aim that your build works on a clean repository with
a clean build using the goals "clean verify" or you will have fun with the
release plugin...

(On a side note, this may not always be achieveable, in which case you may
have to switch your preparation goals for th release plugin to "clean
install"... but that can leave your release build partially dirty)

-Stephen

2009/3/9 Matthias Dorfner <Ma...@psylock.com>

> Thanks for your help, I'm indeed new to Maven ;-)
>
> I'll try it with the dependencies plugin, that solutions sounds good!
>
> What would you suggest for my second concern? Is there a possibility to
> deny deploying on a submodules' level?
>
> Thank you!
> MD
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com]
> Gesendet: Montag, 9. März 2009 09:44
> An: Maven Users List
> Betreff: Re: Questions about using Maven in a multi-module environment
>
> 2009/3/9 Matthias Dorfner <Ma...@psylock.com>
>
> > Hi everybody,
> >
> >
> >
> > I have a multi-moduled project that looks like this:
> >
> >
> >
> > -parent
> >
> > --submodule1
> >
> > --submodule2
> >
> > --submodule3
> >
> >
> >
> > My questions are now:
> >
> >
> >
> > 1. How can I retrieve the name of the compiled jar from submodule2 & 3
> > in the parent's pom? (I think it's the finalname of submodule2 & 3)
> >
>
> You do know that <finalName> only controls the name of the jar file in the
> target directory....
>
> I'm getting a smell that you are unaware of the maven-dependency-plugin,
> and
> it's copy-dependencies goal...
>
> Do'n do what I think you are trying to do... there are better ways...
> create
> another sub-module and use the maven-dependency-plugin to copy the jar
> files
> into that submodule4 and wrap them up in the zip file with the assembly
> plugin.
>
>
> >
> > Maybe I need an Ant-Script for this?
> >
> >
> >
> > 2. Can I forbid deploying on a submodules' level? I only want to allow
> > deploying the files from the parent's level. Can I let Maven throw an
> > error message or something like this if someone tries to deploy from a
> > submodule?
> >
> >
> You are thinking that maven is like ant.  it isn't, drink the kool-aid it
> tastes great ;-)
>
>
> >
> >
> > Thank you very much!
> >
> > Matthias
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Questions about using Maven in a multi-module environment

Posted by Stephen Connolly <st...@gmail.com>.
I would forget your second concern...

Once you are using the copy-dependencies goal of the maven-dependency-plugin
you will actually *need* the sub-modules to deploy when running as far as
ehe deploy phase of the maven lifecycle...

By the way, the deploy phase does not do what you think it does... the
deploy phase pushes the artifacts to the Maven repository.... that is what
it is for.... it is *nothing* to do with deploying your artifacts to a
tomcat server... do not try to use it for such.

By default you should be trying to avoid running the lifecycle past verify
unless you are doing a release.

If you are working in one sub-module and want quicker builds it *may* be
useful for you to run as far as install (which puts the artifacts in your
local repository) in order to make rebuilding the module you are working on
quicker

parent# mvn clean install
parent# cd submodule3
// do some stuff
submodule3# mvn verify
// do some more stuff
submodule3# mvn verify
// do some more stuff
submodule3# mvn verify
// etc

may be quicker than
parent# mvn verify
parent# cd submodule3
// do some stuff
submodule3# cd ..
parent# mvn verify
parent# cd submodule3
// do some more stuff
submodule3# cd ..
parent# mvn verify
parent# cd submodule3
// do some more stuff
submodule3# cd ..
parent# mvn verify
// etc

(in the above case submodule3 has dependencies on submodule1 & 2... since
"verify" does not install anything into the local repo you have to run the
lifecycle from the aggregator pom so that submodule3 can find the build
artifacts from the reactor)

By the way, you should aim that your build works on a clean repository with
a clean build using the goals "clean verify" or you will have fun with the
release plugin...

(On a side note, this may not always be achieveable, in which case you may
have to switch your preparation goals for th release plugin to "clean
install"... but that can leave your release build partially dirty)

-Stephen

2009/3/9 Matthias Dorfner <Ma...@psylock.com>

> Thanks for your help, I'm indeed new to Maven ;-)
>
> I'll try it with the dependencies plugin, that solutions sounds good!
>
> What would you suggest for my second concern? Is there a possibility to
> deny deploying on a submodules' level?
>
> Thank you!
> MD
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com]
> Gesendet: Montag, 9. März 2009 09:44
> An: Maven Users List
> Betreff: Re: Questions about using Maven in a multi-module environment
>
> 2009/3/9 Matthias Dorfner <Ma...@psylock.com>
>
> > Hi everybody,
> >
> >
> >
> > I have a multi-moduled project that looks like this:
> >
> >
> >
> > -parent
> >
> > --submodule1
> >
> > --submodule2
> >
> > --submodule3
> >
> >
> >
> > My questions are now:
> >
> >
> >
> > 1. How can I retrieve the name of the compiled jar from submodule2 & 3
> > in the parent's pom? (I think it's the finalname of submodule2 & 3)
> >
>
> You do know that <finalName> only controls the name of the jar file in the
> target directory....
>
> I'm getting a smell that you are unaware of the maven-dependency-plugin,
> and
> it's copy-dependencies goal...
>
> Do'n do what I think you are trying to do... there are better ways...
> create
> another sub-module and use the maven-dependency-plugin to copy the jar
> files
> into that submodule4 and wrap them up in the zip file with the assembly
> plugin.
>
>
> >
> > Maybe I need an Ant-Script for this?
> >
> >
> >
> > 2. Can I forbid deploying on a submodules' level? I only want to allow
> > deploying the files from the parent's level. Can I let Maven throw an
> > error message or something like this if someone tries to deploy from a
> > submodule?
> >
> >
> You are thinking that maven is like ant.  it isn't, drink the kool-aid it
> tastes great ;-)
>
>
> >
> >
> > Thank you very much!
> >
> > Matthias
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

AW: Questions about using Maven in a multi-module environment

Posted by Matthias Dorfner <Ma...@psylock.com>.
Thanks for your help, I'm indeed new to Maven ;-)

I'll try it with the dependencies plugin, that solutions sounds good!

What would you suggest for my second concern? Is there a possibility to deny deploying on a submodules' level?

Thank you!
MD



-----Ursprüngliche Nachricht-----
Von: Stephen Connolly [mailto:stephen.alan.connolly@gmail.com] 
Gesendet: Montag, 9. März 2009 09:44
An: Maven Users List
Betreff: Re: Questions about using Maven in a multi-module environment

2009/3/9 Matthias Dorfner <Ma...@psylock.com>

> Hi everybody,
>
>
>
> I have a multi-moduled project that looks like this:
>
>
>
> -parent
>
> --submodule1
>
> --submodule2
>
> --submodule3
>
>
>
> My questions are now:
>
>
>
> 1. How can I retrieve the name of the compiled jar from submodule2 & 3
> in the parent's pom? (I think it's the finalname of submodule2 & 3)
>

You do know that <finalName> only controls the name of the jar file in the
target directory....

I'm getting a smell that you are unaware of the maven-dependency-plugin, and
it's copy-dependencies goal...

Do'n do what I think you are trying to do... there are better ways... create
another sub-module and use the maven-dependency-plugin to copy the jar files
into that submodule4 and wrap them up in the zip file with the assembly
plugin.


>
> Maybe I need an Ant-Script for this?
>
>
>
> 2. Can I forbid deploying on a submodules' level? I only want to allow
> deploying the files from the parent's level. Can I let Maven throw an
> error message or something like this if someone tries to deploy from a
> submodule?
>
>
You are thinking that maven is like ant.  it isn't, drink the kool-aid it
tastes great ;-)


>
>
> Thank you very much!
>
> Matthias
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Questions about using Maven in a multi-module environment

Posted by Stephen Connolly <st...@gmail.com>.
2009/3/9 Matthias Dorfner <Ma...@psylock.com>

> Hi everybody,
>
>
>
> I have a multi-moduled project that looks like this:
>
>
>
> -parent
>
> --submodule1
>
> --submodule2
>
> --submodule3
>
>
>
> My questions are now:
>
>
>
> 1. How can I retrieve the name of the compiled jar from submodule2 & 3
> in the parent's pom? (I think it's the finalname of submodule2 & 3)
>

You do know that <finalName> only controls the name of the jar file in the
target directory....

I'm getting a smell that you are unaware of the maven-dependency-plugin, and
it's copy-dependencies goal...

Do'n do what I think you are trying to do... there are better ways... create
another sub-module and use the maven-dependency-plugin to copy the jar files
into that submodule4 and wrap them up in the zip file with the assembly
plugin.


>
> Maybe I need an Ant-Script for this?
>
>
>
> 2. Can I forbid deploying on a submodules' level? I only want to allow
> deploying the files from the parent's level. Can I let Maven throw an
> error message or something like this if someone tries to deploy from a
> submodule?
>
>
You are thinking that maven is like ant.  it isn't, drink the kool-aid it
tastes great ;-)


>
>
> Thank you very much!
>
> Matthias
>
>