You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Lewis, Eric" <Er...@ipi.ch> on 2008/11/24 11:03:38 UTC

Profiles: active is not the same as used?

Hi

I think there's something I apparently don't understand regarding
profiles and properties.

My idea was the following:
We have a couple of profiles containing configuration (application
server etc.), they're 'local', 'development' etc.

Now, since we develop on Windows but all other platforms are Linux
(including our build server), I thought that I could activate the used
default profile in settings.xml using the OS name:

  <profiles>
    <profile>
      <id>development</id>
      <activation>
        <os>
          <family>unix</family>
        </os>
      </activation>
    </profile>

    <profile>
      <id>local</id>
      <activation>
        <os>
          <family>windows</family>
        </os>
      </activation>
    </profile>
  </profiles>

So, in fact the developer and the normal build wouldn't have to specify
a profile, it would be 'local' for developers and 'development' on the
build server.


However, I noticed that the two following commands don't result in the
same POM (they were run on the build server):

mvn help:active-profiles help:effective-pom

mvn help:active-profiles help:effective-pom -Pdevelopment



In the first case, I get

The following profiles are active:

 - development (source: settings.xml)

In the second case, I get

The following profiles are active:

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



As for the effective POM, in the first case:

    <profile>
      <id>development</id>
      <properties>
        <appserver.domain.name>foobar</appserver.domain.name>
        <jndi.url>jnp://${appserver.domain.name}:1099</jndi.url>
      </properties>
    </profile>
...
  <properties>
    <source.version>1.6</source.version>
  </properties>


In the second case:

    <profile>
      <id>development</id>
      <properties>
        <appserver.domain.name>foobar</appserver.domain.name>
        <jndi.url>jnp://foobar:1099</jndi.url>
      </properties>
    </profile>
...
  <properties>
    <appserver.domain.name>foobar</appserver.domain.name>
    <jndi.url>jnp://foobar:1099</jndi.url>
    <source.version>1.6</source.version>
  </properties>


Clearly, the second version is what I want, but I don't want to have to
specify the profile all the time when I could use some default
activation. 'activeByDefault' doesn't work, because it's _always_
active. It seems that for a profile, 'active' is not the same as
'used'... ??

Thanks for any help that lets me see clearer how Maven handles
properties/profiles.

Best regards,
Eric

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