The current source for maven-resources-plugin gives project properties a higher precedence than system properties. I think that is backwards (but it is an improvement over the old code, which effectively did not consider system properties for token replacement at all :-)):

    private void initializeFiltering()
        throws MojoExecutionException
    {
        filterProperties = new Properties();

        // System properties
        filterProperties.putAll( System.getProperties() );

        // Project properties
        filterProperties.putAll( project.getProperties() );



Here's an idea for a work-around for your issue: Define a profile (in your pom.xml) that is only active if the "db" property is NOT set:

    <profile>
      <id>db-profile</id>
      <activation>
        <property>
          <!-- this profile is active when db is NOT set -->
          <name>!db</name>
        </property>
      </activation>
      <properties>
        <!-- put the default value here -->
        <db>hsql</db>
      </properties>
    </profile>

If you set db on the command line (or in settings.xml), this profile will not be activated. But if you don't set it, the profile will activate and give the default value of hsql.

-Max

fagfa wrote:
I'm still stuck with this one and can't believe no one knows the answer ...


fagfa wrote:
We have a parent project which contains several J2EE subprojects, such as
web, ejb, ear, etc.. In the parent POM, a property "db" is defined, whose
default is "hsql", for example. Build for various databases can be
switched by specifying commandline, "mvn -Ddb=mysql", or changing "db"
property directly. In our sub projects, there are some resource files that
depend on this "db" property and we hope these resource files are properly
filtered during the building.
If I just change "db" property in parent POM file, everything works
perfectly. But when I specify "-Ddb=mysql", the resource files are
filtered, but still by the properties in the parent POM, not from command
line. Based on my understanding, property specified in command line should
precede elsewhere specified, which is NOT happending here. Any ideas?
Thanks,

fagfa



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to