You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by pjungwir <ma...@9stmaryrd.com> on 2007/01/22 20:36:41 UTC

Project-wide default profile?

Hello,

I know that profiles get discussed here all the time, but I just wanted to
confirm that the feature I want really doesn't exist. I want to create two
mutually-exclusive profiles. To build the project successfully, you must
activate one of these profiles. Therefore they should be in the pom.xml, not
the settings.xml. They are not activated by interrogating the environment;
you must specify one. But it's annoying to give a profile every time you run
maven. And new developers might not even know that specifying a profile is
required. So is there a way to make one the default? Even better, can the
project "come with" a default?

I tried using <activeProfiles> in my settings.xml, but that doesn't work,
because <activeProfiles> only applies to profiles defined in settings.xml,
but my profiles are defined in pom.xml. But even if that solution worked, it
wouldn't be that great, because I want to give developers a default as part
of their checkout. They shouldn't have to create the default themselves.

Does maven give me any way to do what I want? This seems like such a basic
and obvious requirement.

Thanks,
Paul

-- 
View this message in context: http://www.nabble.com/Project-wide-default-profile--tf3059791s177.html#a8508102
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Project-wide default profile?

Posted by pjungwir <ma...@9stmaryrd.com>.
Ah, thank you. The key is right here:

    <activation>
      <property>
        <name>!jsf</name>
      </property>
    </activation>

I didn't know you could activate a profile based on an *unset* property. But
that gives me just what I need.

Thanks again,
Paul

-- 
View this message in context: http://www.nabble.com/Project-wide-default-profile--tf3059791s177.html#a8508531
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Project-wide default profile?

Posted by Craig McClanahan <cr...@apache.org>.
On 1/22/07, pjungwir <ma...@9stmaryrd.com> wrote:
>
>
>
> Does maven give me any way to do what I want? This seems like such a basic
> and obvious requirement.


The POM for the shale-apps module[1] in Shale[2] has an example of exactly
the scenario you describe, showing the way we decided to approach this.

Shale is an add-on library on top of JavaServer Faces, and it can run with
any compatible implementation.  We wanted to provide sample apps that you
could easily build with any of the options, but (as you described) make one
of them the default.  With the settings shown below, we can select any of:

* "mvn clean install" -- Selects MyFaces 1.1 (the default)

* "mvn -Djsf=ri clean install" -- Selects the reference implementation 1.1

* "mvn -Djsf=ri12 clean install" -- Selects the reference implementatin 1.2,
  and includes it in the webapp for a non-JavaEE5 container.

* "mvn -Djsf=ee5 clean install" -- Selects the reference implemenation 1.2,
  and omits it from the webapp because JSF 1.2 is provided on an EE5
container.

The relevant bits of the pom.xml are:

<profiles>

  <!-- Apache MyFaces 1.1 (default) -->
  <profile>
    <id>myfaces</id>
    <activation>
      <property>
        <name>!jsf</name>
      </property>
    </activation>
    ...
  </profile>

  <!-- JSF RI 1.1 -->
  <profile>
    <id>jsfri</id>
    <activation>
      <property>
        <name>jsf</name>
        <value>ri</value>
      </property>
    </activation>
    ...
  </profile>

  <!-- JSF RI 1.2 (non-EE5 container) -->
  <profile>
    <id>jsfri12</id>
    <activation>
      <property>
        <name>jsf</name>
        <value>ri12</value>
      </property>
    </activation>
    ...
  </profile>

  <!-- JSF RI 1.2 (EE5 container) -->
  <profile>
    <id>jsfee5</id>
    <activation>
      <property>
        <name>jsf</name>
        <value>ee5</value>
      </property>
    </activation>
    ...
  </profile>

</profiles>

So, you indirectly choose a profile by passing a system property with a
specific value.

Craig

[1]
http://svn.apache.org/viewvc/shale/framework/trunk/shale-apps/pom.xml?view=markup
[2] http://shale.apache.org/