Skip to content

Commit

Permalink
[MNG-6672] Upgrade Maven Resolver to 1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-o committed Jun 12, 2019
1 parent d3ace78 commit 25ffca0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.eclipse.aether.impl.RepositoryEventDispatcher;
import org.eclipse.aether.impl.SyncContextFactory;
import org.eclipse.aether.impl.VersionResolver;
import org.eclipse.aether.internal.impl.CacheUtils;
import org.eclipse.aether.metadata.DefaultMetadata;
import org.eclipse.aether.metadata.Metadata;
import org.eclipse.aether.repository.ArtifactRepository;
Expand Down Expand Up @@ -154,7 +153,7 @@ public VersionResult resolveVersion( RepositorySystemSession session, VersionReq
Record record = (Record) obj;
result.setVersion( record.version );
result.setRepository(
CacheUtils.getRepository( session, request.getRepositories(), record.repoClass, record.repoId ) );
getRepository( session, request.getRepositories(), record.repoClass, record.repoId ) );
return result;
}
}
Expand Down Expand Up @@ -429,6 +428,34 @@ private String getKey( String classifier, String extension )
return StringUtils.clean( classifier ) + ':' + StringUtils.clean( extension );
}

private ArtifactRepository getRepository( RepositorySystemSession session,
List<RemoteRepository> repositories, Class<?> repoClass,
String repoId )
{
if ( repoClass != null )
{
if ( WorkspaceRepository.class.isAssignableFrom( repoClass ) )
{
return session.getWorkspaceReader().getRepository();
}
else if ( LocalRepository.class.isAssignableFrom( repoClass ) )
{
return session.getLocalRepository();
}
else
{
for ( RemoteRepository repository : repositories )
{
if ( repoId.equals( repository.getId() ) )
{
return repository;
}
}
}
}
return null;
}

private boolean isSafelyCacheable( RepositorySystemSession session, Artifact artifact )
{
/*
Expand Down Expand Up @@ -502,7 +529,8 @@ private static class Key
extension = artifact.getExtension();
version = artifact.getVersion();
localRepo = session.getLocalRepository().getBasedir();
workspace = CacheUtils.getWorkspace( session );
WorkspaceReader reader = session.getWorkspaceReader();
workspace = ( reader != null ) ? reader.getRepository() : null;
repositories = new ArrayList<>( request.getRepositories().size() );
boolean repoMan = false;
for ( RemoteRepository repository : request.getRepositories() )
Expand All @@ -526,7 +554,7 @@ private static class Key
hash = hash * 31 + extension.hashCode();
hash = hash * 31 + version.hashCode();
hash = hash * 31 + localRepo.hashCode();
hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
hash = hash * 31 + repositories.hashCode();
hashCode = hash;
}

Expand All @@ -546,8 +574,7 @@ else if ( obj == null || !getClass().equals( obj.getClass() ) )
return artifactId.equals( that.artifactId ) && groupId.equals( that.groupId ) && classifier.equals(
that.classifier ) && extension.equals( that.extension ) && version.equals( that.version )
&& context.equals( that.context ) && localRepo.equals( that.localRepo )
&& CacheUtils.eq( workspace, that.workspace )
&& CacheUtils.repositoriesEquals( repositories, that.repositories );
&& Objects.equals( workspace, that.workspace ) && repositories.equals( that.repositories );
}

@Override
Expand Down Expand Up @@ -582,4 +609,4 @@ private static class Record
}
}

}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ under the License.
<cipherVersion>1.7</cipherVersion>
<modelloVersion>1.10.0</modelloVersion>
<jxpathVersion>1.3</jxpathVersion>
<resolverVersion>1.3.3</resolverVersion>
<resolverVersion>1.4.0</resolverVersion>
<slf4jVersion>1.7.25</slf4jVersion>
<xmlunitVersion>2.2.1</xmlunitVersion>
<maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
Expand Down

0 comments on commit 25ffca0

Please sign in to comment.