You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jon Strayer <jo...@strayer.org> on 2007/06/15 19:38:04 UTC

Profiles

Is it possible to have a default profile that is activated only when no
other profile is activated?

-- 
Esse Quam Videre
To Be, rather than to Seem

RE: Profiles

Posted by "Wagner, James" <Ja...@RelayHealth.com>.

This works for a default profile arrangement. 

"mvn  compile"  will utilize the local profile and would be my default
profile.

"mvn -Denv=dev compile"    will use the dev profile.
but  "mvn -Denv=local compile"    will cause an error as the default
profile expects no values.

To test it out place different files in the src/main/resources-local &
src/main/resources-dev directories and see what appears in the target
folder.

<profiles>
  <!-- default PROFILE -->
  <!-- activation name !env forces local to run when no values supplied
-->
  <!-- do NOT add a value to the local profile for !env -->
    <profile>
      <id>local-env</id>
      <activation>
        <property>
          <name>!env</name>
        </property>
      </activation>
      <properties>
        <resources.home>src/main/resources-local</resources.home>
      </properties>
    </profile>
    
    <profile>
      <id>dev-env</id>
      <activation>
        <property>
          <name>env</name>
          <value>dev</value>
        </property>
      </activation>
      <properties>
         <resources.home>src/main/resources-dev</resources.home>
      </properties>
    </profile>
    
  </profiles>
  ...
  <build>        
    <resources>
      <resource>
        <directory>${resources.home}</directory>
        <includes>
          <include>**/*.properties</include>
        </includes>
        <targetPath>${resources.target}</targetPath>
      </resource>
    </resources>
         	
  </build>


Cheers,
Jim



-----Original Message-----
From: Chris Helck [mailto:Chris.Helck@us.icap.com] 
Sent: Friday, June 15, 2007 1:59 PM
To: Maven Users List
Subject: RE: Profiles

If you use activeByDefault then isn't the profile always active? I don't
believe you can have a default profile that is active if and only if no
other profile is active. If I'm wrong I'd love to know because I would
find this very useful.

Regards,
Christopher


-----Original Message-----
From: Arnaud HERITIER [mailto:aheritier@gmail.com] 
Sent: Friday, June 15, 2007 2:02 PM
To: Maven Users List
Subject: Re: Profiles

yes you have to set the activeByDefault to true
http://maven.apache.org/ref/2.0.4/maven-settings/settings.html#class_act
ivation

Arnaud

On 15/06/07, Jon Strayer <jo...@strayer.org> wrote:
>
> Is it possible to have a default profile that is activated only when 
> no other profile is activated?
>
> --
> Esse Quam Videre
> To Be, rather than to Seem
>



--
..........................................................
Arnaud HERITIER
..........................................................
OCTO Technology - aheritier@octo.com
www.octo.com | blog.octo.com
..........................................................
ASF - aheritier@apache.org
www.apache.org | maven.apache.org
...........................................................

**********************************************************************
This communication and all information (including, but not limited to,
 market prices/levels and data) contained therein (the "Information") is
 for informational purposes only, is confidential, may be legally
 privileged and is the intellectual property of ICAP plc and its
affiliates
 ("ICAP") or third parties. No confidentiality or privilege is waived or
 lost by any mistransmission. The Information is not, and should not
 be construed as, an offer, bid or solicitation in relation to any
 financial instrument or as an official confirmation of any transaction.
 The Information is not warranted, including, but not limited, as to
 completeness, timeliness or accuracy and is subject to change
 without notice. ICAP assumes no liability for use or misuse of the
 Information. All representations and warranties are expressly
 disclaimed. The Information does not necessarily reflect the views of
 ICAP. Access to the Information by anyone else other than the
 recipient is unauthorized and any disclosure, copying, distribution or
 any action taken or omitted to be taken in reliance on it is
prohibited. If
 you receive this message in error, please immediately delete it and all
 copies of it from your system, destroy any hard copies of it and
 notify the sender.
**********************************************************************


---------------------------------------------------------------------
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: Profiles

Posted by Nathan Maves <na...@gmail.com>.
I too am looking for a similar solution for my problem.

I have have 3 profiles right now.  (dev/uat/prod)

To accomplish this I have each profile set a variable called 'env'.  I then
have a dynamic resource directory used based on this env variable.  The only
issue I have is that I need one of these 3 profiles to be used to create a
successful build.  Here is how I setup the resources.

        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/resources-${env}</directory>
            </resource>
        </resources>

I have tried to place the resources that I want in the default profile into
the standard 'resources' directory but these files are then not overwritten
if a profile is actually selected.  If there was some way to have a default
profile if none is selected then this would be perfect for us.

Here is a simple test case that I used.

./resources/file1
./resources/file2

./resources-prod/file1
./resources-prod/file3

If I select to use the prod profile then I end up with

./target/classes/file1 (from ./resources)
./target/classes/file2 (from ./resources)
./target/classes/file3 (from ./resources-prod)

I would expect to see

./target/classes/file1 (from ./resources)
./target/classes/file2 (from ./resources-prod)
./target/classes/file3 (from ./resources-prod)

If if there is not a solution to this having the ability to force the
developer to use a profile would work as well. Maybe some sort of arrest
that a profile was selected.

So in the end, like Chis stated, I would love a solution to this problem.

Nathan
On 6/15/07, Chris Helck <Ch...@us.icap.com> wrote:
>
> If you use activeByDefault then isn't the profile always active? I don't
> believe you can have a default profile that is active if and only if no
> other profile is active. If I'm wrong I'd love to know because I would
> find this very useful.
>
> Regards,
> Christopher
>
>
> -----Original Message-----
> From: Arnaud HERITIER [mailto:aheritier@gmail.com]
> Sent: Friday, June 15, 2007 2:02 PM
> To: Maven Users List
> Subject: Re: Profiles
>
> yes you have to set the activeByDefault to true
> http://maven.apache.org/ref/2.0.4/maven-settings/settings.html#class_act
> ivation
>
> Arnaud
>
> On 15/06/07, Jon Strayer <jo...@strayer.org> wrote:
> >
> > Is it possible to have a default profile that is activated only when
> > no other profile is activated?
> >
> > --
> > Esse Quam Videre
> > To Be, rather than to Seem
> >
>
>
>
> --
> ..........................................................
> Arnaud HERITIER
> ..........................................................
> OCTO Technology - aheritier@octo.com
> www.octo.com | blog.octo.com
> ..........................................................
> ASF - aheritier@apache.org
> www.apache.org | maven.apache.org
> ...........................................................
>
> **********************************************************************
> This communication and all information (including, but not limited to,
> market prices/levels and data) contained therein (the "Information") is
> for informational purposes only, is confidential, may be legally
> privileged and is the intellectual property of ICAP plc and its affiliates
> ("ICAP") or third parties. No confidentiality or privilege is waived or
> lost by any mistransmission. The Information is not, and should not
> be construed as, an offer, bid or solicitation in relation to any
> financial instrument or as an official confirmation of any transaction.
> The Information is not warranted, including, but not limited, as to
> completeness, timeliness or accuracy and is subject to change
> without notice. ICAP assumes no liability for use or misuse of the
> Information. All representations and warranties are expressly
> disclaimed. The Information does not necessarily reflect the views of
> ICAP. Access to the Information by anyone else other than the
> recipient is unauthorized and any disclosure, copying, distribution or
> any action taken or omitted to be taken in reliance on it is prohibited.
> If
> you receive this message in error, please immediately delete it and all
> copies of it from your system, destroy any hard copies of it and
> notify the sender.
> **********************************************************************
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

RE: Profiles

Posted by Chris Helck <Ch...@us.icap.com>.
If you use activeByDefault then isn't the profile always active? I don't
believe you can have a default profile that is active if and only if no
other profile is active. If I'm wrong I'd love to know because I would
find this very useful.

Regards,
Christopher


-----Original Message-----
From: Arnaud HERITIER [mailto:aheritier@gmail.com] 
Sent: Friday, June 15, 2007 2:02 PM
To: Maven Users List
Subject: Re: Profiles

yes you have to set the activeByDefault to true
http://maven.apache.org/ref/2.0.4/maven-settings/settings.html#class_act
ivation

Arnaud

On 15/06/07, Jon Strayer <jo...@strayer.org> wrote:
>
> Is it possible to have a default profile that is activated only when 
> no other profile is activated?
>
> --
> Esse Quam Videre
> To Be, rather than to Seem
>



--
..........................................................
Arnaud HERITIER
..........................................................
OCTO Technology - aheritier@octo.com
www.octo.com | blog.octo.com
..........................................................
ASF - aheritier@apache.org
www.apache.org | maven.apache.org
...........................................................

**********************************************************************
This communication and all information (including, but not limited to,
 market prices/levels and data) contained therein (the "Information") is
 for informational purposes only, is confidential, may be legally
 privileged and is the intellectual property of ICAP plc and its affiliates
 ("ICAP") or third parties. No confidentiality or privilege is waived or
 lost by any mistransmission. The Information is not, and should not
 be construed as, an offer, bid or solicitation in relation to any
 financial instrument or as an official confirmation of any transaction.
 The Information is not warranted, including, but not limited, as to
 completeness, timeliness or accuracy and is subject to change
 without notice. ICAP assumes no liability for use or misuse of the
 Information. All representations and warranties are expressly
 disclaimed. The Information does not necessarily reflect the views of
 ICAP. Access to the Information by anyone else other than the
 recipient is unauthorized and any disclosure, copying, distribution or
 any action taken or omitted to be taken in reliance on it is prohibited. If
 you receive this message in error, please immediately delete it and all
 copies of it from your system, destroy any hard copies of it and
 notify the sender.
**********************************************************************


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


Re: Profiles

Posted by Arnaud HERITIER <ah...@gmail.com>.
yes you have to set the activeByDefault to true
http://maven.apache.org/ref/2.0.4/maven-settings/settings.html#class_activation

Arnaud

On 15/06/07, Jon Strayer <jo...@strayer.org> wrote:
>
> Is it possible to have a default profile that is activated only when no
> other profile is activated?
>
> --
> Esse Quam Videre
> To Be, rather than to Seem
>



-- 
..........................................................
Arnaud HERITIER
..........................................................
OCTO Technology - aheritier@octo.com
www.octo.com | blog.octo.com
..........................................................
ASF - aheritier@apache.org
www.apache.org | maven.apache.org
...........................................................