You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stanimir Stamenkov <s7...@netscape.net> on 2011/10/13 23:29:49 UTC

Activate profile with property set in a file

I'm trying to activate a build profile in a project, like:

   <profiles>
     <profile>
       <id>unpack</id>
       <activation>
         <property>
           <name>dev.explode</name>
           <value>yes</value>
         </property>
       </activation>
       <build>
         <pluginManagement>
           <plugins>
             ...
           </plugins>
         </pluginManagement>
       </build>
     </profile>
   </profiles>

Specifying the system property on the command-line like:

mvn package -D dev.explode=yes

seems to trigger the profile o.k. but I would like to have that 
configured in a build.properties file which gets read by the build. 
  So I've tried the Properties Maven Plugin [1] by including it in 
the default build:

   <plugin>
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>properties-maven-plugin</artifactId>
     <version>1.0-alpha-2</version>
     <executions>
       <execution>
         <phase>initialize</phase>
         <goals>
           <goal>read-project-properties</goal>
         </goals>
         <configuration>
           <files>
             <file>build.properties</file>
           </files>
         </configuration>
       </execution>
     </executions>
   </plugin>

I didn't appear to have any effect and I've realized project and 
system properties might be different beasts, and trying to include 
the property like:

   <properties>
     <dev.explode>yes</dev.explode>
   </properties>

didn't change anything - the profile doesn't get activated.  I've 
further tried moving the execution of the properties plugin to the 
validate phase, and using its set-system-properties goal:

   <plugin>
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>properties-maven-plugin</artifactId>
     <version>1.0-alpha-2</version>
     <executions>
       <execution>
         <phase>validate</phase>
         <goals>
           <goal>set-system-properties</goal>
         </goals>
         <configuration>
           <properties>
             <property>
               <name>dev.explode</name>
               <value>yes</value>
             </property>
           </properties>
         </configuration>
       </execution>
     </executions>
   </plugin>

with no luck.  Does one have experience with using external 
properties file for the purposes of configuring the activation of 
profiles?

[1] http://mojo.codehaus.org/properties-maven-plugin/

-- 
Stanimir

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


Re: Activate profile with property set in a file

Posted by Jörg Schaible <jo...@gmx.de>.
Manfred Moser wrote:

> If you really have to do it a non maven way you can use the properties
> plugin ..

Maybe you start again with the beginning of the thread ...

- Jörg


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


Re: Activate profile with property set in a file

Posted by Manfred Moser <ma...@mosabuam.com>.
If you really have to do it a non maven way you can use the properties 
plugin ..

On 11-10-15 10:45 AM, Ansgar Konermann wrote:
> You could use project specific settings.xml, using command line switch -s.
> Not sure if this fits your use case though.
> Am 15.10.2011 18:35 schrieb "Stanimir Stamenkov"<s7...@netscape.net>:
>
>> Fri, 14 Oct 2011 09:35:26 +0200, /Jörg Schaible/:
>>
>>   Any property used
>>> to activate a profile must be given on the command line or be defined in
>>> the
>>> settings.xml.
>>>
>> Thanks.  That confirms my suspicions.  The point I want properties read
>> from external file, but not settings.xml, is to maintain a configuration
>> specific to a project.  Using setting.xml for all projects could cause
>> conflicts if two projects use the same named property for different
>> purposes, or one just wants two projects configured differently.  Having to
>> always specify the properties on the command-line is not the best
>> convenience, also.
>>
>> --
>> Stanimir
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@maven.**apache.org<us...@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: Activate profile with property set in a file

Posted by Wayne Fay <wa...@gmail.com>.
> Thanks.  I haven't realized it is possible.  My ultimate goal is not
having to specify anything more than 'mvn clean/compile/package/install' on
the command-line, but if it's not otherwise possible specifying '-s
settings.xml' additionally could be bearable.

Nothing stops you from altering mvn.bat and mvn.sh so that it looks for and
uses settings.xml if one is in the same dir by activating -s in the
batch/shell script. Then you could "just" type mvn compile etc.

Wayne

Re: Activate profile with property set in a file

Posted by Stanimir Stamenkov <s7...@netscape.net>.
Sat, 15 Oct 2011 19:45:25 +0200, /Ansgar Konermann/:
> Am 15.10.2011 18:35 schrieb "Stanimir Stamenkov":
>
>> The point I want properties read
>> from external file, but not settings.xml, is to maintain a configuration
>> specific to a project.  Using setting.xml for all projects could cause
>> conflicts if two projects use the same named property for different
>> purposes, or one just wants two projects configured differently.  Having to
>> always specify the properties on the command-line is not the best
>> convenience, also.
>
> You could use project specific settings.xml, using command line switch -s.
> Not sure if this fits your use case though.

Thanks.  I haven't realized it is possible.  My ultimate goal is not 
having to specify anything more than 'mvn 
clean/compile/package/install' on the command-line, but if it's not 
otherwise possible specifying '-s settings.xml' additionally could 
be bearable.

-- 
Stanimir

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


Re: Activate profile with property set in a file

Posted by Ansgar Konermann <an...@googlemail.com>.
You could use project specific settings.xml, using command line switch -s.
Not sure if this fits your use case though.
Am 15.10.2011 18:35 schrieb "Stanimir Stamenkov" <s7...@netscape.net>:

> Fri, 14 Oct 2011 09:35:26 +0200, /Jörg Schaible/:
>
>  Any property used
>> to activate a profile must be given on the command line or be defined in
>> the
>> settings.xml.
>>
>
> Thanks.  That confirms my suspicions.  The point I want properties read
> from external file, but not settings.xml, is to maintain a configuration
> specific to a project.  Using setting.xml for all projects could cause
> conflicts if two projects use the same named property for different
> purposes, or one just wants two projects configured differently.  Having to
> always specify the properties on the command-line is not the best
> convenience, also.
>
> --
> Stanimir
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@maven.**apache.org<us...@maven.apache.org>
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Activate profile with property set in a file

Posted by Stanimir Stamenkov <s7...@netscape.net>.
Fri, 14 Oct 2011 09:35:26 +0200, /Jörg Schaible/:

> Any property used
> to activate a profile must be given on the command line or be defined in the
> settings.xml.

Thanks.  That confirms my suspicions.  The point I want properties 
read from external file, but not settings.xml, is to maintain a 
configuration specific to a project.  Using setting.xml for all 
projects could cause conflicts if two projects use the same named 
property for different purposes, or one just wants two projects 
configured differently.  Having to always specify the properties on 
the command-line is not the best convenience, also.

-- 
Stanimir

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


Re: Activate profile with property set in a file

Posted by Jörg Schaible <jo...@scalaris.com>.
Hi,

Stanimir Stamenkov wrote:

[snip]

> with no luck.  Does one have experience with using external
> properties file for the purposes of configuring the activation of
> profiles?
> 
> [1] http://mojo.codehaus.org/properties-maven-plugin/

It does simply not work this way. One of the first things Maven does when 
reading a POM is to evaluate the profiles to setup the final project 
description. After that phase it starts the lifecycle where plugins might be 
called. So it is simply not possible to activate a profile based on a 
property set by a plugin. You may not even set a property in a profile of a  
parent pom and use that to activate a profile in a child. Any property used 
to activate a profile must be given on the command line or be defined in the 
settings.xml.

- Jörg



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