PR: MPARTIFACT-49
resolve the POM before deploying git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@179539 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1fa742b9af
commit
4c46b07881
@ -63,68 +63,61 @@
|
|||||||
<tag>MAVEN_ARTIFACT_1_4_1</tag>
|
<tag>MAVEN_ARTIFACT_1_4_1</tag>
|
||||||
</version>
|
</version>
|
||||||
</versions>
|
</versions>
|
||||||
<developers/>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>maven</artifactId>
|
<artifactId>maven</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>plexus</groupId>
|
<groupId>plexus</groupId>
|
||||||
<artifactId>plexus-utils</artifactId>
|
<artifactId>plexus-utils</artifactId>
|
||||||
<version>1.0-alpha-1</version>
|
<version>1.0-alpha-3</version>
|
||||||
<type>jar</type>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-betwixt</groupId>
|
||||||
|
<artifactId>commons-betwixt</artifactId>
|
||||||
|
<version>0.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-net</groupId>
|
<groupId>commons-net</groupId>
|
||||||
<artifactId>commons-net</artifactId>
|
<artifactId>commons-net</artifactId>
|
||||||
<version>1.1.0</version>
|
<version>1.1.0</version>
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-httpclient</groupId>
|
<groupId>commons-httpclient</groupId>
|
||||||
<artifactId>commons-httpclient</artifactId>
|
<artifactId>commons-httpclient</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-lang</groupId>
|
<groupId>commons-lang</groupId>
|
||||||
<artifactId>commons-lang</artifactId>
|
<artifactId>commons-lang</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-logging</groupId>
|
<groupId>commons-logging</groupId>
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
<version>1.0.3</version>
|
<version>1.0.3</version>
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jsch</groupId>
|
<groupId>jsch</groupId>
|
||||||
<artifactId>jsch</artifactId>
|
<artifactId>jsch</artifactId>
|
||||||
<version>0.1.14</version>
|
<version>0.1.14</version>
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-jelly</groupId>
|
<groupId>commons-jelly</groupId>
|
||||||
<artifactId>commons-jelly</artifactId>
|
<artifactId>commons-jelly</artifactId>
|
||||||
<version>1.0-beta-4</version>
|
<version>1.0-beta-4</version>
|
||||||
<url>http://jakarta.apache.org/commons/jelly/</url>
|
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-jelly</groupId>
|
<groupId>commons-jelly</groupId>
|
||||||
<artifactId>commons-jelly-tags-velocity</artifactId>
|
<artifactId>commons-jelly-tags-velocity</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>velocity</groupId>
|
<groupId>velocity</groupId>
|
||||||
<artifactId>velocity</artifactId>
|
<artifactId>velocity</artifactId>
|
||||||
<version>1.4</version>
|
<version>1.4</version>
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.wagon</groupId>
|
<groupId>org.apache.maven.wagon</groupId>
|
||||||
@ -156,5 +149,10 @@
|
|||||||
<artifactId>wagon-file</artifactId>
|
<artifactId>wagon-file</artifactId>
|
||||||
<version>1.0-alpha-3</version>
|
<version>1.0-alpha-3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>maven-model</artifactId>
|
||||||
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -17,11 +17,20 @@ package org.apache.maven.artifact.deployer;
|
|||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.commons.betwixt.XMLIntrospector;
|
||||||
|
import org.apache.commons.betwixt.io.BeanWriter;
|
||||||
|
import org.apache.commons.betwixt.strategy.DecapitalizeNameMapper;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.maven.MavenConstants;
|
import org.apache.maven.MavenConstants;
|
||||||
import org.apache.maven.MavenException;
|
import org.apache.maven.MavenException;
|
||||||
|
import org.apache.maven.MavenUtils;
|
||||||
|
import org.apache.maven.jelly.MavenJellyContext;
|
||||||
|
import org.apache.maven.model.Dependency;
|
||||||
|
import org.apache.maven.model.Model;
|
||||||
|
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||||
|
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||||
import org.apache.maven.project.Project;
|
import org.apache.maven.project.Project;
|
||||||
import org.apache.maven.repository.ArtifactTypeHandler;
|
import org.apache.maven.repository.ArtifactTypeHandler;
|
||||||
import org.apache.maven.repository.DefaultArtifactTypeHandler;
|
import org.apache.maven.repository.DefaultArtifactTypeHandler;
|
||||||
@ -41,8 +50,14 @@ import org.apache.maven.wagon.providers.ssh.SftpWagon;
|
|||||||
import org.apache.maven.wagon.providers.sshext.ScpExternalWagon;
|
import org.apache.maven.wagon.providers.sshext.ScpExternalWagon;
|
||||||
import org.apache.maven.wagon.repository.Repository;
|
import org.apache.maven.wagon.repository.Repository;
|
||||||
import org.codehaus.plexus.util.FileUtils;
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
@ -100,7 +115,7 @@ public class DefaultArtifactDeployer
|
|||||||
File file;
|
File file;
|
||||||
if ( POM_TYPE.equals( type ) )
|
if ( POM_TYPE.equals( type ) )
|
||||||
{
|
{
|
||||||
file = project.getFile();
|
file = getRewrittenPom( project );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -110,12 +125,111 @@ public class DefaultArtifactDeployer
|
|||||||
// do not deploy POM twice
|
// do not deploy POM twice
|
||||||
if ( !POM_TYPE.equals( type ) )
|
if ( !POM_TYPE.equals( type ) )
|
||||||
{
|
{
|
||||||
doDeploy( project.getFile(), project, POM_ARTIFACT_TYPE_HANDLER, version, POM_TYPE );
|
doDeploy( getRewrittenPom( project ), project, POM_ARTIFACT_TYPE_HANDLER, version, POM_TYPE );
|
||||||
}
|
}
|
||||||
|
|
||||||
doDeploy( file, project, handler, version, type );
|
doDeploy( file, project, handler, version, type );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static File getRewrittenPom( Project project )
|
||||||
|
throws MavenException
|
||||||
|
{
|
||||||
|
Model model;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Very gross, but in Maven 1.0 we can't get access, and we don't want initialize() called
|
||||||
|
// A future version should use use project.getModel() and serialize that
|
||||||
|
Method m = MavenUtils.class.getDeclaredMethod( "getNonJellyProject",
|
||||||
|
new Class[]{File.class, MavenJellyContext.class,
|
||||||
|
boolean.class} );
|
||||||
|
m.setAccessible( true );
|
||||||
|
Project p = (Project) m.invoke( null,
|
||||||
|
new Object[]{project.getFile(), project.getContext(), Boolean.TRUE} );
|
||||||
|
m.setAccessible( false );
|
||||||
|
m = MavenUtils.class.getDeclaredMethod( "getJellyProject", new Class[]{Project.class} );
|
||||||
|
m.setAccessible( true );
|
||||||
|
p = (Project) m.invoke( null, new Object[]{p} );
|
||||||
|
m.setAccessible( false );
|
||||||
|
|
||||||
|
// now sanitize
|
||||||
|
p.setContext( null );
|
||||||
|
p.setParent( null );
|
||||||
|
p.setArtifacts( null );
|
||||||
|
p.setDependencyVerifier( null );
|
||||||
|
p.setExtend( null );
|
||||||
|
|
||||||
|
ByteArrayOutputStream projectStream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
BeanWriter beanWriter = new BeanWriter( projectStream );
|
||||||
|
beanWriter.setXMLIntrospector( createXMLIntrospector() );
|
||||||
|
|
||||||
|
beanWriter.enablePrettyPrint();
|
||||||
|
beanWriter.setWriteIDs( false );
|
||||||
|
beanWriter.write( p );
|
||||||
|
|
||||||
|
String asString = projectStream.toString( System.getProperty( "file.encoding" ) );
|
||||||
|
|
||||||
|
MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||||
|
model = reader.read( new StringReader( asString ) );
|
||||||
|
model.setId( null );
|
||||||
|
|
||||||
|
for ( Iterator i = model.getDependencies().iterator(); i.hasNext(); )
|
||||||
|
{
|
||||||
|
Dependency d = (Dependency) i.next();
|
||||||
|
d.setId( null );
|
||||||
|
|
||||||
|
if ( d.getUrl() != null && d.getUrl().length() == 0 )
|
||||||
|
{
|
||||||
|
d.setUrl( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( d.getType() != null && d.getType().length() == 0 )
|
||||||
|
{
|
||||||
|
d.setType( null );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( d.getJar() != null && d.getJar().length() == 0 )
|
||||||
|
{
|
||||||
|
d.setJar( null );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( Exception e )
|
||||||
|
{
|
||||||
|
throw new MavenException( "Error getting the project as a string", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
FileWriter w = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MavenXpp3Writer writer = new MavenXpp3Writer();
|
||||||
|
File f = File.createTempFile( "maven-artifact-plugin.", null );
|
||||||
|
f.deleteOnExit();
|
||||||
|
w = new FileWriter( f );
|
||||||
|
writer.write( w, model );
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new MavenException( "Error getting the project as a string", e );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( w );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static XMLIntrospector createXMLIntrospector()
|
||||||
|
{
|
||||||
|
XMLIntrospector introspector = new XMLIntrospector();
|
||||||
|
|
||||||
|
introspector.setAttributesForPrimitives( false );
|
||||||
|
introspector.setElementNameMapper( new DecapitalizeNameMapper() );
|
||||||
|
|
||||||
|
return introspector;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ArtifactDeployer#install(String, String, Project, ArtifactTypeHandler)
|
* @see ArtifactDeployer#install(String, String, Project, ArtifactTypeHandler)
|
||||||
*/
|
*/
|
||||||
@ -141,7 +255,7 @@ public class DefaultArtifactDeployer
|
|||||||
File file;
|
File file;
|
||||||
if ( POM_TYPE.equals( type ) )
|
if ( POM_TYPE.equals( type ) )
|
||||||
{
|
{
|
||||||
file = project.getFile();
|
file = getRewrittenPom( project );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -153,7 +267,7 @@ public class DefaultArtifactDeployer
|
|||||||
// do not install twice
|
// do not install twice
|
||||||
if ( !POM_TYPE.equals( type ) )
|
if ( !POM_TYPE.equals( type ) )
|
||||||
{
|
{
|
||||||
doInstall( project.getFile(), POM_TYPE, project, version, POM_ARTIFACT_TYPE_HANDLER );
|
doInstall( getRewrittenPom( project ), POM_TYPE, project, version, POM_ARTIFACT_TYPE_HANDLER );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
<release version="1.5-SNAPSHOT" date="in SVN">
|
<release version="1.5-SNAPSHOT" date="in SVN">
|
||||||
|
<action dev="brett" type="update" issue="MPARTIFACT-49">Wholly resolve the POM before deploying</action>
|
||||||
<action dev="brett" type="update" issue="MPARTIFACT-19">Deploy anything with SNAPSHOT in the version as a snapshot</action>
|
<action dev="brett" type="update" issue="MPARTIFACT-19">Deploy anything with SNAPSHOT in the version as a snapshot</action>
|
||||||
<action dev="brett" type="update">Deprecated install-snapshot and deploy-snapshot goals</action>
|
<action dev="brett" type="update">Deprecated install-snapshot and deploy-snapshot goals</action>
|
||||||
<action dev="brett" type="remove">Remove deprecated old deployment method</action>
|
<action dev="brett" type="remove">Remove deprecated old deployment method</action>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user