mirror of https://github.com/apache/maven.git
[MNG-4469] [regression] deploy:deploy-file fails with secured repository
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@888488 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ed4f6d1094
commit
7dec7325a9
|
@ -19,11 +19,15 @@ package org.apache.maven.artifact.repository;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.UnknownRepositoryLayoutException;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
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.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
||||
|
@ -34,21 +38,20 @@ import org.codehaus.plexus.component.annotations.Requirement;
|
|||
public class DefaultArtifactRepositoryFactory
|
||||
implements ArtifactRepositoryFactory
|
||||
{
|
||||
// TODO: use settings?
|
||||
private String globalUpdatePolicy;
|
||||
|
||||
@Requirement
|
||||
private org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory factory;
|
||||
|
||||
private String globalChecksumPolicy;
|
||||
@Requirement
|
||||
private LegacySupport legacySupport;
|
||||
|
||||
// FIXME: This is a non-ThreadLocal cache!!
|
||||
private final Map<String,ArtifactRepository> artifactRepositories = new HashMap<String,ArtifactRepository>();
|
||||
|
||||
@Requirement(role=ArtifactRepositoryLayout.class)
|
||||
private Map<String,ArtifactRepositoryLayout> repositoryLayouts;
|
||||
@Requirement
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
public ArtifactRepositoryLayout getLayout( String layoutId )
|
||||
throws UnknownRepositoryLayoutException
|
||||
{
|
||||
return repositoryLayouts.get( layoutId );
|
||||
return factory.getLayout( layoutId );
|
||||
}
|
||||
|
||||
public ArtifactRepository createDeploymentArtifactRepository( String id,
|
||||
|
@ -57,22 +60,7 @@ public class DefaultArtifactRepositoryFactory
|
|||
boolean uniqueVersion )
|
||||
throws UnknownRepositoryLayoutException
|
||||
{
|
||||
ArtifactRepositoryLayout layout = repositoryLayouts.get( layoutId );
|
||||
|
||||
checkLayout( id, layoutId, layout );
|
||||
|
||||
return createDeploymentArtifactRepository( id, url, layout, uniqueVersion );
|
||||
}
|
||||
|
||||
private void checkLayout( String repositoryId,
|
||||
String layoutId,
|
||||
ArtifactRepositoryLayout layout )
|
||||
throws UnknownRepositoryLayoutException
|
||||
{
|
||||
if ( layout == null )
|
||||
{
|
||||
throw new UnknownRepositoryLayoutException( repositoryId, layoutId );
|
||||
}
|
||||
return injectSession( factory.createDeploymentArtifactRepository( id, url, layoutId, uniqueVersion ), false );
|
||||
}
|
||||
|
||||
public ArtifactRepository createDeploymentArtifactRepository( String id,
|
||||
|
@ -80,7 +68,7 @@ public class DefaultArtifactRepositoryFactory
|
|||
ArtifactRepositoryLayout repositoryLayout,
|
||||
boolean uniqueVersion )
|
||||
{
|
||||
return createArtifactRepository( id, url, repositoryLayout, null, null );
|
||||
return injectSession( factory.createDeploymentArtifactRepository( id, url, repositoryLayout, uniqueVersion ), false);
|
||||
}
|
||||
|
||||
public ArtifactRepository createArtifactRepository( String id,
|
||||
|
@ -90,11 +78,7 @@ public class DefaultArtifactRepositoryFactory
|
|||
ArtifactRepositoryPolicy releases )
|
||||
throws UnknownRepositoryLayoutException
|
||||
{
|
||||
ArtifactRepositoryLayout layout = repositoryLayouts.get( layoutId );
|
||||
|
||||
checkLayout( id, layoutId, layout );
|
||||
|
||||
return createArtifactRepository( id, url, layout, snapshots, releases );
|
||||
return injectSession( factory.createArtifactRepository( layoutId, url, layoutId, snapshots, releases ), true );
|
||||
}
|
||||
|
||||
public ArtifactRepository createArtifactRepository( String id,
|
||||
|
@ -103,42 +87,42 @@ public class DefaultArtifactRepositoryFactory
|
|||
ArtifactRepositoryPolicy snapshots,
|
||||
ArtifactRepositoryPolicy releases )
|
||||
{
|
||||
if ( snapshots == null )
|
||||
{
|
||||
snapshots = new ArtifactRepositoryPolicy();
|
||||
}
|
||||
|
||||
if ( releases == null )
|
||||
{
|
||||
releases = new ArtifactRepositoryPolicy();
|
||||
}
|
||||
|
||||
if ( globalUpdatePolicy != null )
|
||||
{
|
||||
snapshots.setUpdatePolicy( globalUpdatePolicy );
|
||||
releases.setUpdatePolicy( globalUpdatePolicy );
|
||||
}
|
||||
|
||||
if ( globalChecksumPolicy != null )
|
||||
{
|
||||
snapshots.setChecksumPolicy( globalChecksumPolicy );
|
||||
releases.setChecksumPolicy( globalChecksumPolicy );
|
||||
}
|
||||
|
||||
ArtifactRepository repository = new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases );
|
||||
|
||||
artifactRepositories.put( id, repository );
|
||||
|
||||
return repository;
|
||||
return injectSession( factory.createArtifactRepository( id, url, repositoryLayout, snapshots, releases ), true );
|
||||
}
|
||||
|
||||
public void setGlobalUpdatePolicy( String updatePolicy )
|
||||
{
|
||||
globalUpdatePolicy = updatePolicy;
|
||||
factory.setGlobalUpdatePolicy( updatePolicy );
|
||||
}
|
||||
|
||||
public void setGlobalChecksumPolicy( String checksumPolicy )
|
||||
{
|
||||
globalChecksumPolicy = checksumPolicy;
|
||||
factory.setGlobalChecksumPolicy( checksumPolicy );
|
||||
}
|
||||
}
|
||||
|
||||
private ArtifactRepository injectSession( ArtifactRepository repository, boolean mirrors )
|
||||
{
|
||||
MavenSession session = legacySupport.getSession();
|
||||
|
||||
if ( session != null && repository != null )
|
||||
{
|
||||
MavenExecutionRequest request = session.getRequest();
|
||||
if ( request != null )
|
||||
{
|
||||
List<ArtifactRepository> repositories = Arrays.asList( repository );
|
||||
|
||||
if ( mirrors )
|
||||
{
|
||||
repositorySystem.injectMirror( repositories, request.getMirrors() );
|
||||
}
|
||||
|
||||
repositorySystem.injectProxy( repositories, request.getProxies() );
|
||||
|
||||
repositorySystem.injectAuthentication( repositories, request.getServers() );
|
||||
}
|
||||
}
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.maven.artifact.Artifact;
|
|||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.Authentication;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.apache.maven.repository.legacy.repository;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License. You may obtain a
|
||||
* copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License
|
||||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||
* or implied. See the License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.UnknownRepositoryLayoutException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
||||
/** @author jdcasey */
|
||||
public interface ArtifactRepositoryFactory
|
||||
{
|
||||
|
||||
String DEFAULT_LAYOUT_ID = "default";
|
||||
|
||||
String LOCAL_REPOSITORY_ID = "local";
|
||||
|
||||
@Deprecated
|
||||
ArtifactRepositoryLayout getLayout( String layoutId )
|
||||
throws UnknownRepositoryLayoutException;
|
||||
|
||||
@Deprecated
|
||||
ArtifactRepository createDeploymentArtifactRepository( String id, String url, String layoutId, boolean uniqueVersion )
|
||||
throws UnknownRepositoryLayoutException;
|
||||
|
||||
ArtifactRepository createDeploymentArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion );
|
||||
|
||||
ArtifactRepository createArtifactRepository( String id, String url, String layoutId, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases )
|
||||
throws UnknownRepositoryLayoutException;
|
||||
|
||||
ArtifactRepository createArtifactRepository( String id, String url, ArtifactRepositoryLayout repositoryLayout, ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases );
|
||||
|
||||
void setGlobalUpdatePolicy( String snapshotPolicy );
|
||||
|
||||
void setGlobalChecksumPolicy( String checksumPolicy );
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
package org.apache.maven.repository.legacy.repository;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.maven.artifact.UnknownRepositoryLayoutException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.MavenArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
||||
/**
|
||||
* @author jdcasey
|
||||
*/
|
||||
@Component(role=ArtifactRepositoryFactory.class)
|
||||
public class DefaultArtifactRepositoryFactory
|
||||
implements ArtifactRepositoryFactory
|
||||
{
|
||||
// TODO: use settings?
|
||||
private String globalUpdatePolicy;
|
||||
|
||||
private String globalChecksumPolicy;
|
||||
|
||||
@Requirement(role=ArtifactRepositoryLayout.class)
|
||||
private Map<String,ArtifactRepositoryLayout> repositoryLayouts;
|
||||
|
||||
public ArtifactRepositoryLayout getLayout( String layoutId )
|
||||
throws UnknownRepositoryLayoutException
|
||||
{
|
||||
return repositoryLayouts.get( layoutId );
|
||||
}
|
||||
|
||||
public ArtifactRepository createDeploymentArtifactRepository( String id,
|
||||
String url,
|
||||
String layoutId,
|
||||
boolean uniqueVersion )
|
||||
throws UnknownRepositoryLayoutException
|
||||
{
|
||||
ArtifactRepositoryLayout layout = repositoryLayouts.get( layoutId );
|
||||
|
||||
checkLayout( id, layoutId, layout );
|
||||
|
||||
return createDeploymentArtifactRepository( id, url, layout, uniqueVersion );
|
||||
}
|
||||
|
||||
private void checkLayout( String repositoryId,
|
||||
String layoutId,
|
||||
ArtifactRepositoryLayout layout )
|
||||
throws UnknownRepositoryLayoutException
|
||||
{
|
||||
if ( layout == null )
|
||||
{
|
||||
throw new UnknownRepositoryLayoutException( repositoryId, layoutId );
|
||||
}
|
||||
}
|
||||
|
||||
public ArtifactRepository createDeploymentArtifactRepository( String id,
|
||||
String url,
|
||||
ArtifactRepositoryLayout repositoryLayout,
|
||||
boolean uniqueVersion )
|
||||
{
|
||||
return createArtifactRepository( id, url, repositoryLayout, null, null );
|
||||
}
|
||||
|
||||
public ArtifactRepository createArtifactRepository( String id,
|
||||
String url,
|
||||
String layoutId,
|
||||
ArtifactRepositoryPolicy snapshots,
|
||||
ArtifactRepositoryPolicy releases )
|
||||
throws UnknownRepositoryLayoutException
|
||||
{
|
||||
ArtifactRepositoryLayout layout = repositoryLayouts.get( layoutId );
|
||||
|
||||
checkLayout( id, layoutId, layout );
|
||||
|
||||
return createArtifactRepository( id, url, layout, snapshots, releases );
|
||||
}
|
||||
|
||||
public ArtifactRepository createArtifactRepository( String id,
|
||||
String url,
|
||||
ArtifactRepositoryLayout repositoryLayout,
|
||||
ArtifactRepositoryPolicy snapshots,
|
||||
ArtifactRepositoryPolicy releases )
|
||||
{
|
||||
if ( snapshots == null )
|
||||
{
|
||||
snapshots = new ArtifactRepositoryPolicy();
|
||||
}
|
||||
|
||||
if ( releases == null )
|
||||
{
|
||||
releases = new ArtifactRepositoryPolicy();
|
||||
}
|
||||
|
||||
if ( globalUpdatePolicy != null )
|
||||
{
|
||||
snapshots.setUpdatePolicy( globalUpdatePolicy );
|
||||
releases.setUpdatePolicy( globalUpdatePolicy );
|
||||
}
|
||||
|
||||
if ( globalChecksumPolicy != null )
|
||||
{
|
||||
snapshots.setChecksumPolicy( globalChecksumPolicy );
|
||||
releases.setChecksumPolicy( globalChecksumPolicy );
|
||||
}
|
||||
|
||||
ArtifactRepository repository = new MavenArtifactRepository( id, url, repositoryLayout, snapshots, releases );
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setGlobalUpdatePolicy( String updatePolicy )
|
||||
{
|
||||
globalUpdatePolicy = updatePolicy;
|
||||
}
|
||||
|
||||
public void setGlobalChecksumPolicy( String checksumPolicy )
|
||||
{
|
||||
globalChecksumPolicy = checksumPolicy;
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
||||
import org.apache.maven.settings.Mirror;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.apache.maven.artifact.DefaultArtifact;
|
|||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.repository.legacy.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
||||
|
|
Loading…
Reference in New Issue