Uploaded image for project: 'Maven EAR Plugin'
  1. Maven EAR Plugin
  2. MEAR-47

since resourcesDir property is deprecated anyway, please make it optional and do not attempt to copy resources from it if is not explicitly set

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2
    • 2.3
    • None
    • Patch

    Description

      The deprecated resourcesDir property recently caused me quite a bit of grief. In our build environment we use a profile called "dev" that allows artifacts to be built directly to their test deploy locations, rather than to target/classes (or target/my.ear in the case of the ear plugin). To make this magic happen, I had to write a simple M2 plugin that allows you to override the value of project.build.directory and/or project.build.outputDirectory. So for our ear, the dev profile sets the ear plugin's workDirectory prop to <testAppServer>/deploy/my.ear. It also sets project.build.outputDirectory to <testAppServer>/deploy/my.ear in the pre-clean phase, so that the clean phase will delete <testAppServer>/deploy/my.ear.

      The problem that I hit was that if I ran "mvn clean install", project.build.outputDirectory would still be set to "<testAppServer>/deploy/my.ear" when mvn got to the default lifecycle, and since the ear plugin's resourcesDir property defaults to "${project.build.outputDirectory}", the ear plugin ends up trying to copy the contents of "<testAppServer>/deploy/my.ear" over top of themselves, which causes all of the files in the ear to get zeroed out.

      Anyway, I know my use case is a bit unusual, but making the property optional and not doing anything if it's not explicitly set would save me from having to do an additional hack to reset project.build.outputDirectory at the beginning of the default lifecycle.

      Another acceptable alternative would be if the resource copying was skipped if resourceDir equals workDirectory.

      I've attached patches for both of the alternatives.

      Attachments

        Issue Links

          Activity

            People

              snicoll Stephane Nicoll
              ips Ian P. Springer
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: