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

Generated properties appear to be ignored by the resources plugin

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Incomplete
    • 2.3, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.5, 2.6, 2.7
    • None
    • copy
    • None
    • Running on Mac OS X
      Apache Maven 3.2.3
      Java version: 1.6.0_65, vendor: Apple Inc.

    Description

      There are currently two plugins that I'm aware of that can generate a property; one is the build-helper-maven-plugin from org.codehaus.mojo, and the other is
      gmaven-plugin from org.codehaus.groovy.maven. What these plugins do is allow you to run a regex on a pre-defined property and therefore generate a new property.

      For my project, I'm trying to transform the 1.6.0-SNAPSHOT project.version into a simpler new string, essentially v1p6p0. I'm doing this with a regex, and the variable this will be stored in is called target.version.encoded. I'd like to use that property name to create a directory with that name during resources:resources execution. Note that I can easily do this with a hardcoded property.

      The regex happens at the validate phase of the build.
      The resources copy happens at the process-resources phase of the build.
      I have an ANT task that runs in-between these two processes during the initialize phase of the build, in order to print out the variable, which verifies that it was created properly. Unfortunately, when the resources:resources phase runs, the newly-generated property is ignored, and a directory called ${target.version.encoded} is created. My pom is below, followed by the important part of the log that I see.

      In the pom-file (attached), you can comment out the "TEST 1" plugin section and replace it with the "TEST2" and you'll see similar results. If you don't run the pom with the "prod" profile, you can also see everything work with the hard-coded property for target.version.encoded.

      The pom is attached to preserve formatting.

      Command: mvn -Pprod clean install

      Log:
      [INFO] — build-helper-maven-plugin:1.9.1:regex-property (regex-target.version.encoded) @ fake-parent —
      [INFO]
      [INFO] — maven-antrun-plugin:1.1:run (default) @ fake-parent —
      [INFO] Executing tasks
      [echo] =======================================
      [echo] DYNAMIC VARIABLES
      [echo] =======================================
      [echo] [target.version.encoded] v1p6p0
      [echo] =======================================
      [INFO] Executed tasks
      [INFO]
      [INFO] — maven-resources-plugin:2.3:resources (default-resources) @ fake-parent —
      [WARNING] Using platform encoding (MacRoman actually) to copy filtered resources, i.e. build is platform dependent!
      [INFO] Copying 1 resource to /Users/user/git/example2/target/${target.version.encoded}

      Result:

      • You can see that the ant task clearly knows target.version.encoded, whereas the replacer version does not. When I look in target/, I see a directory called "${target.version.encoded}".

      Note that if you run the command without the -Pprod profile, target.version.encoded becomes "dev", and the target/dev directory is created appropriately.

      I tried with versions 2.3 through 2.7 of the resources plugin, and with both property-creator plugins. Since both produce the same result, I am suspicious of the resources plugin. However, the issue could be that those plugins produce non-standard output, although that does not seem to be the case based on the fact that the ant script works fine with the newly-created property.

      Any help would be appreciated.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            Propane13 John Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment