atom feed3 messages in org.apache.maven.usersRe: Project-wide default profile?
FromSent OnAttachments
pjungwirJan 22, 2007 11:36 am 
Craig McClanahanJan 22, 2007 11:53 am 
pjungwirJan 22, 2007 12:02 pm 
Subject:Re: Project-wide default profile?
From:Craig McClanahan (crai@apache.org)
Date:Jan 22, 2007 11:53:08 am
List:org.apache.maven.users

On 1/22/07, pjungwir <mav@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/