You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Thomas Markus <t....@proventis.net> on 2010/02/05 12:39:41 UTC

question about profile inheritance

hi,

i try to define profiles in a parent pom and activate these profiles in
a child pom. its a little bit confusion.

in child project part1

mvn help:active-profiles

shows
 - test1 (source: pom)
 - base (source: settings.xml)

but a

mvn

doesn't runs my plugin (no inheritance)

but a

mvn -P test1

(expected to be same)

executes the plugin

what i'm missing here? i try to define profiles for different project
configurations.

regards
Thomas



parent 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>MavenTest</groupId>
    <artifactId>Main</artifactId>
    <packaging>pom</packaging>
    <version>0.0.1-SNAPSHOT</version>

    <modules>
        <module>part1</module>
    </modules>

    <build>
        <defaultGoal>initialize</defaultGoal>
    </build>

    <profiles>
        <profile>
            <id>test1</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>runtest1</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo
message="#########################################" />
                                        <echo message="lets run test1" />
                                        <echo
message="#########################################" />
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
------------------------------------------------------------------------

child 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>MavenTest</groupId>
    <artifactId>part1</artifactId>

    <parent>
        <groupId>MavenTest</groupId>
        <artifactId>Main</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>..</relativePath>
    </parent>

    <profiles>
        <profile>
            <id>test1</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
    </profiles>

</project>
------------------------------------------------------------------------


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


Re: question about profile inheritance

Posted by Thomas Markus <t....@proventis.net>.
i read this,

but the behaviour is not constistent. and how to define reusable
profiles for multiple projects?

thanks
Thomas


Am 05.02.2010 13:14, schrieb Jörg Schaible:
>
> [snip]
>
> Activation of a profile is either global if set by command line or activated 
> in the settings.xml, otherwise the activation is only local to the *current* 
> POM i.e. in your parent is not activated and the profile in your child POM 
> does actually not add something to the build.
>
> - Jörg
>
>
>
> ---------------------------------------------------------------------
> 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: question about profile inheritance

Posted by Jörg Schaible <jo...@gmx.de>.
Thomas Markus wrote at Freitag, 5. Februar 2010 12:39:

> hi,
> 
> i try to define profiles in a parent pom and activate these profiles in
> a child pom. its a little bit confusion.
> 
> in child project part1
> 
> mvn help:active-profiles
> 
> shows
>  - test1 (source: pom)
>  - base (source: settings.xml)
> 
> but a
> 
> mvn
> 
> doesn't runs my plugin (no inheritance)
> 
> but a
> 
> mvn -P test1
> 
> (expected to be same)
> 
> executes the plugin
> 
> what i'm missing here? i try to define profiles for different project
> configurations.

[snip]

> parent pom:
> 
> ------------------------------------------------------------------------

[snip]

>     <profiles>
>         <profile>
>             <id>test1</id>
>             <build>

[snip]

>             </build>
>         </profile>
>     </profiles>
> 
> </project>
> ------------------------------------------------------------------------
> 
> child pom:
> ------------------------------------------------------------------------

[snip]

>     <profiles>
>         <profile>
>             <id>test1</id>
>             <activation>
>                 <activeByDefault>true</activeByDefault>
>             </activation>
>         </profile>
>     </profiles>

[snip]

Activation of a profile is either global if set by command line or activated 
in the settings.xml, otherwise the activation is only local to the *current* 
POM i.e. in your parent is not activated and the profile in your child POM 
does actually not add something to the build.

- Jörg



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