mirror of https://github.com/apache/maven.git
[MNG-4571] mvn deploy -DaltDeploymentRepository errors out
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@917058 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
57ff75ee45
commit
fe9a21ca81
|
@ -17,14 +17,19 @@ package org.apache.maven.artifact.deployer;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataDeploymentException;
|
||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.LegacySupport;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.repository.legacy.TransferListenerAdapter;
|
||||
import org.apache.maven.repository.legacy.WagonManager;
|
||||
import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformationManager;
|
||||
|
@ -49,6 +54,9 @@ public class DefaultArtifactDeployer
|
|||
@Requirement
|
||||
private RepositoryMetadataManager repositoryMetadataManager;
|
||||
|
||||
@Requirement
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
@Requirement
|
||||
private LegacySupport legacySupport;
|
||||
|
||||
|
@ -68,6 +76,8 @@ public class DefaultArtifactDeployer
|
|||
public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository )
|
||||
throws ArtifactDeploymentException
|
||||
{
|
||||
deploymentRepository = injectSession( deploymentRepository );
|
||||
|
||||
try
|
||||
{
|
||||
transformationManager.transformForDeployment( artifact, deploymentRepository, localRepository );
|
||||
|
@ -113,4 +123,32 @@ public class DefaultArtifactDeployer
|
|||
return TransferListenerAdapter.newAdapter( session.getRequest().getTransferListener() );
|
||||
}
|
||||
|
||||
private ArtifactRepository injectSession( ArtifactRepository repository )
|
||||
{
|
||||
/*
|
||||
* NOTE: This provides backward-compat with maven-deploy-plugin:2.4 which bypasses the repository factory when
|
||||
* using an alternative deployment location.
|
||||
*/
|
||||
if ( repository instanceof DefaultArtifactRepository && repository.getAuthentication() == null )
|
||||
{
|
||||
MavenSession session = legacySupport.getSession();
|
||||
|
||||
if ( session != null )
|
||||
{
|
||||
MavenExecutionRequest request = session.getRequest();
|
||||
|
||||
if ( request != null )
|
||||
{
|
||||
List<ArtifactRepository> repositories = Arrays.asList( repository );
|
||||
|
||||
repositorySystem.injectProxy( repositories, request.getProxies() );
|
||||
|
||||
repositorySystem.injectAuthentication( repositories, request.getServers() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,6 +49,10 @@ public class DefaultArtifactRepository
|
|||
|
||||
private boolean blacklisted;
|
||||
|
||||
private Authentication authentication;
|
||||
|
||||
private Proxy proxy;
|
||||
|
||||
/**
|
||||
* Create a local repository or a test repository.
|
||||
*
|
||||
|
@ -212,30 +216,24 @@ public class DefaultArtifactRepository
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
//
|
||||
// This implementation does not support authentication
|
||||
//
|
||||
public Authentication getAuthentication()
|
||||
{
|
||||
return null;
|
||||
return authentication;
|
||||
}
|
||||
|
||||
public void setAuthentication( Authentication authentication )
|
||||
{
|
||||
// do nothing
|
||||
this.authentication = authentication;
|
||||
}
|
||||
|
||||
//
|
||||
// This implementation does not support proxies
|
||||
//
|
||||
public Proxy getProxy()
|
||||
{
|
||||
return null;
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public void setProxy( Proxy proxy )
|
||||
{
|
||||
// do nothing
|
||||
this.proxy = proxy;
|
||||
}
|
||||
|
||||
public boolean isUniqueVersion()
|
||||
|
|
|
@ -19,9 +19,5 @@ under the License.
|
|||
|
||||
<plexus>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
|
||||
<implementation>org.apache.maven.artifact.deployer.SimpleArtifactMetadataSource</implementation>
|
||||
</component>
|
||||
</components>
|
||||
</plexus>
|
||||
|
|
Loading…
Reference in New Issue