Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-4735

File-based profile activation behaves differently in Maven 3

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 3.0-beta-1
    • None
    • Profiles
    • None
    • Ubuntu 10.04 64-bit, Windows XP 32-bit, Windows 7 64-bit
      Java 6

    Description

      I have a project with parent and child poms. The child pom has a profile that is activated by file existence. When running a multimodule build in the directory of the parent pom, the profile fails to activate when it should. Under Maven 2, the profile activates as expected. Example poms that demonstrate the problem are below. Put the first pom in the root of the project. Put the second pom in a subdirectory named "child". Then, in the project root, run "mvn antrun:run". With Maven 2, the output will be "profile property value". Under Maven 3, it will be "default property value".

      Note that the problem is unrelated to the antrun plugin. I'm just using it to demonstrate the behavior.

      pom.xml
      <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.foo</groupId>
          <artifactId>parent</artifactId>
          <packaging>pom</packaging>
          <version>1.0-SNAPSHOT</version>
          <modules>
              <module>child</module>
          </modules>
      </project>
      
      child/pom.xml
      <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>
          <artifactId>child</artifactId>
          <packaging>jar</packaging>
          <parent>
              <groupId>com.foo</groupId>
              <artifactId>parent</artifactId>
              <version>1.0-SNAPSHOT</version>
          </parent>
          <properties>
              <test.property>default property value</test.property>
          </properties>
          <build>
              <plugins>
                  <plugin>
                      <artifactId>maven-antrun-plugin</artifactId>
                      <version>1.3</version>
                      <executions>
                          <execution>
                              <id>default-cli</id>
                              <goals>
                                  <goal>run</goal>
                              </goals>
                              <configuration>
                                  <tasks>
                                      <echo message="Property value: [${test.property}]"/>
                                  </tasks>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
              </plugins>
          </build>
          <profiles>
              <profile>
                  <id>change-property-value</id>
                  <activation>
                      <file>
                          <exists>child/pom.xml</exists>
                      </file>
                  </activation>
                  <properties>
                      <test.property>profile property value</test.property>
                  </properties>
              </profile>
          </profiles>
      </project>
      

      Attachments

        Issue Links

          Activity

            People

              bentmann Benjamin Bentmann
              zzantozz Ryan Stewart
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: