code: public String toXml() throws ProjectException {
          log.debug("Writing xml");
  
          Project copy = this;
          copy.removeProperty( "project.basedir" );
  
          StringWriter writer = new StringWriter();
  
          MavenXpp3Writer pomWriter = new MavenXpp3Writer();
          try {
              pomWriter.write(writer, copy.mavenModel);
          } catch (IOException e) {
              throw new ProjectException("Failed to create pom xml", e);
          }
  
          writer.flush();
          return writer.toString();
      }
docs: Convert Project to POM XML
  
  @return String
  @throws ProjectException exception