You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Jochen Wiedmann (JIRA)" <ji...@codehaus.org> on 2007/02/21 13:27:27 UTC

[jira] Commented: (MWAR-89) filtering ${something.url} ignores my property value and writes http://maven.apache.org/something

    [ http://jira.codehaus.org/browse/MWAR-89?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_88128 ] 

Jochen Wiedmann commented on MWAR-89:
-------------------------------------

The reason for this bug is in the use of the "CompositeMap" for filtering. The "CompositeMap" is basically a special Map, which works like this:

- Query the Project in a "magic" way for the property. If something non-null is returned, that's the result value.
- Otherwise, query the projects properties and return the result.

The "magic" way is implemented by a utility class called ReflectionValueExtractor. The first thing this class does is removing any part of the property name until and including a dot. In other words, the lookup for "something.url" becomes a lookup for "url". That's of course a valid value. In other words, a possible workaround is to change your property name to "something_url" and everything should work fine.

I find the behaviour of ReflectionValueExtractor (or the use of it) quite questionable. Basically this means that ${whatever.foo} becomes ${project.foo}. In other words, the use of the dot (which is quite common if not recommended in property names) becomes almost imopssible.

I'd recommend to

- change the implementation of CompositeMap so that it accepts an array of Maps, rather than two Maps.
- Instantiate the CompositeMap with the following values, in that order:

     project.getProperties()
     ReflectionMap(project)
     System.getProperties()

I am ready to provide a patch, should I know that my suggestion will be accepted.


my re


> filtering ${something.url} ignores my property value and writes http://maven.apache.org/something
> -------------------------------------------------------------------------------------------------
>
>                 Key: MWAR-89
>                 URL: http://jira.codehaus.org/browse/MWAR-89
>             Project: Maven 2.x War Plugin
>          Issue Type: Bug
>    Affects Versions: 2.0.2
>            Reporter: Paul Jungwirth
>            Priority: Minor
>
> I have a multimodule build, and one of the modules is a war. That module has an artifactId of "aardvark." This is aardvark's pom:
> <project>
>   ...
>   <properties>
>     <something.url>http://anywhere.com/</something.url>
>     <another.property>whatever</another.property>
>   </properties>
>   ...
>   <build>
>     <plugins>
>       <plugin>
>         <artifactId>maven-war-plugin</artifactId>
>         <configuration>
>           <webResources>
>             <resource>
>                <directory>${basedir}/src/main/resources</directory>
>                <filtering>true</filtering>
>             </resource>
>           </webResources>
>        </configuration>
>       </plugin>
>     </plugins>
>   </builg>
> </project>
> Inside src/main/resources, I have a file that includes both ${something.url} and ${another.property}. But when I run maven, ${another.property} is filtered correctly, while ${something.url} becomes "http://maven.apache.org/aardvark." It ignores my value and writes a URL to apache.org instead, appending the artifactId. Weird, huh? This seems to happen with any property that ends in ".url." Is this supposed to be a feature? I've never seen it documented anywhere.
> Thanks,
> Paul

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira