You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Gisbert Amm <gi...@webde.de> on 2007/08/09 17:14:19 UTC

How to activate profile for certain packaging?

I want to activate a profile for the packaging type war.

This is what I've tried without success:

<activation>
   <property>
     <name>pom.packaging</name>
     <value>war</value>
   </property>
</activation>

How can I achieve that?

-Gisbert

-- 
Gisbert Amm
Softwareentwickler Infrastruktur
Telefon: (0721) 91374 - 4224
Telefax: (0721) 91374 - 2740
E-Mail: gisbert.amm@1und1.de
Internet: www.1und1.de

1&1 Internet AG
Elgendorfer Strasse 57
56410 Montabaur

Amtsgericht Montabaur HRB 6484

Vorstand: Ralph Dommermuth, Matthias Ehrlich, Andreas Gauger 
(Vorsitzender), Matthias Greve, Henning Ahlert, Norbert Lang, Achim 
Weiss, Robert Hoffmann,
Aufsichtsratsvorsitzender: Michael Scheeren

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


Re: How to activate profile for certain packaging?

Posted by Gisbert Amm <gi...@webde.de>.
John Casey schrieb:
> Unfortunately, Maven 2.0.x doesn't support that particular type of 
> profile activation. We're working on a feature in the trunk 
> (2.1-SNAPSHOT, currently) that would allow you to bring in custom 
> profile activators via build extensions, however. A custom activator 
> could give you an avenue for this sort of profile activation...but it's 
> still not available in a released version of Maven.
> 

That's good news. For the moment, I use the following workaround, 
inspired by the sentence "Profiles listed in the activeProfiles tag 
would be activated by default everytime a project use it." on 
http://maven.apache.org/guides/introduction/introduction-to-profiles.html:

1) List my profile in "activeProfiles" in the global settings.xml
2) Use that profile only in the projects that build a war. These 
projects are generated from an archetype anyway, so I got everthing 
under perfect control.

Thank you,
-Gisbert Amm



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


Re: How to activate profile for certain packaging?

Posted by John Casey <jd...@commonjava.org>.
Unfortunately, Maven 2.0.x doesn't support that particular type of  
profile activation. We're working on a feature in the trunk (2.1- 
SNAPSHOT, currently) that would allow you to bring in custom profile  
activators via build extensions, however. A custom activator could  
give you an avenue for this sort of profile activation...but it's  
still not available in a released version of Maven.


Sorry,

-john

On Aug 10, 2007, at 9:08 AM, Gisbert Amm wrote:

> Michael Meyer schrieb:
>> Hi,
>> does this work?
>> <activation>
>>   <property>
>>     <name>project.packaging</name>
>>     <value>war</value>
>>   </property>
>> </activation>
>
> Unfortunately not.
>
> I'll describe my problem more generally instead of asking how to  
> fix my obviously wrong approach:
>
> I need to execute a specific, home grown deployment preparation  
> plugin only for projects that produce a war (<packaging>war</ 
> packaging>). How can I achieve that?
>
> My first thought was to use a profile. However, that does not work  
> because a profile cannot be activated throught POM entries like  
> <packaging>war</packaging>. I don't want to set an extra property  
> for that either since all information I need is already covered in  
> the <packaging> element and doesn't need to be duplicated.
>
> How do others implement conditional calls of certain plugins? How  
> is the Maven2 way to do that?
>
> -Gisbert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

---
John Casey
Committer and PMC Member, Apache Maven
mail: jdcasey at commonjava dot org
blog: http://www.ejlife.net/blogs/john



Re: How to activate profile for certain packaging?

Posted by Tim Kettler <ti...@udo.edu>.
You could create a war specific parent pom with the plugin execution 
defined.

-Tim

Gisbert Amm schrieb:
> Michael Meyer schrieb:
>> Hi,
>> does this work?
>>
>> <activation>
>>   <property>
>>     <name>project.packaging</name>
>>     <value>war</value>
>>   </property>
>> </activation>
> 
> Unfortunately not.
> 
> I'll describe my problem more generally instead of asking how to fix my 
> obviously wrong approach:
> 
> I need to execute a specific, home grown deployment preparation plugin 
> only for projects that produce a war (<packaging>war</packaging>). How 
> can I achieve that?
> 
> My first thought was to use a profile. However, that does not work 
> because a profile cannot be activated throught POM entries like 
> <packaging>war</packaging>. I don't want to set an extra property for 
> that either since all information I need is already covered in the 
> <packaging> element and doesn't need to be duplicated.
> 
> How do others implement conditional calls of certain plugins? How is the 
> Maven2 way to do that?
> 
> -Gisbert
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org


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


Re: How to activate profile for certain packaging?

Posted by Michael Meyer <mi...@netcetera.ch>.
Hi
if you have access to the source code of the plugin you can do something 
like this:

   /**
    * The packaging of this project.
    *
    * @parameter expression="${project.packaging}"
    * @required
    * @readonly
    */
   private String packaging;
		
   public void execute() throws MojoExecutionException {
     if (packaging.equals("war") {
       ...
     }
   }

Cheers, michael


Gisbert Amm wrote:
> Michael Meyer schrieb:
>> Hi,
>> does this work?
>>
>> <activation>
>>   <property>
>>     <name>project.packaging</name>
>>     <value>war</value>
>>   </property>
>> </activation>
> 
> Unfortunately not.
> 
> I'll describe my problem more generally instead of asking how to fix my 
> obviously wrong approach:
> 
> I need to execute a specific, home grown deployment preparation plugin 
> only for projects that produce a war (<packaging>war</packaging>). How 
> can I achieve that?
> 
> My first thought was to use a profile. However, that does not work 
> because a profile cannot be activated throught POM entries like 
> <packaging>war</packaging>. I don't want to set an extra property for 
> that either since all information I need is already covered in the 
> <packaging> element and doesn't need to be duplicated.
> 
> How do others implement conditional calls of certain plugins? How is the 
> Maven2 way to do that?
> 
> -Gisbert
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 

-- 
Michael Meyer | michael.meyer@netcetera.ch
phone +41-44-247 79 12 | fax +41-44-247 70 75
Netcetera AG | 8040 Zürich | Switzerland | http://netcetera.ch


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


Re: How to activate profile for certain packaging?

Posted by Gisbert Amm <gi...@webde.de>.
Michael Meyer schrieb:
> Hi,
> does this work?
> 
> <activation>
>   <property>
>     <name>project.packaging</name>
>     <value>war</value>
>   </property>
> </activation>

Unfortunately not.

I'll describe my problem more generally instead of asking how to fix my 
obviously wrong approach:

I need to execute a specific, home grown deployment preparation plugin 
only for projects that produce a war (<packaging>war</packaging>). How 
can I achieve that?

My first thought was to use a profile. However, that does not work 
because a profile cannot be activated throught POM entries like 
<packaging>war</packaging>. I don't want to set an extra property for 
that either since all information I need is already covered in the 
<packaging> element and doesn't need to be duplicated.

How do others implement conditional calls of certain plugins? How is the 
Maven2 way to do that?

-Gisbert

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


Re: How to activate profile for certain packaging?

Posted by Michael Meyer <mi...@netcetera.ch>.
Hi,
does this work?

<activation>
   <property>
     <name>project.packaging</name>
     <value>war</value>
   </property>
</activation>

Cheers, michael

Gisbert Amm wrote:
> I want to activate a profile for the packaging type war.
> 
> This is what I've tried without success:
> 
> <activation>
>   <property>
>     <name>pom.packaging</name>
>     <value>war</value>
>   </property>
> </activation>
> 
> How can I achieve that?
> 
> -Gisbert
> 

-- 
Michael Meyer | michael.meyer@netcetera.ch
phone +41-44-247 79 12 | fax +41-44-247 70 75
Netcetera AG | 8040 Zürich | Switzerland | http://netcetera.ch


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