mirror of
https://github.com/apache/maven.git
synced 2025-03-07 00:59:51 +00:00
[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 @@
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
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.RepositoryMetadataDeploymentException;
|
||||||
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
|
import org.apache.maven.artifact.repository.metadata.RepositoryMetadataManager;
|
||||||
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.plugin.LegacySupport;
|
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.TransferListenerAdapter;
|
||||||
import org.apache.maven.repository.legacy.WagonManager;
|
import org.apache.maven.repository.legacy.WagonManager;
|
||||||
import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformationManager;
|
import org.apache.maven.repository.legacy.resolver.transform.ArtifactTransformationManager;
|
||||||
@ -49,6 +54,9 @@ public class DefaultArtifactDeployer
|
|||||||
@Requirement
|
@Requirement
|
||||||
private RepositoryMetadataManager repositoryMetadataManager;
|
private RepositoryMetadataManager repositoryMetadataManager;
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private RepositorySystem repositorySystem;
|
||||||
|
|
||||||
@Requirement
|
@Requirement
|
||||||
private LegacySupport legacySupport;
|
private LegacySupport legacySupport;
|
||||||
|
|
||||||
@ -68,6 +76,8 @@ public void deploy( String basedir, String finalName, Artifact artifact, Artifac
|
|||||||
public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository )
|
public void deploy( File source, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository )
|
||||||
throws ArtifactDeploymentException
|
throws ArtifactDeploymentException
|
||||||
{
|
{
|
||||||
|
deploymentRepository = injectSession( deploymentRepository );
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
transformationManager.transformForDeployment( artifact, deploymentRepository, localRepository );
|
transformationManager.transformForDeployment( artifact, deploymentRepository, localRepository );
|
||||||
@ -113,4 +123,32 @@ private TransferListener getTransferListener()
|
|||||||
return TransferListenerAdapter.newAdapter( session.getRequest().getTransferListener() );
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,10 @@ public class DefaultArtifactRepository
|
|||||||
private ArtifactRepositoryPolicy releases;
|
private ArtifactRepositoryPolicy releases;
|
||||||
|
|
||||||
private boolean blacklisted;
|
private boolean blacklisted;
|
||||||
|
|
||||||
|
private Authentication authentication;
|
||||||
|
|
||||||
|
private Proxy proxy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a local repository or a test repository.
|
* Create a local repository or a test repository.
|
||||||
@ -212,30 +216,24 @@ public List<String> findVersions( Artifact artifact )
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// This implementation does not support authentication
|
|
||||||
//
|
|
||||||
public Authentication getAuthentication()
|
public Authentication getAuthentication()
|
||||||
{
|
{
|
||||||
return null;
|
return authentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthentication( Authentication authentication )
|
public void setAuthentication( Authentication authentication )
|
||||||
{
|
{
|
||||||
// do nothing
|
this.authentication = authentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// This implementation does not support proxies
|
|
||||||
//
|
|
||||||
public Proxy getProxy()
|
public Proxy getProxy()
|
||||||
{
|
{
|
||||||
return null;
|
return proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProxy( Proxy proxy )
|
public void setProxy( Proxy proxy )
|
||||||
{
|
{
|
||||||
// do nothing
|
this.proxy = proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUniqueVersion()
|
public boolean isUniqueVersion()
|
||||||
|
@ -19,9 +19,5 @@ under the License.
|
|||||||
|
|
||||||
<plexus>
|
<plexus>
|
||||||
<components>
|
<components>
|
||||||
<component>
|
|
||||||
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
|
|
||||||
<implementation>org.apache.maven.artifact.deployer.SimpleArtifactMetadataSource</implementation>
|
|
||||||
</component>
|
|
||||||
</components>
|
</components>
|
||||||
</plexus>
|
</plexus>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user