Changing aether dependencies from sonatype to eclipse. Compile OK.

This commit is contained in:
Martin Stockhammer 2018-10-26 22:23:45 +02:00
parent ba75d27818
commit 24ee701d1d
11 changed files with 113 additions and 141 deletions

View File

@ -22,7 +22,6 @@ package org.apache.archiva.converter.artifact;
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.checksum.ChecksumValidationException;
import org.apache.archiva.checksum.ChecksummedFile;
import org.apache.archiva.common.plexusbridge.DigesterUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
import org.apache.archiva.transaction.FileTransaction;
@ -46,8 +45,6 @@ import org.apache.maven.model.Relocation;
import org.apache.maven.model.converter.ModelConverter;
import org.apache.maven.model.converter.PomTranslationException;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.codehaus.plexus.digest.Digester;
import org.codehaus.plexus.digest.DigesterException;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.springframework.stereotype.Service;
@ -77,7 +74,7 @@ public class LegacyToDefaultConverter
implements ArtifactConverter
{
/**
* {@link List}<{@link Digester}
*
*/
private List<ChecksumAlgorithm> digesters;

View File

@ -1,79 +0,0 @@
package org.apache.archiva.common.plexusbridge;
/*
* 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.codehaus.plexus.digest.Digester;
import org.codehaus.plexus.digest.Md5Digester;
import org.codehaus.plexus.digest.Sha1Digester;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import java.util.Arrays;
import java.util.List;
/**
* @author Olivier Lamy
* @since 1.4-M1
*/
@Service( "digesterUtils" )
public class DigesterUtils
{
private Logger log = LoggerFactory.getLogger( getClass() );
private List<? extends Digester> allDigesters;
@Inject
public DigesterUtils( PlexusSisuBridge plexusSisuBridge )
throws PlexusSisuBridgeException
{
this.allDigesters = plexusSisuBridge.lookupList( Digester.class );
if ( allDigesters == null || allDigesters.isEmpty() )
{
// olamy when the TCL is not a URLClassLoader lookupList fail !
// when using tomcat maven plugin so adding a simple hack
log.warn( "using lookupList from sisu plexus failed so build plexus Digesters manually" );
allDigesters = Arrays.asList( new Sha1Digester(), new Md5Digester() );
}
if ( allDigesters == null || allDigesters.isEmpty() )
{
throw new PlexusSisuBridgeException( "no way to initiliaze IndexCreator" );
}
log.debug( "allIndexCreators {}", allDigesters );
}
public List<? extends Digester> getAllDigesters()
{
return allDigesters;
}
public void setAllDigesters( List<? extends Digester> allDigesters )
{
this.allDigesters = allDigesters;
}
}

View File

@ -22,7 +22,6 @@ package org.apache.archiva.transaction;
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.apache.archiva.checksum.ChecksummedFile;
import org.apache.commons.io.FileUtils;
import org.codehaus.plexus.digest.Digester;
import java.io.IOException;
import java.nio.charset.Charset;
@ -51,9 +50,6 @@ public abstract class AbstractTransactionEvent
private List<Path> createdFiles = new ArrayList<>();
/**
* {@link List}&lt;{@link Digester}&gt;
*/
private List<ChecksumAlgorithm> checksumAlgorithms;
protected AbstractTransactionEvent()

View File

@ -20,7 +20,6 @@ package org.apache.archiva.transaction;
*/
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.codehaus.plexus.digest.Digester;
import java.io.IOException;
import java.nio.file.Files;
@ -43,7 +42,7 @@ public class CreateFileEvent
*
* @param content
* @param destination
* @param checksumAlgorithms {@link List}&lt;{@link Digester}&gt; digesters to use for checksumming
* @param checksumAlgorithms digesters to use for checksumming
*/
public CreateFileEvent( String content, Path destination, List<ChecksumAlgorithm> checksumAlgorithms )
{

View File

@ -20,7 +20,6 @@ package org.apache.archiva.transaction;
*/
import org.apache.archiva.checksum.ChecksumAlgorithm;
import org.codehaus.plexus.digest.Digester;
import java.io.IOException;
import java.nio.file.Path;

View File

@ -100,9 +100,10 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<version>${maven3x.version}</version>
<version>3.3.9</version>
</dependency>
<!--
<dependency>
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-api</artifactId>
@ -119,6 +120,24 @@
<groupId>org.sonatype.aether</groupId>
<artifactId>aether-connector-file</artifactId>
</dependency>
-->
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>0.9.0.M2</version>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-connector-file</artifactId>
<version>0.9.0.M2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-impl</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
@ -205,6 +224,7 @@
<artifactId>jaxb-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@ -18,17 +18,18 @@ package org.apache.archiva.dependency.tree.maven2;
* under the License.
*/
import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.connector.file.FileRepositoryConnectorFactory;
import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.spi.connector.ArtifactDownload;
import org.sonatype.aether.spi.connector.ArtifactUpload;
import org.sonatype.aether.spi.connector.MetadataDownload;
import org.sonatype.aether.spi.connector.MetadataUpload;
import org.sonatype.aether.spi.connector.RepositoryConnector;
import org.sonatype.aether.transfer.NoRepositoryConnectorException;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.connector.file.FileRepositoryConnectorFactory;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.spi.connector.ArtifactDownload;
import org.eclipse.aether.spi.connector.ArtifactUpload;
import org.eclipse.aether.spi.connector.MetadataDownload;
import org.eclipse.aether.spi.connector.MetadataUpload;
import org.eclipse.aether.spi.connector.RepositoryConnector;
import org.eclipse.aether.transfer.NoRepositoryConnectorException;
import java.util.Collection;
@ -37,8 +38,11 @@ import java.util.Collection;
* @since 1.4-M3
*/
public class ArchivaRepositoryConnectorFactory
extends FileRepositoryConnectorFactory
implements RepositoryConnectorFactory
{
private FileRepositoryConnectorFactory delegate = new FileRepositoryConnectorFactory();
public ArchivaRepositoryConnectorFactory()
{
// no op but empty constructor needed by aether
@ -50,7 +54,7 @@ public class ArchivaRepositoryConnectorFactory
{
try
{
return super.newInstance( session, repository );
return delegate.newInstance( session, repository );
}
catch ( NoRepositoryConnectorException e )
{
@ -83,4 +87,10 @@ public class ArchivaRepositoryConnectorFactory
}
};
}
@Override
public float getPriority( )
{
return 0;
}
}

View File

@ -19,7 +19,7 @@ package org.apache.archiva.dependency.tree.maven2;
*/
import org.apache.archiva.maven2.model.TreeEntry;
import org.sonatype.aether.graph.DependencyVisitor;
import org.eclipse.aether.graph.DependencyVisitor;
import java.util.List;

View File

@ -35,37 +35,39 @@ import org.apache.archiva.maven2.metadata.MavenMetadataReader;
import org.apache.archiva.maven2.model.TreeEntry;
import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
import org.apache.archiva.model.ArchivaRepositoryMetadata;
import org.apache.archiva.proxy.common.WagonFactory;
import org.apache.archiva.repository.metadata.MetadataTools;
import org.apache.archiva.xml.XMLException;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.model.building.DefaultModelBuilderFactory;
import org.apache.maven.model.building.ModelBuilder;
import org.apache.maven.repository.internal.DefaultArtifactDescriptorReader;
import org.apache.maven.repository.internal.DefaultVersionRangeResolver;
import org.apache.maven.repository.internal.DefaultVersionResolver;
import org.apache.maven.repository.internal.MavenRepositorySystemSession;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.artifact.DefaultArtifact;
import org.eclipse.aether.impl.DefaultServiceLocator;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.LocalRepositoryManager;
import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.aether.RepositorySystem;
import org.sonatype.aether.RepositorySystemSession;
import org.sonatype.aether.collection.CollectRequest;
import org.sonatype.aether.collection.CollectResult;
import org.sonatype.aether.collection.DependencyCollectionException;
import org.sonatype.aether.collection.DependencySelector;
import org.sonatype.aether.graph.Dependency;
import org.sonatype.aether.graph.DependencyVisitor;
import org.sonatype.aether.impl.ArtifactDescriptorReader;
import org.sonatype.aether.impl.VersionRangeResolver;
import org.sonatype.aether.impl.VersionResolver;
import org.sonatype.aether.impl.internal.DefaultServiceLocator;
import org.sonatype.aether.impl.internal.SimpleLocalRepositoryManager;
import org.sonatype.aether.spi.connector.RepositoryConnectorFactory;
import org.sonatype.aether.util.artifact.DefaultArtifact;
import org.sonatype.aether.util.graph.selector.AndDependencySelector;
import org.sonatype.aether.util.graph.selector.ExclusionDependencySelector;
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.collection.CollectRequest;
import org.eclipse.aether.collection.CollectResult;
import org.eclipse.aether.collection.DependencyCollectionException;
import org.eclipse.aether.collection.DependencySelector;
import org.eclipse.aether.graph.Dependency;
import org.eclipse.aether.graph.DependencyVisitor;
import org.eclipse.aether.impl.ArtifactDescriptorReader;
import org.eclipse.aether.impl.VersionRangeResolver;
import org.eclipse.aether.impl.VersionResolver;
import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
import org.eclipse.aether.util.graph.selector.AndDependencySelector;
import org.eclipse.aether.util.graph.selector.ExclusionDependencySelector;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@ -96,9 +98,6 @@ public class Maven3DependencyTreeBuilder
@Named( "repositoryPathTranslator#maven2" )
private RepositoryPathTranslator pathTranslator;
@Inject
private WagonFactory wagonFactory;
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
@ -113,7 +112,6 @@ public class Maven3DependencyTreeBuilder
private ArtifactFactory factory;
private ModelBuilder builder;
@PostConstruct
public void initialize()
@ -122,10 +120,11 @@ public class Maven3DependencyTreeBuilder
factory = plexusSisuBridge.lookup( ArtifactFactory.class, "default" );
DefaultModelBuilderFactory defaultModelBuilderFactory = new DefaultModelBuilderFactory();
builder = defaultModelBuilderFactory.newInstance();
defaultModelBuilderFactory.newInstance();
}
@Override
public void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
DependencyVisitor dependencyVisitor )
throws DependencyTreeBuilderException
@ -229,7 +228,7 @@ public class Maven3DependencyTreeBuilder
RepositorySystemSession session = newRepositorySystemSession( system, resolveRequest.localRepoDir );
org.sonatype.aether.artifact.Artifact artifact = new DefaultArtifact(
org.eclipse.aether.artifact.Artifact artifact = new DefaultArtifact(
resolveRequest.groupId + ":" + resolveRequest.artifactId + ":" + resolveRequest.version );
CollectRequest collectRequest = new CollectRequest();
@ -238,9 +237,8 @@ public class Maven3DependencyTreeBuilder
// add remote repositories
for ( RemoteRepository remoteRepository : resolveRequest.remoteRepositories )
{
collectRequest.addRepository(
new org.sonatype.aether.repository.RemoteRepository( remoteRepository.getId(), "default",
remoteRepository.getUrl() ) );
org.eclipse.aether.repository.RemoteRepository repo = new org.eclipse.aether.repository.RemoteRepository.Builder( remoteRepository.getId( ), "default", remoteRepository.getUrl( ) ).build( );
collectRequest.addRepository(repo);
}
collectRequest.setRequestContext( "project" );
@ -262,7 +260,7 @@ public class Maven3DependencyTreeBuilder
private RepositorySystem newRepositorySystem()
{
DefaultServiceLocator locator = new DefaultServiceLocator();
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator( );
locator.addService( RepositoryConnectorFactory.class,
ArchivaRepositoryConnectorFactory.class );// FileRepositoryConnectorFactory.class );
locator.addService( VersionResolver.class, DefaultVersionResolver.class );
@ -276,13 +274,22 @@ public class Maven3DependencyTreeBuilder
private RepositorySystemSession newRepositorySystemSession( RepositorySystem system, String localRepoDir )
{
MavenRepositorySystemSession session = new MavenRepositorySystemSession();
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession( );
LocalRepository repo = new LocalRepository( localRepoDir );
DependencySelector depFilter = new AndDependencySelector( new ExclusionDependencySelector() );
session.setDependencySelector( depFilter );
session.setLocalRepositoryManager(
new SimpleLocalRepositoryManager( localRepoDir ) );
SimpleLocalRepositoryManagerFactory repFactory = new SimpleLocalRepositoryManagerFactory( );
try
{
LocalRepositoryManager manager = repFactory.newInstance( session, repo );
session.setLocalRepositoryManager(manager);
}
catch ( NoLocalRepositoryManagerException e )
{
e.printStackTrace( );
}
return session;
}

View File

@ -20,10 +20,11 @@ package org.apache.archiva.dependency.tree.maven2;
import org.apache.archiva.maven2.model.Artifact;
import org.apache.archiva.maven2.model.TreeEntry;
import org.eclipse.aether.graph.DependencyVisitor;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.sonatype.aether.graph.DependencyNode;
import org.sonatype.aether.graph.DependencyVisitor;
import org.eclipse.aether.graph.DependencyNode;
import org.eclipse.aether.graph.DependencyVisitor;
import java.util.List;
@ -39,7 +40,7 @@ public class TreeDependencyNodeVisitor
private TreeEntry currentEntry;
private org.sonatype.aether.graph.DependencyNode firstDependencyNode;
private org.eclipse.aether.graph.DependencyNode firstDependencyNode;
public TreeDependencyNodeVisitor( List<TreeEntry> treeEntries )
{

View File

@ -34,6 +34,8 @@ import org.apache.archiva.repository.RepositoryCredentials;
import org.apache.archiva.xml.XMLException;
import org.apache.commons.lang.StringUtils;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Repository;
import org.apache.maven.model.building.FileModelSource;
import org.apache.maven.model.building.ModelSource;
@ -161,6 +163,20 @@ public class RepositoryModelResolver
return new FileModelSource( model.toFile() );
}
// TODO: v3.0.0 Implement this method
@Override
public ModelSource resolveModel( Parent parent ) throws UnresolvableModelException
{
return null;
}
// TODO: v3.0.0 Implement this method
@Override
public ModelSource resolveModel( Dependency dependency ) throws UnresolvableModelException
{
return null;
}
protected Path findTimeStampedSnapshotPom( String groupId, String artifactId, String version,
String parentDirectory )
{
@ -211,6 +227,12 @@ public class RepositoryModelResolver
// ID since they will rarely match
}
@Override
public void addRepository( Repository repository, boolean b ) throws InvalidRepositoryException
{
}
@Override
public ModelResolver newCopy()
{