Maven
  1. Maven
  2. MNG-3309

Is it possible to trigger profiles from profiles

    Details

    • Type: New Feature New Feature
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.7
    • Fix Version/s: 3.x / Backlog
    • Component/s: Profiles
    • Labels:
      None

      Description

      I want include profiles from profiles ... a example ... please tell me if this is nonsense

      <profiles>
      
          <!-- my default-profile ... this profile defines properties .... so i try to include other property-triggered-profiles -->
          <profile>
            <id>default</id>
            <activation>
              <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
              <!-- include profile tomcat6 -->
              <tomcat>6</tomcat>
              <!-- include profile myfaces12 -->
              <jsf>myfaces12</jsf>
             <!-- include profile richfaces -->
              <richfaces>true</richfaces>
             <!-- don't include profile seam -->
              <seam>false</seam>
            </properties>
          </profile>
      
          <profile>
            <!-- 
              JBoss Seam JSF framework : -Dseam=yes 
            -->
            <id>seam</id>
            <activation>
              <activeByDefault>false</activeByDefault>
              <property>
                <name>seam</name>
                <value>true</value>
              </property>
            </activation>
            ...
          </profile>
      
          <profile>
            <!-- 
              JBoss Richfaces Component Lib for JSF : -Drichfaces=true 
            -->
            <id>richfaces</id>
            <activation>
              <activeByDefault>false</activeByDefault>
              <property>
                <name>richfaces</name>
                <value>true</value>
              </property>
            </activation>
            ...
          </profile>
      
          <profile>
            <!-- 
              MyFaces JSF Implementation 1.2 : -Djsf=myfaces12 
            -->
            <id>myfaces12</id>
            <activation>
              <activeByDefault>false</activeByDefault>
              <property>
                <name>jsf</name>
                <value>myfaces12</value>
              </property>
            </activation>
            ...
          </profile>
      
          <profile>
            <!-- 
              MyFaces JSF Implementation 1.1 : -Djsf=myfaces11 
            -->
            <id>myfaces11</id>
            <activation>
              <activeByDefault>false</activeByDefault>
              <property>
                <name>jsf</name>
                <value>myfaces11</value>
              </property>
            </activation>
            ...
          </profile>
      
          <profile>
            <!-- 
              Sun's JSF Reference Implementation 1.2 : -Djsf=ri12
            -->
            <id>jsfri12</id>
            <activation>
              <activeByDefault>false</activeByDefault>
              <property>
                <name>jsf</name>
                <value>ri12</value>
              </property>
            </activation>
            ....
          </profile>
      
          <profile>
            <!-- 
              Tomcat 5.x Environment : -Dtomcat=5
            -->
            <id>tomcat5</id>
            <activation>
              <activeByDefault>false</activeByDefault>
              <property>
                <name>tomcat</name>
                <value>5</value>
              </property>
            </activation>
            <build>
              <defaultGoal>jetty:run</defaultGoal>
            </build>
            <dependencies>
              <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.4</version>
                <scope>provided</scope>
              </dependency>
              <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>jsp-api</artifactId>
                <version>2.0</version>
                <scope>provided</scope>
              </dependency>
              <dependency>
                <groupId>javax.el</groupId>
                <artifactId>el-api</artifactId>
                <version>1.0</version>
              </dependency>
              <dependency>
                <groupId>el-impl</groupId>
                <artifactId>el-impl</artifactId>
                <version>1.0</version>
              </dependency>
            </dependencies>
          </profile>
      
          <profile>
            <!-- 
              Tomcat 6.x Environment : -Dtomcat=6
            -->
            <id>tomcat6</id>
            <activation>
              <activeByDefault>false</activeByDefault>
              <property>
                <name>tomcat</name>
                <value>6</value>
              </property>
            </activation>
            <build>
              <defaultGoal>jetty:run</defaultGoal>
            </build>
            <dependencies>
              <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
                <version>2.5</version>
                <scope>provided</scope>
              </dependency>
              <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>jsp-api</artifactId>
                <version>2.1</version>
                <scope>provided</scope>
              </dependency>
              <dependency>
                <groupId>javax.el</groupId>
                <artifactId>el-api</artifactId>
                <version>1.0</version>
                <scope>provided</scope>
              </dependency>
              <dependency>
                <groupId>el-impl</groupId>
                <artifactId>el-impl</artifactId>
                <version>1.0</version>
                <scope>provided</scope>
              </dependency>
            </dependencies>
          </profile>
      ...
      
      'mvn -Pdefault eclipse:eclipse'  should create a tomcat6, myfaces12, richfaces project
      'mvn -Pdevel eclipse:eclipse'  should create a tomcat5, myfaces12, richfaces project
      'mvn -Pproductiv eclipse:eclipse'  should create a jboss, myfaces12, richfaces project
      ....
      

      any ideas?

        Issue Links

          Activity

          Hide
          Brett Porter added a comment -

          not possible, but some sort of feature that enables this use case to reduce duplication makes sense

          Show
          Brett Porter added a comment - not possible, but some sort of feature that enables this use case to reduce duplication makes sense
          Hide
          Vladimir Konkov added a comment - - edited

          Current implementation with properties (MNG-2276) is useles in real projects. Below the simple example:
          from pom.xml:

          <profiles>
          <profile>
          <id>db-mysql</id>
          <activation>
          <property>
          <name>db.type</name>
          <value>mysql</value>
          </property>
          </activation>
          <properties>
          <db.driver>MySQL</db.driver>
          </properties>
          </profile>
          <profile>
          <id>db-postgre</id>
          <activation>
          <property>
          <name>db.type</name>
          <value>postgresql</value>
          </property>
          </activation>
          <properties>
          <db.host>PostgreSQL</db.host>
          </properties>
          </profile>
          <profile>
          <id>prod</id>
          <properties>
          <db.type>postgresql</db.type>
          <server.type>tomcat</server.type>
          </properties>
          </profile>
          </profiles>

          $ mvn3 package -P prod

          Property db.host are'nt set.

          I can't move that logic into settings because it's project scope. I've minimum 3 dimensions of profiles (db,app server,data dir) in my projects and as now is no way to implement effective buid process with maven.

          Maven is near it 3 version but missed some critical future: profile activation by other profile. It's so simple and so essential future...

          PS: Is there any questions why big multienviroment projects (Alfresco, Liferay etc) not moved to maven until now?

          Show
          Vladimir Konkov added a comment - - edited Current implementation with properties ( MNG-2276 ) is useles in real projects. Below the simple example: from pom.xml: <profiles> <profile> <id>db-mysql</id> <activation> <property> <name>db.type</name> <value>mysql</value> </property> </activation> <properties> <db.driver>MySQL</db.driver> </properties> </profile> <profile> <id>db-postgre</id> <activation> <property> <name>db.type</name> <value>postgresql</value> </property> </activation> <properties> <db.host>PostgreSQL</db.host> </properties> </profile> <profile> <id>prod</id> <properties> <db.type>postgresql</db.type> <server.type>tomcat</server.type> </properties> </profile> </profiles> $ mvn3 package -P prod Property db.host are'nt set. I can't move that logic into settings because it's project scope. I've minimum 3 dimensions of profiles (db,app server,data dir) in my projects and as now is no way to implement effective buid process with maven. Maven is near it 3 version but missed some critical future: profile activation by other profile. It's so simple and so essential future... PS: Is there any questions why big multienviroment projects (Alfresco, Liferay etc) not moved to maven until now?
          Hide
          Victor Nazarov added a comment -

          I've developed an extention to provide this functionality.

          https://github.com/sviperll/maven-profiledep-extention

          Show
          Victor Nazarov added a comment - I've developed an extention to provide this functionality. https://github.com/sviperll/maven-profiledep-extention
          Hide
          Victor Nazarov added a comment -

          Still missing peace is an ability to explicitly activate profiles from pom.xml, like MNG-5408.

          Show
          Victor Nazarov added a comment - Still missing peace is an ability to explicitly activate profiles from pom.xml, like MNG-5408 .
          Hide
          Gordon Pettey added a comment -

          I have several profiles to affect javadoc and install plugins and select dev or prod deployment and alter manifest depending on whether bamboo or Jenkins is detected (or another manifest by default for no-ci). Because maven kills "default" profiles as soon as any one is conditionally activated, nor has support for one profile causing others to be enabled or disabled, it is impossible to actually make use of activation properties. This should be in core, not require an extension.

          Show
          Gordon Pettey added a comment - I have several profiles to affect javadoc and install plugins and select dev or prod deployment and alter manifest depending on whether bamboo or Jenkins is detected (or another manifest by default for no-ci). Because maven kills "default" profiles as soon as any one is conditionally activated, nor has support for one profile causing others to be enabled or disabled, it is impossible to actually make use of activation properties. This should be in core, not require an extension.

            People

            • Assignee:
              Unassigned
              Reporter:
              Andreas Höhmann
            • Votes:
              13 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:

                Development