Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6259

Maven Resources Plugin copy error when filtering is true on a Mac

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Incomplete
    • Affects Version/s: 3.2.5
    • Fix Version/s: None
    • Component/s: Errors
    • Labels:
      None

      Description

      This is an error consistently seen on Mac (OS X 10.11.6), but it seems to work fine on linux (our jenkins agent).

      Basically, when `filtering` is set to true in the resources plugin, the resource file contents are copied incorrectly converting \${something} to ${something}. Note the missing back-slash, and also that "something" is not a maven variable. The expected behavior is to keep it unchanged. Here is a unit test that shows the issue:
      1. First, create a resource text file "new.test" with just the string

      \${something }

      2. Make sure that resource plugin has filtering set to "true":

      <testResources>
            <testResource>
              <directory>src/test/resources</directory>
              <filtering>true</filtering>
            </testResource>
      

      3. Create the unit test below:

      @Test
      public void test() throws IOException {
          URL url = Resources.getResource("conf/new.test");
          String text = Resources.toString(url, Charsets.UTF_8);
          String expectedText = "\\${something }" ;
          System.out.println("actual: " + text);
          System.out.println("expected: " + expectedText);
      
          assertEquals(expectedText, text);
      }
      

      3. Note that when you run the above test from the IDE directly, it passes.
      4. Run `mvn clean install` from command line and verify the following error:

      actual: ${something }
      expected: \${something }
      
      org.junit.ComparisonFailure: 
      Expected :\${something }
      Actual   :${something }  ---> Note the back-slash has gone missing.
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fahdsiddiqui Fahd Siddiqui
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: