maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe Le Marchand" <plemarch...@noctis.be>
Subject Re: profile inheritance and activation
Date Thu, 06 Sep 2007 15:14:54 GMT
Hi ossi, thank you very much for your reaction, I just figured it out
searching in Nabble's archives, so I prepared myself to ask for help
on what I needed instead of how to inherit profiles to accomplish it
:-)

So the idea is to:

- access the filter properties file corresponding to the target environment
- override waven war plugin behaviour for local deployment only (that
is setting another webapp directory than the Maven's default
target/artifactId)
- activate the local profile by default if none is provided through
the CLI (with -P profileId).

I've got several filter properties files under parent/src/main/filters:

- filter-local.properties
- filter-dev.properties

and I would like the path to the deploy folder of my AS (JBoss) user dependent.

Here are more relevant extracts:


*** parent POM ***
  <build>
    <filters>
      <filter>${parent.relativePath}/src/main/filters/filter-${env}.properties</filter>
    </filters>
  </build>

  <profiles>
    <profile>
      <id>local</id>
      <properties>
        <env>local</env>
      </properties>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-war-plugin</artifactId>
              <configuration>

<webappDirectory>${appserver.deploy}/${build.finalName}.war</webappDirectory>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>dev</id>
      <properties>
        <env>dev</env>
      </properties>
    </profile>
  </profiles>

*** moduleN POM ***
  <build>
    <resources>
      <resource>
        <filtering>true</filtering>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
  </build>

*** user's settings.xml ***
  <profiles>
    <profile>
      <id>local</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <properties>
        <appserver.deploy>/path/to/deploy/folder</appserver.deploy>
      </properties>
    </profile>
  </profiles>


When launching the CLI 'mvn install' in a module or the parent,
everything works fine, but with 'mvn install -P dev' it seems that the
'local' profile (activeByDefault) is not deactivated.
The 'env' property is ok, as the right filter properties file is
chosen, but it still assemble the webapp under 'appserver.deploy',
which is not asked (see pluginManagement under 'local' profile) and
the property itself shouldn't be set (see user's settings.xml).

I've found the following interesting issue in Jira:

http://jira.codehaus.org/browse/MNG-2136

But I still don't understand why the 'local' profile is not deactivated.
If not possible, should there be another way to meet my needs?

Thanks,

Philippe


On 9/6/07, ossi petz <ossipetz@hallo.ms> wrote:
> hallo
>
> the profiles are not inherited to child modules, but the effects are. so
> the child will not show the profile as active but it will work nontheless.
>
> see: http://www.nabble.com/Profile-inheritance-tf2953156s177.html#a8259757
> for a better explanation
>
> regards
> ossi
>
>
>
> Philippe Le Marchand schrieb:
> > Hi all,
> >
> > This is my first post, necessary as I can't find an answer in the archives ;-)
> >
> > I'm trying to define profiles, mainly for filtering purpose, on
> > different modules of my project: local, test and prod, for instance.
> > I configured my project and modules with inheritance and aggregation,
> > which is working fine except that profiles defined in the parent's POM
> > doesn't seem to be inherited by its modules.
> >
> > Here is an extract from the parent's POM:
> >
> >
> >   <groupId>parent-groupId</groupId>
> >   <artifactId>parent-artifactId</artifactId>
> >   <packaging>pom</packaging>
> >   <version>1.0-SNAPSHOT</version>
> >
> >   <modules>
> >     <module>../module1</module>
> >     <module>../module2</module>
> >   </modules>
> >
> >   <profiles>
> >     <profile>
> >       <id>local</id>
> >       <properties>
> >         <env>local</env>
> >       </properties>
> >     </profile>
> >     <profile>
> >       <id>dev</id>
> >       <properties>
> >         <env>dev</env>
> >       </properties>
> >     </profile>
> >   </profiles>
> >
> > Here is an extract from the module1's POM:
> >
> >
> >   <parent>
> >     <groupId>parent-groupId</groupId>
> >     <artifactId>parent-artifactId</artifactId>
> >     <version>1.0-SNAPSHOT</version>
> >     <relativePath>../parent</relativePath>
> >   </parent>
> >
> >   <groupId>module1-groupId</groupId>
> >   <artifactId>module1-artifactId</artifactId>
> >   <packaging>jar</packaging>
> >   <version>1.0-SNAPSHOT</version>
> >
> >
> > The module2's POM is the same with 'module2' as ids and 'war' as packaging.
> >
> > When launching the following CLI in the parent's base dir :
> >
> >
> > mvn help:active-profiles -P local
> >
> >
> > I see :
> >
> >
> > Active Profiles for Project 'parent-groupId:parent-artifactId:pom:1.0-SNAPSHOT':
> >
> > The following profiles are active:
> >
> > - local (source: pom)
> > - alwaysActiveProfile (source: settings.xml)
> >
> > Active Profiles for Project
> > 'module1-groupId:module1-artifactId:jar:1.0-SNAPSHOT':
> >
> > The following profiles are active:
> >
> >  - alwaysActiveProfile (source: settings.xml)
> >
> >
> > Active Profiles for Project
> > 'module2-groupId:module2-artifactId:war:1.0-SNAPSHOT':
> >
> > The following profiles are active:
> >
> >  - alwaysActiveProfile (source: settings.xml)
> >
> >
> > Same result with '-P dev' in the CLI, and same problem running the CLI
> > in a module's base dir.
> >
> > How can I have 'local' or 'dev' profile active in the modules?
> >
> > Thanks for your help,
> >
> > Philippe
>
>
> ---------------------------------------------------------------------
> 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


Mime
View raw message