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

Add support for "lifecycle" activation for profiles

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Incomplete
    • 2.2.1
    • None
    • Profiles
    • Windows 7

    Description

      I have the following scenario: Initialization step is done in the default lifecycle "initialize" phase which sets properties that are used in later build phases. Unfortunately, the same properties need set in the "clean" lifecycle in order to use them in the clean phase. There is no way to easily run the same execution of plugins without duplication. However, it turns out very easy to manipulate the phase attribute in the following way:

      <profile>
      <id>default-phase</id>
      <activation>
      <property>
      <name>!clean-all</name>
      </property>
      </activation>
      <properties>
      <init-phase>initialize</init-phase>
      </properties>
      </profile>

      <profile>
      <id>clean-phase</id>
      <activation>
      <property>
      <name>clean-all</name>
      </property>
      </activation>
      <properties>
      <init-phase>pre-clean</init-phase>
      </properties>
      </profile>

      <profile>
      <id>plugin-config</id>
      <activation>
      <property>
      <name>java.version</name> <!-- Always on -->
      </property>
      </activation>
      <build>
      <plugins>
      <plugin>
      ... <!-- Whatever plugin -->
      <executions>
      <execution>
      <id>initialize properties</id>
      <goals><goal><!--The goal --></goal></goals>
      <phase>${init-phase}</phase>
      <configuration>
      <!-- The plugin config to use -->
      </configuration>
      </execution>
      </executions>
      </plugin>
      ...
      </plugins>
      </build>
      </profile>

      This will run the initialize step under initialize phase for default lifecycle and under pre-clean phase for clean lifecycle provided that the config information falls after the property set in a profile. However, the one issue I have with this is that it requires you to run Maven with -Dclean-all property on the command line. It would be even better if there was an activation for <lifecycle> that could be set to "default", "clean", "site", etc. Then, the activation can occur when that specific lifecycle is invoked during the build. As far as I can tell, there is no other way to determine this information.

      Attachments

        Activity

          People

            Unassigned Unassigned
            gmbaumgardner Gregory Baumgardner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: