mirror of https://github.com/apache/maven.git
Resolving issue: MNG-271
o Added method to MavenProject called writeModel( Writer ) o Added code in MavenArchiver to export the full effective POM to ${project.build.directory}/exported-pom.xml and then embed that in the archive, rather than simply embedding ${project.file}. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191588 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1c58065c2a
commit
07dda3c3ae
|
@ -18,13 +18,16 @@ package org.apache.maven.archiver;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||||
|
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.codehaus.plexus.archiver.ArchiverException;
|
import org.codehaus.plexus.archiver.ArchiverException;
|
||||||
import org.codehaus.plexus.archiver.jar.JarArchiver;
|
import org.codehaus.plexus.archiver.jar.JarArchiver;
|
||||||
import org.codehaus.plexus.archiver.jar.Manifest;
|
import org.codehaus.plexus.archiver.jar.Manifest;
|
||||||
import org.codehaus.plexus.archiver.jar.ManifestException;
|
import org.codehaus.plexus.archiver.jar.ManifestException;
|
||||||
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
@ -216,7 +219,10 @@ public class MavenArchiver
|
||||||
|
|
||||||
String artifactId = project.getArtifactId();
|
String artifactId = project.getArtifactId();
|
||||||
|
|
||||||
archiver.addFile( project.getFile(), "META-INF/maven/" + groupId + "/" + artifactId + "/pom.xml" );
|
|
||||||
|
File exportReadyPom = writeExportReadyPom( project );
|
||||||
|
|
||||||
|
archiver.addFile( exportReadyPom, "META-INF/maven/" + groupId + "/" + artifactId + "/pom.xml" );
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Create pom.properties file
|
// Create pom.properties file
|
||||||
|
@ -269,4 +275,26 @@ public class MavenArchiver
|
||||||
|
|
||||||
pomPropertiesFile.delete();
|
pomPropertiesFile.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File writeExportReadyPom( MavenProject project ) throws IOException
|
||||||
|
{
|
||||||
|
String buildDirectory = project.getBuild().getDirectory();
|
||||||
|
|
||||||
|
File fullPom = new File( buildDirectory, "exported-pom.xml" );
|
||||||
|
|
||||||
|
FileWriter fWriter = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fWriter = new FileWriter( fullPom );
|
||||||
|
|
||||||
|
project.writeModel( fWriter );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( fWriter );
|
||||||
|
}
|
||||||
|
|
||||||
|
return fullPom;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,12 @@ import org.apache.maven.model.Scm;
|
||||||
import org.apache.maven.model.PluginExecution;
|
import org.apache.maven.model.PluginExecution;
|
||||||
import org.apache.maven.model.ReportPlugin;
|
import org.apache.maven.model.ReportPlugin;
|
||||||
import org.apache.maven.model.ReportSet;
|
import org.apache.maven.model.ReportSet;
|
||||||
|
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -1033,4 +1036,11 @@ public class MavenProject
|
||||||
{
|
{
|
||||||
this.executionProject = executionProject;
|
this.executionProject = executionProject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void writeModel( Writer writer ) throws IOException
|
||||||
|
{
|
||||||
|
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
|
||||||
|
|
||||||
|
pomWriter.write( writer, getModel() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue