On Thu, Dec 15, 2011 at 11:21 AM, scabbage <[email protected]> wrote:
> Great! Thanks for the suggestions.
>
> The organization of my project is:
>
> parent
>   - module1
>   - module2
>
>
> Following your advice, I did:
>
> parent:
> <project>
>    <groupId>test</groupId>
>    <artifactId>parent</artifactId>
>    <version>1.0-SNAPSHOT</version>
>    <packaging>pom</packaging>
>
>    <modules>
>        <module>module1</module>
>        <module>module2</module>
>    </modules>
>
>    <dependency>
>        <groupId>org.springframework</groupId>
>        <artifactId>spring-context</artifactId>
>        <version>3.0.6.RELEASE</version>
>    </dependency>
> </project>
>
>
> module1:
> <project>
>    <parent>
>        <groupId>test</groupId>
>        <artifactId>parent</artifactId>
>        <version>1.0-SNAPSHOT</version>
>    </parent>
>
>    <artifactId>module1</artifactId>
>    <dependencies>
>        <dependency>
>            <groupId>test</groupId>
>            <artifactId>module2</artifactId>
>            <version>1.0-SNAPSHOT</version>
>        </dependency>
>    </dependencies>
> </project>
>
>
> module2:
> <project>
>    <parent>
>        <groupId>test</groupId>
>        <artifactId>parent</artifactId>
>        <version>1.0-SNAPSHOT</version>
>    </parent>
>
>    <artifactId>module2</artifactId>
>    <dependencies>
>        <dependency>
>            <groupId>foo</groupId>
>            <artifactId>bar</artifactId>
>            <version>1.0</version>
>            <exclusions>
>                <exclusion>
>                    <groupId>org.springframework</groupId>
>                    <artifactId>spring</artifactId>
>                </exclusion>
>            </exclusions>
>        </dependency>
>    </dependencies>
> </project>
>
> It works like a charm :)

I recommend that your parent stop using dependency and use depenencyManagement.
See http://maven.apache.org/ref/3.0.3/maven-model/maven.html
If you use dependency you are saying that any child of this project
MUST include any dependencies specified in the parent.

I also recommend that you removed ALL versions from your child poms.
Use the dependencyManagement section of the paren instead.  This
allows you to adjust version information in one place AND ensure that
no one is "slipping" in a new dependency under the radar.
If they try to slip a new dependency in the build will blow up since
the parent hasn't got that version defined.
I dont think enforcer can enforce this setup, its something you have
to actively manage - perhaps at least every release cycle.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to