I use a set of parent poms to archive this. I have a directory structure
like this:

build
+ build-base
+ build-java
+ build-native

each build-* directory has a pom.xml. The base pom defines all things that
are valid for java and others. Then the build-java pom.xml defines
everything for java specific projects (like junit config, java specific
plugins like pmd, clover, ...).

This is my base pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycomp.build</groupId>
    <artifactId>build-base</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <build>
        <directory>temp</directory>
        <outputDirectory>temp/classes</outputDirectory>
        <testOutputDirectory>temp/test-classes</testOutputDirectory>
        <sourceDirectory>src/main</sourceDirectory>
        <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
        <testSourceDirectory>src/test</testSourceDirectory>
    </build>
</project>

Not the use of /project/build/directory set to "temp" in stead of "target"
and the packaging type of "pom"

Do a 'mvn install'. Then in my java pom:

<project xmlns="http://maven.apache.org/POM/4.0.0"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
    <parent>
        <groupId>com.mycomp.build</groupId>
        <artifactId>build-base</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycomp.build</groupId>
    <artifactId>build-java</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Note the <parent/> section here. In your real project use again a <parent/>
section, but now with this last one as the parent. I will automatically use
the "temp" directory in stead of target for your project.

regards,

Wim



2005/12/14, Slawek Zachcial <[EMAIL PROTECTED]>:
>
> Hi,
>
> I would like that all the generated files for all my m2 projects go to
> specific, different than default, build directory. For example, if I have
> projects P1 and P2, the default build directories are P1/target and
> P2/target. I'd like to change it to something like /temp/target.
>
> I don't want to modify every single pom.xml. I'd like to have this as a
> global, my environment specific setting.
>
> It looks like several of maven plugins base their build directory path on
> "project.build.directory" so I tried sth like "m2 -
> Dproject.build.directory=/temp/target package" but this has no effect.
>
> Is anyone aware any working way to achieve this - either through
> settings.xml or through -D or some other global approach?
>
> Thanks,
> /Slawek
>
>
>
> ---------------------------------
> Yahoo! Shopping
> Find Great Deals on Holiday Gifts at Yahoo! Shopping
>

Reply via email to