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

MavenXpp3Writer.write( writer, model ) does not write the <groupId> for <plugin> sections under <pluginManagement> when the "groupId" is "org.apache.maven.plugins"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Incomplete
    • 2.0.9, 3.0-alpha-1
    • None
    • Embedding
    • None

    Description

      I need to update the some sections of a super pom file for every release.
      Instead of writing a script, I am using maven-model library to read the Model of the pom.xml and update my stuff.
      then I am simply writing the file back into disk

      Following is the code.

      BufferedReader in = new BufferedReader( new FileReader(pomFilePath) );

      MavenXpp3Reader reader = new MavenXpp3Reader();

      Model model = reader.read(in);

      in.close();

      DistributionManagement dMgmt = model.getDistributionManagement();
      DeploymentRepository repository = dMgmt.getRepository();

      repository.setUrl(repositoryUrl);

      // write the pom file
      BufferedWriter out = new BufferedWriter(new FileWriter( pomFilePath ));
      MavenXpp3Writer writer = new MavenXpp3Writer();

      writer.write(out, model);

      MavenXpp3Writer.write( writer, model ) does not write the <groupId> for <plugin> sections under <pluginManagement> when the "groupId" is "org.apache.maven.plugins"

      Following is the code that does the work

      private void writePlugin(Plugin plugin, String tagName, XmlSerializer serializer)
      throws java.io.IOException
      {
      if ( plugin != null )
      {
      serializer.startTag( NAMESPACE, tagName );
      if ( plugin.getGroupId() != null && !plugin.getGroupId().equals( "org.apache.maven.plugins" ) )

      { serializer.startTag( NAMESPACE, "groupId" ).text( plugin.getGroupId() ).endTag( NAMESPACE, "groupId" ); }

      As you see, the writePlugin method does not write the "groupId" , when the groupId is null or "org.apache.maven.plugins"

      Is this intended or a bug?

      Attachments

        Activity

          People

            Unassigned Unassigned
            snambi snambi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: