Maven Shared Components
  1. Maven Shared Components
  2. MSHARED-154

pomPropertiesFile does not actually permit override

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: maven-archiver-2.4
    • Fix Version/s: maven-archiver-3.0.1
    • Component/s: maven-archiver
    • Labels:
      None
    • Environment:

      Description

      The What

      My understanding is that the pomPropertiesFile configuration element will allow you to override the default pom.properties file that is created by the maven-archiver when addMavenDescriptor is true. I wanted to use this feature to include some Hudson build data into the pom.properties file. We already have utility classes that read version information from this file, so it wasn't a leap to add some build-server information to this same file.

      From the Maven Archiver Reference page:

      pomPropertiesFile Use this to override the auto generated pom.properties file (only if addMavenDescriptor is set to true) File 2.3

      My Expectations

      So my assumption is that I can provide a customized pom.properties file that will be written/copied to the {{META-INF/maven/" + $

      {pom.groupId}

      + "/" + $

      {pom.artifactId}

      + "/pom.properties}} file.

      The Actual Result

      The File I pass to the pomPropertiesFile element is actually overwritten with the default pom.properties file format. One could say it is overriding my override. Maybe I am misunderstanding this configuration element altogether, I can't see how it can possibly be helpful the way that it is behaving right now...

      Background Information

      I am witnessing this behaviour with the apache war plugin:

      Snippet of my pom.xml
      <plugin>
      	<groupId>org.apache.maven.plugins</groupId>
      	<artifactId>maven-war-plugin</artifactId>
      	<version>2.1-beta-1</version>
      	<configuration>
      	<archive>
      		<addMavenDescriptor>true</addMavenDescriptor>
      		<pomPropertiesFile>configurations/custom-pom.properties</pomPropertiesFile>
      	</archive>
      	</configuration>
      </plugin>
      

      And here is my customized properties file that I want used to replace the default pom.properties content:

      Snippet of my custom-pom.properties override file
      version=$\{pom.version\}
      groupId=$\{pom.groupId\}
      artifactId=$\{pom.artifactId\}
      buildTag=${BUILD_TAG}
      buildNumber=${BUILD_NUMBER}
      buildId=${BUILD_ID}
      

      I see from my Maven output that maven-war-plugin-2.1-beta-1 uses maven-archiver-2.4:

      Maven output
      ...
      [DEBUG] Plugin dependencies for:
      
      org.apache.maven.plugins:maven-war-plugin:2.1-beta-1
      
      are:
      
      org.apache.maven:maven-plugin-api:jar:2.0.6:runtime
      org.apache.maven:maven-artifact:jar:2.0.6:runtime
      org.apache.maven:maven-archiver:jar:2.4:runtime
      org.codehaus.plexus:plexus-archiver:jar:1.0-alpha-9:runtime
      org.codehaus.plexus:plexus-io:jar:1.0-alpha-1:runtime
      com.thoughtworks.xstream:xstream:jar:1.3.1:runtime
      org.codehaus.plexus:plexus-utils:jar:1.5.5:runtime
      org.apache.maven.shared:maven-filtering:jar:1.0-beta-2:runtime
      ...
      [DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-war-plugin:2.1-beta-1:war' -->
      [DEBUG]   (s) addMavenDescriptor = false
      [DEBUG]   (s) pomPropertiesFile = /SOME_PATH/configurations/custom-pom.properties
      ...
      

      MavenArchiver#createArchive(...)

      I notice that the createArchive(...) method ALWAYS writes the standard/default pom.properties contents to the supplied file. That provides no benefit.

      If I can offer a suggestion:

      1. get the pomPropertiesFile configuration property.
        • if the property is not null and the property maps to an existing file
          1. archiver.addFile( pomPropertiesFile, "META-INF/maven/" + groupId + "/" + artifactId + "/pom.properties" );
        • else the file property was null
          1. Create the temporary maven-archiver folder
          2. Create a ref to the maven-archiver/pom.properties file
          3. Call PomPropertiesUtil#createPomProperties
      1. 2.7-SNAPSHOT_path
        10 kB
        Saponenko Denis
      2. 2.7-SNAPSHOT_path
        10 kB
        Saponenko Denis
      3. 2.7-SNAPSHOT_path
        12 kB
        Saponenko Denis
      4. path.diff
        14 kB

        Activity

        Hide
        Sergei S. Ivanov added a comment -

        I have just run into the very same problem. I was under assumption that I could override the default pom.properties in maven-jar-plugin execution and augment it with additional build information. It appears it's not possible now.

        Show
        Sergei S. Ivanov added a comment - I have just run into the very same problem. I was under assumption that I could override the default pom.properties in maven-jar-plugin execution and augment it with additional build information. It appears it's not possible now.
        Hide
        Sergei S. Ivanov added a comment -

        What I have also found is that the plugin does actually overwrite my custom properties file with the default content!

        Show
        Sergei S. Ivanov added a comment - What I have also found is that the plugin does actually overwrite my custom properties file with the default content!
        Hide
        Michal Letynski added a comment -

        I also have same problem. Any fix date or workaround for this issue ?

        Show
        Michal Letynski added a comment - I also have same problem. Any fix date or workaround for this issue ?
        Hide
        DAG Support added a comment -

        Same for me, bug is quite old.

        Show
        DAG Support added a comment - Same for me, bug is quite old.
        Hide
        Nathan Green added a comment -

        I created a patch using github, viewable here.

        Show
        Nathan Green added a comment - I created a patch using github, viewable here .
        Hide
        Saponenko Denis added a comment -

        This is function very importantly for me. I use pathed plugin in my projects and add my path to attachment. May upload change classes to public repository (github)?

        Show
        Saponenko Denis added a comment - This is function very importantly for me. I use pathed plugin in my projects and add my path to attachment. May upload change classes to public repository (github)?
        Hide
        Saponenko Denis added a comment -

        Actualized path for 2.7-SNAPSHOT version

        Show
        Saponenko Denis added a comment - Actualized path for 2.7-SNAPSHOT version
        Hide
        Michael Osipov added a comment - - edited

        By reading the current source code, it is true the the implementation is horribly broken. It does not even copy a bit what the documentation says. I do confirm this issue.

        Let's clarify some points first before I fix this one:

        1. The Archiver does not filter/interpolate the properties file, so the example shown in custom-pom.properties won't work and has to be supplied filtered already.
        2. Build properties belong to build.properties which can easily created with the Build Number Maven Plugin. Don't abuse pom.properties.
        3. Even if the implementation would add the three default properties, would that cause any harm to you? I do not think so – better yet, your custom file would comply to the default conversion and additionally having your custom information.

        My proposal is to copy the custom file, add groupId, artifactId, version and bundle with the ZIP file.

        Show
        Michael Osipov added a comment - - edited By reading the current source code, it is true the the implementation is horribly broken. It does not even copy a bit what the documentation says. I do confirm this issue. Let's clarify some points first before I fix this one: 1. The Archiver does not filter/interpolate the properties file, so the example shown in custom-pom.properties won't work and has to be supplied filtered already. 2. Build properties belong to build.properties which can easily created with the Build Number Maven Plugin . Don't abuse pom.properties . 3. Even if the implementation would add the three default properties, would that cause any harm to you? I do not think so – better yet, your custom file would comply to the default conversion and additionally having your custom information. My proposal is to copy the custom file, add groupId , artifactId , version and bundle with the ZIP file.
        Hide
        Dan Nelson added a comment -

        Hey Michael Osipov,
        Every point you made appears completely reasonable to me. Thanks for digging into this.

        Show
        Dan Nelson added a comment - Hey Michael Osipov , Every point you made appears completely reasonable to me. Thanks for digging into this.
        Hide
        Michael Osipov added a comment -

        So, you are fine with having a overlay containing default properties and yours?

        Show
        Michael Osipov added a comment - So, you are fine with having a overlay containing default properties and yours?
        Hide
        Dan Nelson added a comment -

        Yeah that will work just fine. Our use case can adjust accordingly as long as the information I want to add can be added under keys of my choice.

        Show
        Dan Nelson added a comment - Yeah that will work just fine. Our use case can adjust accordingly as long as the information I want to add can be added under keys of my choice.
        Hide
        Michael Osipov added a comment -

        Fixed with r1726860.and snapshot deployed. Please test.

        Show
        Michael Osipov added a comment - Fixed with r1726860 .and snapshot deployed. Please test.
        Hide
        Hudson added a comment -

        SUCCESS: Integrated in maven-shared #850 (See https://builds.apache.org/job/maven-shared/850/)
        MSHARED-154 pomPropertiesFile does not actually permit override (michaelo: http://svn.apache.org/viewvc/?view=rev&rev=1726860)

        • maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java
        • maven-archiver/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java
        • maven-archiver/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java
        • maven-archiver/src/test/resources/custom-pom.properties
        Show
        Hudson added a comment - SUCCESS: Integrated in maven-shared #850 (See https://builds.apache.org/job/maven-shared/850/ ) MSHARED-154 pomPropertiesFile does not actually permit override (michaelo: http://svn.apache.org/viewvc/?view=rev&rev=1726860 ) maven-archiver/src/main/java/org/apache/maven/archiver/MavenArchiver.java maven-archiver/src/main/java/org/apache/maven/archiver/PomPropertiesUtil.java maven-archiver/src/test/java/org/apache/maven/archiver/MavenArchiverTest.java maven-archiver/src/test/resources/custom-pom.properties

          People

          • Assignee:
            Michael Osipov
            Reporter:
            Dan Nelson
          • Votes:
            8 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development