Uploaded image for project: 'Maven Resources Plugin'
  1. Maven Resources Plugin
  2. MRESOURCES-15

Resources plugin does not filter systemproperties properly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.2
    • None
    • None
    • maven 2.0.2, tested on Mac OS X, Windows XP

    Description

      I tried to use filtering to introduce build-time information into some binaries. I used the filtering mechanism as described in the maven getting started guide, but I did not succeed. If you try to filter e.g. ${os.name} it will be filtered to the same result as using ${pom.name}. Other system properties such as
      java.version=${java.version} are simply not filtered and appear untouched in the resulting file in the target-dir. (Just follow getting started guide section filtering to reproduce)

      I think I located the problem (or a part of it): In the resources-plugin's Mojo Code in ResourcesMojo.java in initializeFiltering()

      private void initializeFiltering()
      throws MojoExecutionException
      {
      // System properties
      filterProperties = new Properties( System.getProperties() );
      .....

      the filter is initialized with default-values from System.getProperties(); These properties are not added to the Hashtable the Properties object is extending but to an internal member of Properties called defaults. In getProperty() a second lookup to the internal member is performed in case of a null return of super.get(key) – but the filtering is done via org.codehaus.plexus.util.InterpolationFilterReader which just calls
      get() on the supplied variables Map (in our case a properties object)

      Simple solution would be to explicitly add all system properties to the filter object:

      private void initializeFiltering()
      throws MojoExecutionException
      {
      // System properties
      filterProperties = new Properties();
      filterProperties.putAll(System.getProperties());
      .....

      Hope that helps

      Janis

      Attachments

        Activity

          People

            pmking Marvin King
            js Jeroen Scheerder
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 20m
                20m
                Remaining:
                Remaining Estimate - 20m
                20m
                Logged:
                Time Spent - Not Specified
                Not Specified