You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Czollli <cz...@gmail.com> on 2009/02/03 10:54:26 UTC

Multimodule, multilevel project

Hello,

The main task would be to generate jar files in the leaf projects:

main (pom.xml)
 |
 |____ default (contains src and pom.xml)
            |
            |___ dev (only pom.xml)
                     |
                     |_____ dev1 (only pom.xml)
                     |
                     |_____ dev2 (only pom.xml)

dev1 and dev2 should contain in their target dir the jar file, generated
from src.

Did anybody already meet this problem?
Can anybody suggest a solution?

Thanks a lot!
Czollli
-- 
View this message in context: http://www.nabble.com/Multimodule%2C-multilevel-project-tp21806770p21806770.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Multimodule, multilevel project

Posted by Czollli <cz...@gmail.com>.


Czollli wrote:
> 
> Hello,
> 
> The main task would be to generate jar files in the leaf projects:
> 
> main (pom.xml)
>  |
>  |____ default (contains src and pom.xml)
>             |
>             |___ dev (only pom.xml)
>                      |
>                      |_____ dev1 (only pom.xml)
>                      |
>                      |_____ dev2 (only pom.xml)
> 
> dev1 and dev2 should contain in their target dir the jar file, generated
> from src.
> 
> Did anybody already meet this problem?
> Can anybody suggest a solution?
> 
> Thanks a lot!
> Czollli
> 

Hello,

thanks for all the help!

I have found a really simple solution with resource:
			<resource>
 			      <targetPath>.</targetPath>
			      <filtering>false</filtering>
			      <directory>${level2.default.target.dir}/classes</directory>
			      <includes>
				      <include>**/*.class</include>
			      </includes>

This excerpt should include in the bottom level (dev1, dev2) poms, where the
packaging runs again.
Again because first I had to package at the default level from the source
code.

main (pom.xml)
 |
 |____ default (contains src and pom.xml, packaging jar)
 |
 |___ dev (only pom.xml, packaging pom)
          |
          |_____ dev1 (only pom.xml, packaging jar)
          |
          |_____ dev2 (only pom.xml, packaging jar)

Main pom uses modules (default, dev).

Czollli
-- 
View this message in context: http://www.nabble.com/Multimodule%2C-multilevel-project-tp21806770p21870699.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Multimodule, multilevel project

Posted by Geoffrey Wiseman <ge...@gmail.com>.
On Wed, Feb 4, 2009 at 6:20 AM, Nick Stolwijk <ni...@gmail.com>wrote:

> I think you missed the comment about overlay/flatten/shade the dev1
> and dev2 modules.
>
> What are you going to do with the jars of dev1 and dev2?
>
> 1) Use it as dependencies for other maven modules
> In this case you don't need to do anything special, the common modules
> will end up as a transitive dependency for the other modules, so it
> should be packed when generating a war or ear.
>
> 2) Use it standalone
> Take a look at the Maven Shade Plugin [1]
>
> [1] http://maven.apache.org/plugins/maven-shade-plugin/
>

Shade plugin is probably the most flexible, although last time I used it,
the documentation was pretty sparse.  You've also got the maven assembly
plugin, which I believe can accomplish simpler versions of the same thing:
http://maven.apache.org/plugins/maven-assembly-plugin/

And probably the simplest: jar-with-dependencies, which is part of the the
assembly plugin, but requires less config:
http://maven.apache.org/plugins/maven-assembly-plugin/usage.html



-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: Multimodule, multilevel project

Posted by Nick Stolwijk <ni...@gmail.com>.
I think you missed the comment about overlay/flatten/shade the dev1
and dev2 modules.

What are you going to do with the jars of dev1 and dev2?

1) Use it as dependencies for other maven modules
In this case you don't need to do anything special, the common modules
will end up as a transitive dependency for the other modules, so it
should be packed when generating a war or ear.

2) Use it standalone
Take a look at the Maven Shade Plugin [1]

[1] http://maven.apache.org/plugins/maven-shade-plugin/

Hth,

Nick Stolwijk
~Java Developer~

Iprofs BV.
Claus Sluterweg 125
2012 WS Haarlem
www.iprofs.nl



On Wed, Feb 4, 2009 at 10:37 AM, Czollli <cz...@gmail.com> wrote:
> n.

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


Re: Multimodule, multilevel project

Posted by Czollli <cz...@gmail.com>.


Geoffrey Wiseman wrote:
> 
> parent (pom, multi-module; any common dependencies or dependency
> management,
> plugin management, etc.)
> - common (common source code; jar)
> - dev1 (depends on common; adds config; can overlay/flatten/shade jar if
> you
> like)
> - dev2 (same as dev1, but with its own config)
> 
> Each of common, dev1 and dev2 would have their own pom, and be modules
> under
> the parent build.
> 

Hi Geoffrey,

dev1 has a jar packaging type? 
Because in that case I get an almost empty jar, but I need the classes
generated in the common.

Thanks
Czollli
-- 
View this message in context: http://www.nabble.com/Multimodule%2C-multilevel-project-tp21806770p21827159.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Multimodule, multilevel project

Posted by Geoffrey Wiseman <ge...@gmail.com>.
On Tue, Feb 3, 2009 at 5:34 AM, Czollli <cz...@gmail.com> wrote:

> The source code must be common, dev1, dev2 etc. are different environments
> differs
> only in configuration files.
> That is the reason why I can't keep the standard structure...
> I have configurations at the different levels too, which inherited from the
> upper levels.
> But if you have another idee...
> Can you give me some hints how can I do that?


Well, based on my limited understanding of your project, and my
understanding of "the maven way", I'd probably structure it like this:

parent (pom, multi-module; any common dependencies or dependency management,
plugin management, etc.)
- common (common source code; jar)
- dev1 (depends on common; adds config; can overlay/flatten/shade jar if you
like)
- dev2 (same as dev1, but with its own config)

Each of common, dev1 and dev2 would have their own pom, and be modules under
the parent build.

  - Geoffrey
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: Multimodule, multilevel project

Posted by Czollli <cz...@gmail.com>.


Wayne Fay wrote:
> 
>> The source code must be common, dev1, dev2 etc. are different
>> environments
>> differs only in configuration files.
> 
> In that case, I would probably use profiles (which were designed for
> this purpose exactly) and structure the project as follows:
> no dev1, dev2 directories
> common has all files including config in the proper directory
> (src/main/resources)
> create "dev1" and "dev2" profiles with various values that are
> filtered into the config files during the build, also the profiles
> would set classifiers "dev1" and "dev2" or whatnot
> 
> 

Hi Wayne,

my structure requires multiple levels as you see and because of lack of
profile
inheritance I cannot do it on that way.
Anyway I played with profiles and I like it, but unfortunately isn't useful
here.

Czollli
-- 
View this message in context: http://www.nabble.com/Multimodule%2C-multilevel-project-tp21806770p21827230.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Multimodule, multilevel project

Posted by Geoffrey Wiseman <ge...@gmail.com>.
On Tue, Feb 3, 2009 at 1:28 PM, Wayne Fay <wa...@gmail.com> wrote:

> In that case, I would probably use profiles (which were designed for
> this purpose exactly) and structure the project as follows:
> no dev1, dev2 directories
> common has all files including config in the proper directory
> (src/main/resources)
> create "dev1" and "dev2" profiles with various values that are
> filtered into the config files during the build, also the profiles
> would set classifiers "dev1" and "dev2" or whatnot
>
> Then you would issue "mvn install -Pdev1" and it would build the code
> with the dev1 values substituted into the config files, and "mvn
> install -Pdev2" would do the same for dev2 values.
>

If you're not expecting to distribute and test both versions, I'd probably
go this way; if you're expecting to treat both as a final artifact, then I'd
probably go for sub-modules.  I'm not sure what the config differences are
intended for, so it's hard to speculate.
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: Multimodule, multilevel project

Posted by Wayne Fay <wa...@gmail.com>.
> The source code must be common, dev1, dev2 etc. are different environments
> differs only in configuration files.

In that case, I would probably use profiles (which were designed for
this purpose exactly) and structure the project as follows:
no dev1, dev2 directories
common has all files including config in the proper directory
(src/main/resources)
create "dev1" and "dev2" profiles with various values that are
filtered into the config files during the build, also the profiles
would set classifiers "dev1" and "dev2" or whatnot

Then you would issue "mvn install -Pdev1" and it would build the code
with the dev1 values substituted into the config files, and "mvn
install -Pdev2" would do the same for dev2 values.

Wayne

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


Re: Multimodule, multilevel project

Posted by Czollli <cz...@gmail.com>.


Wayne Fay wrote:
> 
>> dev1 and dev2 should contain in their target dir the jar file, generated
>> from src.
> 
> You could do this... but why would you possibly want to, other than
> "don't want to change structure of old codebase"? Move the source code
> for dev1 to dev1/src/main/java, and the source code for dev2 to
> dev2/src/main/java.
> 
> 

The source code must be common, dev1, dev2 etc. are different environments
differs
only in configuration files. 
That is the reason why I can't keep the standard structure...
I have configurations at the different levels too, which inherited from the
upper levels.
But if you have another idee...
Can you give me some hints how can I do that?

Regards
Czollli
-- 
View this message in context: http://www.nabble.com/Multimodule%2C-multilevel-project-tp21806770p21807333.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Multimodule, multilevel project

Posted by Wayne Fay <wa...@gmail.com>.
> dev1 and dev2 should contain in their target dir the jar file, generated
> from src.

You could do this... but why would you possibly want to, other than
"don't want to change structure of old codebase"? Move the source code
for dev1 to dev1/src/main/java, and the source code for dev2 to
dev2/src/main/java.

Wayne

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