You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Irv Salisbury III <ir...@dotech.com> on 2004/10/21 19:45:30 UTC
Build setup for multiple "small projects" that are related
Didn't get a solid answer to this from the documentation I read. I am
used to setting up my build structure based on what things do under a
given project name. For instance:
src
common
java
xml
conf
web-services
java
xml
xsd
wsdl
xml-util
java
xml
xsd
Typically every "sub project' uses the common piece, but then are pretty
independent. They all fall under a "major" project. This allows people
to build whatever piece they want without having to build the whole
thing. It has really worked out well.
So, the question is, what is the best way to set this up in maven? The
docs say that this isn't directly supported, so it seems like my only
option is to to separate projects for each one, like:
common
project.xml
src
java
xml
conf
web-services
project.xml
src
java
xml
conf
xml-util
project.xml
src
java
xml
conf
I don't have a problem with this, but wanted to make sure I understood.
Also, in the web-services and xml-util projects, would I then list the
common project as a dependency? With my previous builds, I would build
the common source right into the other projects in a build directory.
So, I'd have build/web-services where the common source would be built
with the web-services src. (With nested <src> tags under javac)
Any thoughts would be greatly appreciated.
Irv
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Build setup for multiple "small projects" that are related
Posted by Ben Anderson <be...@benanderson.us>.
> Thanks for the quick reply.
To jog your memory - I was in one of your D.O. Tech classes a couple years back
when I was with Paychex. Just paying my respects to the teacher ;-) You also
introduced me to gvim, for which I am ever grateful.
> 1. Each "sub project" has its own artifacts (jar files). Would i just
> put them down in the lower project.xml files?
not too sure what you're asking here... Are you asking where the jar will be
placed after it is built? If so, you can specify that in the maven.build.dir
property. However, you probably want to leave this as the default
(${basedir}/target). Should you need to use this jar as a dependency in
another project, you'll want to do jar:install. The subproject's project.xml
will be where you specify information specific to that jar, such as the make up
of the jar, the name of the jar, etc.
> 2. When I want to build, for example, the web-services piece, where
> would I do the maven command, and what goal would that be?
from the web-services directory (where your subproject's project.xml is)
maven jar:jar
maven is all about plugins. On maven's home page, click on references->plugins.
> 3. It seems like if I don't use the built in structure, the built in
> goals don't work very well as they "assume" one source directory.
bingo. Maven can be rather intrusive as far as directory structures, jar
contents, etc. This is one of the reasons so many ant supporters are unwilling
to adopt maven. However, like anything else, in order to enforce reuse,
standards must be made and enforced.
Something else it seems you've been hinting at is the reactor. Using it, you
can recursively call subproject goals from a higher directory. You would
create a custom goal which you write in jelly and various tag libraries. The
reactor is invoked from the jelly:maven taglib. You can find this by clicking
"references->maven jelly tags" from maven's home page.
-Ben
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Build setup for multiple "small projects" that are related
Posted by Irv Salisbury III <ir...@dotech.com>.
Thanks for the quick reply. Some follow up questions:
1. Each "sub project" has its own artifacts (jar files). Would i just
put them down in the lower project.xml files?
2. When I want to build, for example, the web-services piece, where
would I do the maven command, and what goal would that be?
3. It seems like if I don't use the built in structure, the built in
goals don't work very well as they "assume" one source directory.
I have no problem reworking my directory structure. I want to use maven
as well as possible and don't always want to be doing extra work just
because of my directory structure.
Irv
Ben Anderson wrote:
>Irv,
>It doesn't sound like your directory structures need to change. I would suggest
>keeping the same one you have, then you can use maven's inheritance:
>
>src
> project.xml
> common
> project.xml
> java
> xml
> conf
> web-services
> project.xml
> java
> xml
> conf
> xml-util
> project.xml
> java
> xml
> conf
>
>In your top level project.xml you can define your common structure:
><project>
> ...
> <build>
> <sourceDirectory>java</sourceDirectory>
> <resources>
> <resource>
> <directory>xml</directory>
> <includes>
> <include>*.xml</include>
> </includes>
> </resource>
> <resource>
> <directory>conf</directory>
> <includes>
> <include>*.properties</include>
> </includes>
> </resource>
> </resources>
> </build>
> ...
></project>
>
>then in your subdirectories
><project>
> <extend>../project.xml</extend>
> ...
></project>
>
>
>
>
>>Also, in the web-services and xml-util projects, would I then list the
>>common project as a dependency?
>>
>>
>If you're creating a war or ear, or some other aggregate artifact, then you will
>need to specify the artifacts you want to include. For instance:
> <dependency>
> <groupId>dotech</groupId>
> <artifactId>common</artifactId>
> <version>1.0</version>
> <properties>
> <war.bundle>true</war.bundle>
> </properties>
> </dependency>
>
>If, however, you are building a component jar, then you only need to specify the
>dependency if it needs to be in your classpath during compile time. So, it
>seems like you will in your case. Note: Make sure that you "install" the
>dependency in your local repo ("maven jar:install") before you try to access
>it.
>
>
>
>>So, I'd have build/web-services where the common source would be built
>>with the web-services src. (With nested <src> tags under javac)
>>
>>
>I think the thing you want to focus on is what artifacts you wish to create.
>Maven has had some controversy about whether to allow multiple source
>directories in the same project. The general understanding is that you should
>not do this, but you can if you want:
>http://maven.apache.org/faq.html#multiple-source-directories
>
>In most cases in makes more sense to keep the jars separate. So, your
>web-services and xml-util jars would not contain the class files that are in
>the common jar.
>
>HTH,
>Ben
>
>
>
>---------------------------------------------------------------------
>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: Build setup for multiple "small projects" that are related
Posted by Ben Anderson <be...@benanderson.us>.
Irv,
It doesn't sound like your directory structures need to change. I would suggest
keeping the same one you have, then you can use maven's inheritance:
src
project.xml
common
project.xml
java
xml
conf
web-services
project.xml
java
xml
conf
xml-util
project.xml
java
xml
conf
In your top level project.xml you can define your common structure:
<project>
...
<build>
<sourceDirectory>java</sourceDirectory>
<resources>
<resource>
<directory>xml</directory>
<includes>
<include>*.xml</include>
</includes>
</resource>
<resource>
<directory>conf</directory>
<includes>
<include>*.properties</include>
</includes>
</resource>
</resources>
</build>
...
</project>
then in your subdirectories
<project>
<extend>../project.xml</extend>
...
</project>
> Also, in the web-services and xml-util projects, would I then list the
> common project as a dependency?
If you're creating a war or ear, or some other aggregate artifact, then you will
need to specify the artifacts you want to include. For instance:
<dependency>
<groupId>dotech</groupId>
<artifactId>common</artifactId>
<version>1.0</version>
<properties>
<war.bundle>true</war.bundle>
</properties>
</dependency>
If, however, you are building a component jar, then you only need to specify the
dependency if it needs to be in your classpath during compile time. So, it
seems like you will in your case. Note: Make sure that you "install" the
dependency in your local repo ("maven jar:install") before you try to access
it.
> So, I'd have build/web-services where the common source would be built
> with the web-services src. (With nested <src> tags under javac)
I think the thing you want to focus on is what artifacts you wish to create.
Maven has had some controversy about whether to allow multiple source
directories in the same project. The general understanding is that you should
not do this, but you can if you want:
http://maven.apache.org/faq.html#multiple-source-directories
In most cases in makes more sense to keep the jars separate. So, your
web-services and xml-util jars would not contain the class files that are in
the common jar.
HTH,
Ben
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org