You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by tpatch <tp...@loftware.com> on 2011/12/02 22:56:51 UTC

Profile - activeByDefault in Maven 3.0

Hi All,

I am currently upgrading to maven 3 from 2.  I have a settings.xml that I
have been using for a couple of years now.  It has a profile in it called
"dev" it looks something like this:

	<profiles>
		<profile>
			<id>dev</id>
			<activation>
				<activeByDefault>true</activeByDefault>
			</activation>

When I run "mvn clean install" in 2.0 it used this profile and all was well. 
Now when I run against Maven 3.0 this profile is not active.  I have to run
"mvn clean install -Pdev" to activate it.  I have searched online and tried
several things, the only thing that seemed to work was <activeProfiles>.  

Does this setting no longer work???

Thanks,

Todd

--
View this message in context: http://maven.40175.n5.nabble.com/Profile-activeByDefault-in-Maven-3-0-tp5043324p5043324.html
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: Profile - activeByDefault in Maven 3.0

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,
to activate your dev-profile you need to it a little bit tricky...

You need to define in the settings.xml a thing like the following:

        <profile>
          <id>test-dev</id>
          <activation>
            <activeByDefault>false</activeByDefault>
          </activation>
          <properties>
             <test.dev>yes</test.dev>
          </properties>
        </profile>

you can activate that profile by using activation rules (via existing 
file or properties etc.). or by activating it via

   <activeProfiles>
     <activeProfile>test-dev</activeProfile>
   </activeProfiles>

than you need to put a thing like this in your pom.xml:

   <profiles>
     <profile>
       <id>test-dev</id>
       <activation>
         <activeByDefault>false</activeByDefault>
         <property>
           <name>test.dev</name>
           <value>yes</value>
         </property>
       </activation>
       <modules>
         <module>sub-1</module>
       </modules>
     </profile>
   </profiles>

This will work as you expect it to work....

Kind regards
Karl Heinz Marbaise
-- 
SoftwareEntwicklung Beratung Schulung    Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl Heinz Marbaise        ICQ#: 135949029
Hauptstrasse 177                         USt.IdNr: DE191347579
52146 Würselen                           http://www.soebes.de

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


Re: Profile - activeByDefault in Maven 3.0

Posted by tpatch <tp...@loftware.com>.
Jorg,

Thanks for the reply.

Thanks for the tip on help:activeprofiles - it shows "dev" - so maybe I have
a different problem.

I created a simple set of projects using archetype:generate -  a parent
project and a child project for a multimodule project, parent builds child.

I ran some tests with and without the -Pdev setting.  It seems to only work
if I specify the -Pdev setting,  what am I missing here?

Thanks,

Todd

In the parent pom I have 

  <groupId>com.test</groupId>
  <artifactId>parent</artifactId>
  <packaging>pom</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>parent</name>
  <url>http://maven.apache.org</url>
  
  <profiles>
  <profile>
  <id>dev</id>
  <modules>
    <module>child</module>
  </modules>
  </profile>
  </profiles>

In the child I have

  <parent>
    <artifactId>parent</artifactId>
    <groupId>com.test</groupId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>com.loftware.test</groupId>
  <artifactId>child</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>childparent</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

When I run "mvn clean install" - I get the following

C:\dev\maven3test\parent>mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building parent 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ parent ---
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ parent ---
[INFO] Installing C:\dev\maven3test\parent\pom.xml to
C:\dev\maven\repo\com\test\parent\1.0-SNAPSHOT\parent-1.0-SNAPSHOT
.pom
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------

When, I run "mvn clean install -Pdev" i get

C:\dev\maven3test\parent>mvn clean install -Pdev
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] childparent
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building parent 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ parent ---
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ parent ---
[INFO] Installing C:\dev\maven3test\parent\pom.xml to
C:\dev\maven\repo\com\test\parent\1.0-SNAPSHOT\parent-1.0-SNAPSHOT
.pom
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building childparent 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------

[INFO] --- maven-jar-plugin:2.3.1:jar (default-jar) @ childparent ---
[INFO] Building jar:
C:\dev\maven3test\parent\childparent\target\childparent-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @
childparent ---
[INFO] Installing
C:\dev\maven3test\parent\childparent\target\childparent-1.0-SNAPSHOT.jar to
C:\dev\maven\repo\com\loft
ware\test\childparent\1.0-SNAPSHOT\childparent-1.0-SNAPSHOT.jar
[INFO] Installing C:\dev\maven3test\parent\childparent\pom.xml to
C:\dev\maven\repo\com\loftware\test\childparent\1.0-SN
APSHOT\childparent-1.0-SNAPSHOT.pom
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [0.484s]
[INFO] childparent ....................................... SUCCESS [1.965s]
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------


Running "mvn help:activeprofiles" gives me 

C:\dev\maven3test\parent>mvn help:active-profiles
[INFO] Scanning for projects...
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building parent 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.1.1:active-profiles (default-cli) @ parent
---
[INFO]
Active Profiles for Project 'com.test:parent:pom:1.0-SNAPSHOT':

The following profiles are active:

 - dev (source: settings.xml)



[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------

running "mvn active-profile -Pdev" gives me

C:\dev\maven3test\parent>mvn help:active-profiles -Pdev
[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] parent
[INFO] childparent
[INFO]
[INFO]
------------------------------------------------------------------------
[INFO] Building parent 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.1.1:active-profiles (default-cli) @ parent
---
[INFO]
Active Profiles for Project 'com.test:parent:pom:1.0-SNAPSHOT':

The following profiles are active:

 - dev (source: pom)
 - dev (source: settings.xml)



Active Profiles for Project
'com.loftware.test:childparent:jar:1.0-SNAPSHOT':

The following profiles are active:

 - dev (source: settings.xml)



[INFO]
------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] parent ............................................ SUCCESS [0.405s]
[INFO] childparent ....................................... SKIPPED
[INFO]
------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO]
------------------------------------------------------------------------









--
View this message in context: http://maven.40175.n5.nabble.com/Profile-activeByDefault-in-Maven-3-0-tp5043324p5044499.html
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: Profile - activeByDefault in Maven 3.0

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,

> activeByDefault always meant that this profile is only active if none other
> is. If you e.g. have added a profile for M3's site plugin to use the POM for
> M2 or M3, well, then you have now an active one ;-)
This is sorry to say simply wrong, cause if that would be true using 
activeByDefault would prevent activating more than one profile...

Based on mvn help:active-profiles i get the following output:

The following profiles are active:

  - maven-3 (source: pom)
  - snapshots (source: settings.xml)
  - dev-1 (source: settings.xml)
  - dev-2 (source: settings.xml)

whereas dev-1 and dev-2 are profiles which have been activated simply

        <profile>
          <id>dev-1</id>
          <activation>
            <activeByDefault>true</activeByDefault>
          </activation>
        </profile>
        <profile>
          <id>dev-2</id>
          <activation>
            <activeByDefault>true</activeByDefault>
          </activation>
        </profile>

furthermore the maven-3 profile contradicts exactly your statements.

Kind regards
Karl Heinz Marbaise
-- 
SoftwareEntwicklung Beratung Schulung    Tel.: +49 (0) 2405 / 415 893
Dipl.Ing.(FH) Karl Heinz Marbaise        ICQ#: 135949029
Hauptstrasse 177                         USt.IdNr: DE191347579
52146 Würselen                           http://www.soebes.de

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


Re: Profile - activeByDefault in Maven 3.0

Posted by Jörg Schaible <jo...@gmx.de>.
Hi Todd,

tpatch wrote:

> Hi All,
> 
> I am currently upgrading to maven 3 from 2.  I have a settings.xml that I
> have been using for a couple of years now.  It has a profile in it called
> "dev" it looks something like this:
> 
> <profiles>
> <profile>
> <id>dev</id>
> <activation>
> <activeByDefault>true</activeByDefault>
> </activation>
> 
> When I run "mvn clean install" in 2.0 it used this profile and all was
> well.
> Now when I run against Maven 3.0 this profile is not active.  I have to
> run
> "mvn clean install -Pdev" to activate it.  I have searched online and
> tried several things, the only thing that seemed to work was
> <activeProfiles>.
> 
> Does this setting no longer work???

activeByDefault always meant that this profile is only active if none other 
is. If you e.g. have added a profile for M3's site plugin to use the POM for 
M2 or M3, well, then you have now an active one ;-)

So, what does this print on console:
 mvn help:active-profiles

Cheers,
Jörg


BTW: I used therefore activeProfiles even in M2 ...


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