maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From WhatTheHell <the.johny....@gmail.com>
Subject RE: Checking properties in a multi-pom environment
Date Wed, 13 Aug 2008 09:31:25 GMT

Hi Brian,

Thank you for your reply. Actually, I think you've just answered my
question, but maybe there still is some other solution.

My situation is:

The root-pom with no properties inside but with some modules. Here you have
a part of it:

-- \/ -- root-pom part -- \/ --
  <profiles>
    <profile>
      <id>full</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <modules>
        <module>ear</module>
      </modules>
    </profile>
  </profiles>

  <modules>
    <module>poms/base</module>
    <module>modules/model</module>
    <module>modules/gwt</module>
    <module>war</module>
    <module>modules/commons/widgets</module>
    <module>modules/commons/metadata</module>
  </modules>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>

          <execution>
            <id>enforce-property</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireProperty>
                  <property>the.url</property>
                </requireProperty>
                <!-- ... -->
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>

        </executions>
      </plugin>
    </plugins>
  </build>
-- /\ -- root-pom part -- /\ --

And in a module 'war' we have several profiles. Some of them have the
property 'the.url' and some of them don't. Of course different profiles have
different values of the.url, so it can not be set globally.
I have to check some more properties from different modules and that's why I
wanted to try to check them from one place to have all the rules togather.

As far as I understand, when I add a rule to the root it will be checked in
every module's pom. So the rule will fail in all the poms except 'war' (but
only if a good profile was used). Is that correct?
I was just wondering whether there is a possibility to check if the rule was
OK at least once in a tree - not for every single pom. And if it failed in
every pom then use the value in <fail></fail> to fail the compilation or
not.

Well, if I have to check the properties in the modules where they appear
I'll live with it   :-)
But if you have any idea for my case, please let me know about it.

I hope this time I gave you enough details.

best
Pawel

------------

Brian E Fox wrote:
> 
> The enforcer rule should work, you'll need to be more explicit about
> what's not working. If you put the enforcer in the root, it will execute
> for all children. If some of those children don't have it set, then it
> should fail. I just double checked the rule, and it's using the core
> code to result the property, so it should behave exactly like the core
> and see inherited properties.
> 
> -----Original Message-----
> From: WhatTheHell [mailto:the.johny.doe@gmail.com] 
> Sent: Tuesday, August 12, 2008 10:44 AM
> To: users@maven.apache.org
> Subject: Checking properties in a multi-pom environment
> 
> 
> Hi Maven users  :)
> 
> I faced a problem to check if some properties were set during maven's
> compilation/deployment etc or not. 
> 
> We have one 'root' pom and it runs some other poms as modules. There are
> no
> properties in the root-pom. They are set during maven's work. The
> example
> property can be the project's URL. Sometimes we just make a local
> compilation and then we don't need it to be set. However, when we deploy
> a
> new release we have to be sure that the URL was set. We use some
> different
> profiles when we just compile and when we deploy and some of those
> profiles
> do have a property while some other don't.
> 
> I've tried to use an enforcer plugin. I've created a
> requireProperty-rule in
> a root-pom, but as far as I can see it doesn't work in a pom-tree
> environment (please correct me if I'm wrong), because I've run mvn with
> a
> profiles that do set the URL for sure and my rule failed. I've also
> tried to
> make a java-custom-rule, but it also failed saying, that I haven't set
> the
> property  :-(
> I know I can check my rule in every single pom that sometimes can set
> the
> URL, but I wanted to do it in the root. Is it possible?
> 
> We use:
> Maven version: 2.0.8
> Java version: 1.5.0_15
> 
> I've tried to find a solution for a couple of days, but I couldn't.
> Maybe
> I've missed some reference...
> 
> Thanks for any help
> Best
> Pawel
> -- 
> View this message in context:
> http://www.nabble.com/Checking-properties-in-a-multi-pom-environment-tp1
> 8945713p18945713.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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Checking-properties-in-a-multi-pom-environment-tp18945713p18959796.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


Mime
View raw message