Uploaded image for project: 'Maven Release Plugin'
  1. Maven Release Plugin
  2. MRELEASE-266

Content outside root elements in pom are not transfered to the release poms

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Auto Closed
    • 2.0-beta-6
    • None
    • prepare
    • None

    Description

      The usual convention for copyright/license headers in xml files is b4 the root element tag, so that it occurs outside the main body (i.e. outside Document.getRootElement()). My experience is that the release plugin does not copy such comments over to the release poms (such that the release poms are missing those headers).

      I believe the plugin tries to handle these comments in org.apache.maven.shared.release.phase.AbstractRewritePomsPhase#transformProject where it sets up the 'intro' and 'outtro' vars. In my experience, this was not working. And JDOM provides an easier approach anyway, by filtering the Document contents for non-Elements (making assumption that <project/> is the single root) and copying over the filtered content. This would be a simple change to #writePom:

      1) just write out the Document itself?:
      ...
      writer = new FileWriter( pomFile );

      // if ( intro != null )
      //

      { // writer.write( intro ); // }
      //
      // Format format = Format.getRawFormat();
      // format.setLineSeparator( LS );
      // XMLOutputter out = new XMLOutputter( format );
      // out.output( document.getRootElement(), writer );
      //
      // if ( outtro != null )
      // { // writer.write( outtro ); // }
      Format format = Format.getRawFormat();
      format.setLineSeparator( LS );
      XMLOutputter out = new XMLOutputter( format );
      out.output( document, writer );

      2) separate element/non-element:
      ...
      writer = new FileWriter( pomFile );

      // if ( intro != null )
      // {// writer.write( intro );// }

      //
      // Format format = Format.getRawFormat();
      // format.setLineSeparator( LS );
      // XMLOutputter out = new XMLOutputter( format );
      // out.output( document.getRootElement(), writer );
      //
      // if ( outtro != null )
      //

      { // writer.write( outtro ); // }

      private final List nonElements = document.getContents(
      new Filter() {
      public boolean matches(Object obj)

      { return obj instanceof Comment || obj instanceof ProcessingInstruction; }

      }
      );
      Format format = Format.getRawFormat();
      format.setLineSeparator( LS );
      XMLOutputter out = new XMLOutputter( format );
      out.putput( nonElements, writer );
      out.output( document.getRootElement(), writer );

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              steve.ebersole@jboss.com Steve Ebersole
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: