mirror of https://github.com/apache/maven.git
o Fixed repo logging to go consistently through listener
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@998715 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3bbe5bcd80
commit
11afa6961f
|
@ -73,6 +73,7 @@ import org.sonatype.aether.resolution.ArtifactResolutionException;
|
||||||
import org.sonatype.aether.resolution.ArtifactResult;
|
import org.sonatype.aether.resolution.ArtifactResult;
|
||||||
import org.sonatype.aether.resolution.VersionRequest;
|
import org.sonatype.aether.resolution.VersionRequest;
|
||||||
import org.sonatype.aether.resolution.VersionResolutionException;
|
import org.sonatype.aether.resolution.VersionResolutionException;
|
||||||
|
import org.sonatype.aether.resolution.VersionResult;
|
||||||
import org.sonatype.aether.spi.locator.Service;
|
import org.sonatype.aether.spi.locator.Service;
|
||||||
import org.sonatype.aether.spi.locator.ServiceLocator;
|
import org.sonatype.aether.spi.locator.ServiceLocator;
|
||||||
import org.sonatype.aether.spi.log.Logger;
|
import org.sonatype.aether.spi.log.Logger;
|
||||||
|
@ -221,7 +222,9 @@ public class DefaultArtifactDescriptorReader
|
||||||
{
|
{
|
||||||
VersionRequest versionRequest =
|
VersionRequest versionRequest =
|
||||||
new VersionRequest( artifact, request.getRepositories(), request.getRequestContext() );
|
new VersionRequest( artifact, request.getRepositories(), request.getRequestContext() );
|
||||||
versionResolver.resolveVersion( session, versionRequest );
|
VersionResult versionResult = versionResolver.resolveVersion( session, versionRequest );
|
||||||
|
|
||||||
|
artifact = artifact.setVersion( versionResult.getVersion() );
|
||||||
}
|
}
|
||||||
catch ( VersionResolutionException e )
|
catch ( VersionResolutionException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.repository.internal;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -46,7 +45,6 @@ import org.sonatype.aether.impl.MetadataResolver;
|
||||||
import org.sonatype.aether.impl.VersionRangeResolver;
|
import org.sonatype.aether.impl.VersionRangeResolver;
|
||||||
import org.sonatype.aether.metadata.Metadata;
|
import org.sonatype.aether.metadata.Metadata;
|
||||||
import org.sonatype.aether.repository.ArtifactRepository;
|
import org.sonatype.aether.repository.ArtifactRepository;
|
||||||
import org.sonatype.aether.repository.LocalRepositoryManager;
|
|
||||||
import org.sonatype.aether.repository.RemoteRepository;
|
import org.sonatype.aether.repository.RemoteRepository;
|
||||||
import org.sonatype.aether.repository.WorkspaceReader;
|
import org.sonatype.aether.repository.WorkspaceReader;
|
||||||
import org.sonatype.aether.resolution.MetadataRequest;
|
import org.sonatype.aether.resolution.MetadataRequest;
|
||||||
|
@ -160,12 +158,16 @@ public class DefaultVersionRangeResolver
|
||||||
MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
|
MAVEN_METADATA_XML, Metadata.Nature.RELEASE_OR_SNAPSHOT );
|
||||||
|
|
||||||
List<MetadataRequest> metadataRequests = new ArrayList<MetadataRequest>( request.getRepositories().size() );
|
List<MetadataRequest> metadataRequests = new ArrayList<MetadataRequest>( request.getRepositories().size() );
|
||||||
|
|
||||||
|
metadataRequests.add( new MetadataRequest( metadata, null, request.getRequestContext() ) );
|
||||||
|
|
||||||
for ( RemoteRepository repository : request.getRepositories() )
|
for ( RemoteRepository repository : request.getRepositories() )
|
||||||
{
|
{
|
||||||
MetadataRequest metadataRequest = new MetadataRequest( metadata, repository, request.getRequestContext() );
|
MetadataRequest metadataRequest = new MetadataRequest( metadata, repository, request.getRequestContext() );
|
||||||
metadataRequest.setDeleteLocalCopyIfMissing( true );
|
metadataRequest.setDeleteLocalCopyIfMissing( true );
|
||||||
metadataRequests.add( metadataRequest );
|
metadataRequests.add( metadataRequest );
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataRequests );
|
List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataRequests );
|
||||||
|
|
||||||
WorkspaceReader workspace = session.getWorkspaceReader();
|
WorkspaceReader workspace = session.getWorkspaceReader();
|
||||||
|
@ -178,30 +180,22 @@ public class DefaultVersionRangeResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
|
|
||||||
File localMetadataFile = new File( lrm.getRepository().getBasedir(), lrm.getPathForLocalMetadata( metadata ) );
|
|
||||||
if ( localMetadataFile.isFile() )
|
|
||||||
{
|
|
||||||
metadata = metadata.setFile( localMetadataFile );
|
|
||||||
Versioning versioning = readVersions( session, metadata, result );
|
|
||||||
for ( String version : versioning.getVersions() )
|
|
||||||
{
|
|
||||||
if ( !versionIndex.containsKey( version ) )
|
|
||||||
{
|
|
||||||
versionIndex.put( version, lrm.getRepository() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( MetadataResult metadataResult : metadataResults )
|
for ( MetadataResult metadataResult : metadataResults )
|
||||||
{
|
{
|
||||||
result.addException( metadataResult.getException() );
|
result.addException( metadataResult.getException() );
|
||||||
Versioning versioning = readVersions( session, metadataResult.getMetadata(), result );
|
|
||||||
|
ArtifactRepository repository = metadataResult.getRequest().getRepository();
|
||||||
|
if ( repository == null )
|
||||||
|
{
|
||||||
|
repository = session.getLocalRepository();
|
||||||
|
}
|
||||||
|
|
||||||
|
Versioning versioning = readVersions( session, metadataResult.getMetadata(), repository, result );
|
||||||
for ( String version : versioning.getVersions() )
|
for ( String version : versioning.getVersions() )
|
||||||
{
|
{
|
||||||
if ( !versionIndex.containsKey( version ) )
|
if ( !versionIndex.containsKey( version ) )
|
||||||
{
|
{
|
||||||
versionIndex.put( version, metadataResult.getRequest().getRepository() );
|
versionIndex.put( version, repository );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,7 +203,8 @@ public class DefaultVersionRangeResolver
|
||||||
return versionIndex;
|
return versionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Versioning readVersions( RepositorySystemSession session, Metadata metadata, VersionRangeResult result )
|
private Versioning readVersions( RepositorySystemSession session, Metadata metadata, ArtifactRepository repository,
|
||||||
|
VersionRangeResult result )
|
||||||
{
|
{
|
||||||
Versioning versioning = null;
|
Versioning versioning = null;
|
||||||
|
|
||||||
|
@ -229,7 +224,7 @@ public class DefaultVersionRangeResolver
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
invalidMetadata( session, metadata, e );
|
invalidMetadata( session, metadata, repository, e );
|
||||||
result.addException( e );
|
result.addException( e );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -240,13 +235,15 @@ public class DefaultVersionRangeResolver
|
||||||
return ( versioning != null ) ? versioning : new Versioning();
|
return ( versioning != null ) ? versioning : new Versioning();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidMetadata( RepositorySystemSession session, Metadata metadata, Exception exception )
|
private void invalidMetadata( RepositorySystemSession session, Metadata metadata, ArtifactRepository repository,
|
||||||
|
Exception exception )
|
||||||
{
|
{
|
||||||
RepositoryListener listener = session.getRepositoryListener();
|
RepositoryListener listener = session.getRepositoryListener();
|
||||||
if ( listener != null )
|
if ( listener != null )
|
||||||
{
|
{
|
||||||
DefaultRepositoryEvent event = new DefaultRepositoryEvent( session, metadata );
|
DefaultRepositoryEvent event = new DefaultRepositoryEvent( session, metadata );
|
||||||
event.setException( exception );
|
event.setException( exception );
|
||||||
|
event.setRepository( repository );
|
||||||
listener.metadataInvalid( event );
|
listener.metadataInvalid( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.sonatype.aether.impl.VersionResolver;
|
||||||
import org.sonatype.aether.impl.internal.CacheUtils;
|
import org.sonatype.aether.impl.internal.CacheUtils;
|
||||||
import org.sonatype.aether.metadata.Metadata;
|
import org.sonatype.aether.metadata.Metadata;
|
||||||
import org.sonatype.aether.repository.ArtifactRepository;
|
import org.sonatype.aether.repository.ArtifactRepository;
|
||||||
import org.sonatype.aether.repository.LocalRepositoryManager;
|
|
||||||
import org.sonatype.aether.repository.RemoteRepository;
|
import org.sonatype.aether.repository.RemoteRepository;
|
||||||
import org.sonatype.aether.repository.WorkspaceReader;
|
import org.sonatype.aether.repository.WorkspaceReader;
|
||||||
import org.sonatype.aether.repository.WorkspaceRepository;
|
import org.sonatype.aether.repository.WorkspaceRepository;
|
||||||
|
@ -174,6 +173,9 @@ public class DefaultVersionResolver
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
List<MetadataRequest> metadataRequests = new ArrayList<MetadataRequest>( request.getRepositories().size() );
|
List<MetadataRequest> metadataRequests = new ArrayList<MetadataRequest>( request.getRepositories().size() );
|
||||||
|
|
||||||
|
metadataRequests.add( new MetadataRequest( metadata, null, request.getRequestContext() ) );
|
||||||
|
|
||||||
for ( RemoteRepository repository : request.getRepositories() )
|
for ( RemoteRepository repository : request.getRepositories() )
|
||||||
{
|
{
|
||||||
MetadataRequest metadataRequest =
|
MetadataRequest metadataRequest =
|
||||||
|
@ -182,25 +184,23 @@ public class DefaultVersionResolver
|
||||||
metadataRequest.setFavorLocalRepository( true );
|
metadataRequest.setFavorLocalRepository( true );
|
||||||
metadataRequests.add( metadataRequest );
|
metadataRequests.add( metadataRequest );
|
||||||
}
|
}
|
||||||
|
|
||||||
List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataRequests );
|
List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataRequests );
|
||||||
|
|
||||||
LocalRepositoryManager lrm = session.getLocalRepositoryManager();
|
|
||||||
File localMetadataFile =
|
|
||||||
new File( lrm.getRepository().getBasedir(), lrm.getPathForLocalMetadata( metadata ) );
|
|
||||||
if ( localMetadataFile.isFile() )
|
|
||||||
{
|
|
||||||
metadata = metadata.setFile( localMetadataFile );
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, VersionInfo> infos = new HashMap<String, VersionInfo>();
|
Map<String, VersionInfo> infos = new HashMap<String, VersionInfo>();
|
||||||
merge( artifact, infos, readVersions( session, metadata, result ),
|
|
||||||
session.getLocalRepositoryManager().getRepository() );
|
|
||||||
|
|
||||||
for ( MetadataResult metadataResult : metadataResults )
|
for ( MetadataResult metadataResult : metadataResults )
|
||||||
{
|
{
|
||||||
result.addException( metadataResult.getException() );
|
result.addException( metadataResult.getException() );
|
||||||
merge( artifact, infos, readVersions( session, metadataResult.getMetadata(), result ),
|
|
||||||
metadataResult.getRequest().getRepository() );
|
ArtifactRepository repository = metadataResult.getRequest().getRepository();
|
||||||
|
if ( repository == null )
|
||||||
|
{
|
||||||
|
repository = session.getLocalRepository();
|
||||||
|
}
|
||||||
|
|
||||||
|
Versioning versioning = readVersions( session, metadataResult.getMetadata(), repository, result );
|
||||||
|
merge( artifact, infos, versioning, repository );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( RELEASE.equals( version ) )
|
if ( RELEASE.equals( version ) )
|
||||||
|
@ -269,7 +269,8 @@ public class DefaultVersionResolver
|
||||||
return info != null;
|
return info != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Versioning readVersions( RepositorySystemSession session, Metadata metadata, VersionResult result )
|
private Versioning readVersions( RepositorySystemSession session, Metadata metadata, ArtifactRepository repository,
|
||||||
|
VersionResult result )
|
||||||
{
|
{
|
||||||
Versioning versioning = null;
|
Versioning versioning = null;
|
||||||
|
|
||||||
|
@ -289,7 +290,7 @@ public class DefaultVersionResolver
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
invalidMetadata( session, metadata, e );
|
invalidMetadata( session, metadata, repository, e );
|
||||||
result.addException( e );
|
result.addException( e );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -300,13 +301,15 @@ public class DefaultVersionResolver
|
||||||
return ( versioning != null ) ? versioning : new Versioning();
|
return ( versioning != null ) ? versioning : new Versioning();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invalidMetadata( RepositorySystemSession session, Metadata metadata, Exception exception )
|
private void invalidMetadata( RepositorySystemSession session, Metadata metadata, ArtifactRepository repository,
|
||||||
|
Exception exception )
|
||||||
{
|
{
|
||||||
RepositoryListener listener = session.getRepositoryListener();
|
RepositoryListener listener = session.getRepositoryListener();
|
||||||
if ( listener != null )
|
if ( listener != null )
|
||||||
{
|
{
|
||||||
DefaultRepositoryEvent event = new DefaultRepositoryEvent( session, metadata );
|
DefaultRepositoryEvent event = new DefaultRepositoryEvent( session, metadata );
|
||||||
event.setException( exception );
|
event.setException( exception );
|
||||||
|
event.setRepository( repository );
|
||||||
listener.metadataInvalid( event );
|
listener.metadataInvalid( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,6 @@ import org.sonatype.aether.util.graph.transformer.ConflictMarker;
|
||||||
import org.sonatype.aether.util.graph.transformer.JavaDependencyContextRefiner;
|
import org.sonatype.aether.util.graph.transformer.JavaDependencyContextRefiner;
|
||||||
import org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator;
|
import org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator;
|
||||||
import org.sonatype.aether.util.graph.traverser.FatArtifactTraverser;
|
import org.sonatype.aether.util.graph.traverser.FatArtifactTraverser;
|
||||||
import org.sonatype.aether.util.listener.AbstractRepositoryListener;
|
|
||||||
import org.sonatype.aether.util.repository.ChainedWorkspaceReader;
|
import org.sonatype.aether.util.repository.ChainedWorkspaceReader;
|
||||||
import org.sonatype.aether.util.repository.DefaultAuthenticationSelector;
|
import org.sonatype.aether.util.repository.DefaultAuthenticationSelector;
|
||||||
import org.sonatype.aether.util.repository.DefaultMirrorSelector;
|
import org.sonatype.aether.util.repository.DefaultMirrorSelector;
|
||||||
|
@ -421,43 +420,7 @@ public class DefaultMaven
|
||||||
|
|
||||||
session.setTransferListener( request.getTransferListener() );
|
session.setTransferListener( request.getTransferListener() );
|
||||||
|
|
||||||
session.setRepositoryListener( new AbstractRepositoryListener()
|
session.setRepositoryListener( new LoggingRepositoryListener( logger ) );
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void artifactInstalling( RepositoryEvent event )
|
|
||||||
{
|
|
||||||
logger.info( "Installing " + event.getArtifact().getFile() + " to " + event.getFile() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void metadataInstalling( RepositoryEvent event )
|
|
||||||
{
|
|
||||||
logger.debug( "Installing " + event.getMetadata() + " to " + event.getFile() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void artifactDescriptorInvalid( RepositoryEvent event )
|
|
||||||
{
|
|
||||||
if ( logger.isDebugEnabled() )
|
|
||||||
{
|
|
||||||
logger.warn( "The POM for " + event.getArtifact() + " is invalid"
|
|
||||||
+ ", transitive dependencies (if any) will not be available: "
|
|
||||||
+ event.getException().getMessage() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.warn( "The POM for " + event.getArtifact() + " is invalid"
|
|
||||||
+ ", transitive dependencies (if any) will not be available"
|
|
||||||
+ ", enable debug logging for more details" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void artifactDescriptorMissing( RepositoryEvent event )
|
|
||||||
{
|
|
||||||
logger.warn( "The POM for " + event.getArtifact() + " is missing, no dependency information available" );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
package org.apache.maven;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.logging.Logger;
|
||||||
|
import org.sonatype.aether.RepositoryEvent;
|
||||||
|
import org.sonatype.aether.transfer.MetadataNotFoundException;
|
||||||
|
import org.sonatype.aether.util.listener.AbstractRepositoryListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
class LoggingRepositoryListener
|
||||||
|
extends AbstractRepositoryListener
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
|
public LoggingRepositoryListener( Logger logger )
|
||||||
|
{
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void artifactInstalling( RepositoryEvent event )
|
||||||
|
{
|
||||||
|
logger.info( "Installing " + event.getArtifact().getFile() + " to " + event.getFile() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void metadataInstalling( RepositoryEvent event )
|
||||||
|
{
|
||||||
|
logger.debug( "Installing " + event.getMetadata() + " to " + event.getFile() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void metadataResolved( RepositoryEvent event )
|
||||||
|
{
|
||||||
|
Exception e = event.getException();
|
||||||
|
if ( e != null )
|
||||||
|
{
|
||||||
|
if ( e instanceof MetadataNotFoundException )
|
||||||
|
{
|
||||||
|
logger.debug( e.getMessage() );
|
||||||
|
}
|
||||||
|
else if ( logger.isDebugEnabled() )
|
||||||
|
{
|
||||||
|
logger.warn( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.warn( e.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void metadataInvalid( RepositoryEvent event )
|
||||||
|
{
|
||||||
|
StringBuilder buffer = new StringBuilder( 256 );
|
||||||
|
buffer.append( "The metadata " );
|
||||||
|
if ( event.getMetadata().getFile() != null )
|
||||||
|
{
|
||||||
|
buffer.append( event.getMetadata().getFile() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer.append( event.getMetadata() );
|
||||||
|
}
|
||||||
|
buffer.append( " is invalid" );
|
||||||
|
if ( event.getException() != null )
|
||||||
|
{
|
||||||
|
buffer.append( ": " );
|
||||||
|
buffer.append( event.getException().getMessage() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( logger.isDebugEnabled() )
|
||||||
|
{
|
||||||
|
logger.warn( buffer.toString(), event.getException() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.warn( buffer.toString() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void artifactDescriptorInvalid( RepositoryEvent event )
|
||||||
|
{
|
||||||
|
StringBuilder buffer = new StringBuilder( 256 );
|
||||||
|
buffer.append( "The POM for " );
|
||||||
|
buffer.append( event.getArtifact() );
|
||||||
|
buffer.append( " is invalid, transitive dependencies (if any) will not be available" );
|
||||||
|
|
||||||
|
if ( logger.isDebugEnabled() )
|
||||||
|
{
|
||||||
|
logger.warn( buffer + ": " + event.getException().getMessage() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.warn( buffer + ", enable debug logging for more details" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void artifactDescriptorMissing( RepositoryEvent event )
|
||||||
|
{
|
||||||
|
logger.warn( "The POM for " + event.getArtifact() + " is missing, no dependency information available" );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -19,7 +19,6 @@ package org.apache.maven.plugin.prefix.internal;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -39,14 +38,16 @@ import org.apache.maven.plugin.prefix.PluginPrefixResult;
|
||||||
import org.codehaus.plexus.component.annotations.Component;
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
|
import org.sonatype.aether.RepositoryListener;
|
||||||
import org.sonatype.aether.RepositorySystem;
|
import org.sonatype.aether.RepositorySystem;
|
||||||
|
import org.sonatype.aether.RepositorySystemSession;
|
||||||
import org.sonatype.aether.repository.ArtifactRepository;
|
import org.sonatype.aether.repository.ArtifactRepository;
|
||||||
import org.sonatype.aether.repository.RemoteRepository;
|
import org.sonatype.aether.repository.RemoteRepository;
|
||||||
import org.sonatype.aether.repository.RepositoryPolicy;
|
import org.sonatype.aether.repository.RepositoryPolicy;
|
||||||
import org.sonatype.aether.resolution.MetadataRequest;
|
import org.sonatype.aether.resolution.MetadataRequest;
|
||||||
import org.sonatype.aether.resolution.MetadataResult;
|
import org.sonatype.aether.resolution.MetadataResult;
|
||||||
import org.sonatype.aether.transfer.MetadataNotFoundException;
|
|
||||||
import org.sonatype.aether.util.DefaultRepositorySystemSession;
|
import org.sonatype.aether.util.DefaultRepositorySystemSession;
|
||||||
|
import org.sonatype.aether.util.listener.DefaultRepositoryEvent;
|
||||||
import org.sonatype.aether.util.metadata.DefaultMetadata;
|
import org.sonatype.aether.util.metadata.DefaultMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,25 +208,6 @@ public class DefaultPluginPrefixResolver
|
||||||
{
|
{
|
||||||
for ( MetadataResult res : results )
|
for ( MetadataResult res : results )
|
||||||
{
|
{
|
||||||
if ( res.getException() != null )
|
|
||||||
{
|
|
||||||
if ( res.getException() instanceof MetadataNotFoundException )
|
|
||||||
{
|
|
||||||
logger.debug( "Could not find " + res.getRequest().getMetadata() + " in "
|
|
||||||
+ res.getRequest().getRepository() );
|
|
||||||
}
|
|
||||||
else if ( logger.isDebugEnabled() )
|
|
||||||
{
|
|
||||||
logger.warn( "Could not retrieve " + res.getRequest().getMetadata() + " from "
|
|
||||||
+ res.getRequest().getRepository() + ": " + res.getException().getMessage(), res.getException() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.warn( "Could not retrieve " + res.getRequest().getMetadata() + " from "
|
|
||||||
+ res.getRequest().getRepository() + ": " + res.getException().getMessage() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
org.sonatype.aether.metadata.Metadata metadata = res.getMetadata();
|
org.sonatype.aether.metadata.Metadata metadata = res.getMetadata();
|
||||||
|
|
||||||
if ( metadata != null )
|
if ( metadata != null )
|
||||||
|
@ -237,7 +219,7 @@ public class DefaultPluginPrefixResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginPrefixResult result =
|
PluginPrefixResult result =
|
||||||
resolveFromRepository( request, metadata.getGroupId(), metadata.getFile(), repository );
|
resolveFromRepository( request, metadata.getGroupId(), metadata, repository );
|
||||||
|
|
||||||
if ( result != null )
|
if ( result != null )
|
||||||
{
|
{
|
||||||
|
@ -255,15 +237,16 @@ public class DefaultPluginPrefixResolver
|
||||||
}
|
}
|
||||||
|
|
||||||
private PluginPrefixResult resolveFromRepository( PluginPrefixRequest request, String pluginGroup,
|
private PluginPrefixResult resolveFromRepository( PluginPrefixRequest request, String pluginGroup,
|
||||||
File metadataFile, ArtifactRepository repository )
|
org.sonatype.aether.metadata.Metadata metadata,
|
||||||
|
ArtifactRepository repository )
|
||||||
{
|
{
|
||||||
if ( metadataFile != null && metadataFile.isFile() )
|
if ( metadata != null && metadata.getFile() != null && metadata.getFile().isFile() )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Map<String, ?> options = Collections.singletonMap( MetadataReader.IS_STRICT, Boolean.FALSE );
|
Map<String, ?> options = Collections.singletonMap( MetadataReader.IS_STRICT, Boolean.FALSE );
|
||||||
|
|
||||||
Metadata pluginGroupMetadata = metadataReader.read( metadataFile, options );
|
Metadata pluginGroupMetadata = metadataReader.read( metadata.getFile(), options );
|
||||||
|
|
||||||
List<org.apache.maven.artifact.repository.metadata.Plugin> plugins = pluginGroupMetadata.getPlugins();
|
List<org.apache.maven.artifact.repository.metadata.Plugin> plugins = pluginGroupMetadata.getPlugins();
|
||||||
|
|
||||||
|
@ -280,18 +263,24 @@ public class DefaultPluginPrefixResolver
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
if ( logger.isDebugEnabled() )
|
invalidMetadata( request.getRepositorySession(), metadata, repository, e );
|
||||||
{
|
|
||||||
logger.warn( "Error reading plugin group metadata: " + e.getMessage(), e );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.warn( "Error reading plugin group metadata: " + e.getMessage() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void invalidMetadata( RepositorySystemSession session, org.sonatype.aether.metadata.Metadata metadata,
|
||||||
|
ArtifactRepository repository, Exception exception )
|
||||||
|
{
|
||||||
|
RepositoryListener listener = session.getRepositoryListener();
|
||||||
|
if ( listener != null )
|
||||||
|
{
|
||||||
|
DefaultRepositoryEvent event = new DefaultRepositoryEvent( session, metadata );
|
||||||
|
event.setException( exception );
|
||||||
|
event.setRepository( repository );
|
||||||
|
listener.metadataInvalid( event );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.plugin.version.internal;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -39,13 +38,15 @@ import org.codehaus.plexus.component.annotations.Component;
|
||||||
import org.codehaus.plexus.component.annotations.Requirement;
|
import org.codehaus.plexus.component.annotations.Requirement;
|
||||||
import org.codehaus.plexus.logging.Logger;
|
import org.codehaus.plexus.logging.Logger;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
import org.sonatype.aether.RepositoryListener;
|
||||||
import org.sonatype.aether.RepositorySystem;
|
import org.sonatype.aether.RepositorySystem;
|
||||||
|
import org.sonatype.aether.RepositorySystemSession;
|
||||||
import org.sonatype.aether.repository.ArtifactRepository;
|
import org.sonatype.aether.repository.ArtifactRepository;
|
||||||
import org.sonatype.aether.repository.LocalRepository;
|
import org.sonatype.aether.repository.LocalRepository;
|
||||||
import org.sonatype.aether.repository.RemoteRepository;
|
import org.sonatype.aether.repository.RemoteRepository;
|
||||||
import org.sonatype.aether.resolution.MetadataRequest;
|
import org.sonatype.aether.resolution.MetadataRequest;
|
||||||
import org.sonatype.aether.resolution.MetadataResult;
|
import org.sonatype.aether.resolution.MetadataResult;
|
||||||
import org.sonatype.aether.transfer.MetadataNotFoundException;
|
import org.sonatype.aether.util.listener.DefaultRepositoryEvent;
|
||||||
import org.sonatype.aether.util.metadata.DefaultMetadata;
|
import org.sonatype.aether.util.metadata.DefaultMetadata;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,29 +123,13 @@ public class DefaultPluginVersionResolver
|
||||||
|
|
||||||
for ( MetadataResult res : results )
|
for ( MetadataResult res : results )
|
||||||
{
|
{
|
||||||
if ( res.getException() != null )
|
ArtifactRepository repository = res.getRequest().getRepository();
|
||||||
|
if ( repository == null )
|
||||||
{
|
{
|
||||||
if ( res.getException() instanceof MetadataNotFoundException )
|
repository = request.getRepositorySession().getLocalRepository();
|
||||||
{
|
|
||||||
logger.debug( "Could not find " + res.getRequest().getMetadata() + " in "
|
|
||||||
+ res.getRequest().getRepository() );
|
|
||||||
}
|
|
||||||
else if ( logger.isDebugEnabled() )
|
|
||||||
{
|
|
||||||
logger.warn( "Could not retrieve " + res.getRequest().getMetadata() + " from "
|
|
||||||
+ res.getRequest().getRepository() + ": " + res.getException().getMessage(), res.getException() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger.warn( "Could not retrieve " + res.getRequest().getMetadata() + " from "
|
|
||||||
+ res.getRequest().getRepository() + ": " + res.getException().getMessage() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( res.getMetadata() != null )
|
mergeMetadata( request.getRepositorySession(), versions, res.getMetadata(), repository );
|
||||||
{
|
|
||||||
mergeMetadata( versions, res.getMetadata().getFile(), res.getRequest().getRepository() );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( StringUtils.isNotEmpty( versions.releaseVersion ) )
|
if ( StringUtils.isNotEmpty( versions.releaseVersion ) )
|
||||||
|
@ -167,29 +152,36 @@ public class DefaultPluginVersionResolver
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeMetadata( Versions versions, File metadataFile, ArtifactRepository repository )
|
private void mergeMetadata( RepositorySystemSession session, Versions versions,
|
||||||
|
org.sonatype.aether.metadata.Metadata metadata, ArtifactRepository repository )
|
||||||
{
|
{
|
||||||
if ( metadataFile != null && metadataFile.isFile() )
|
if ( metadata != null && metadata.getFile() != null && metadata.getFile().isFile() )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Map<String, ?> options = Collections.singletonMap( MetadataReader.IS_STRICT, Boolean.FALSE );
|
Map<String, ?> options = Collections.singletonMap( MetadataReader.IS_STRICT, Boolean.FALSE );
|
||||||
|
|
||||||
Metadata repoMetadata = metadataReader.read( metadataFile, options );
|
Metadata repoMetadata = metadataReader.read( metadata.getFile(), options );
|
||||||
|
|
||||||
mergeMetadata( versions, repoMetadata, repository );
|
mergeMetadata( versions, repoMetadata, repository );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
if ( logger.isDebugEnabled() )
|
invalidMetadata( session, metadata, repository, e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void invalidMetadata( RepositorySystemSession session, org.sonatype.aether.metadata.Metadata metadata,
|
||||||
|
ArtifactRepository repository, Exception exception )
|
||||||
{
|
{
|
||||||
logger.warn( "Failed to read metadata " + metadataFile + ": " + e.getMessage(), e );
|
RepositoryListener listener = session.getRepositoryListener();
|
||||||
}
|
if ( listener != null )
|
||||||
else
|
|
||||||
{
|
{
|
||||||
logger.warn( "Failed to read metadata " + metadataFile + ": " + e.getMessage() );
|
DefaultRepositoryEvent event = new DefaultRepositoryEvent( session, metadata );
|
||||||
}
|
event.setException( exception );
|
||||||
}
|
event.setRepository( repository );
|
||||||
|
listener.metadataInvalid( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ abstract class AbstractMavenTransferListener
|
||||||
|
|
||||||
public void transferSucceeded( TransferEvent event )
|
public void transferSucceeded( TransferEvent event )
|
||||||
{
|
{
|
||||||
TransferResource artifact = event.getResource();
|
TransferResource resource = event.getResource();
|
||||||
long contentLength = event.getTransferredBytes();
|
long contentLength = event.getTransferredBytes();
|
||||||
if ( contentLength >= 0 )
|
if ( contentLength >= 0 )
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ abstract class AbstractMavenTransferListener
|
||||||
String len = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B";
|
String len = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B";
|
||||||
|
|
||||||
String throughput = "";
|
String throughput = "";
|
||||||
long duration = System.currentTimeMillis() - artifact.getTransferStartTime();
|
long duration = System.currentTimeMillis() - resource.getTransferStartTime();
|
||||||
if ( duration > 0 )
|
if ( duration > 0 )
|
||||||
{
|
{
|
||||||
DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) );
|
DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) );
|
||||||
|
@ -64,7 +64,7 @@ abstract class AbstractMavenTransferListener
|
||||||
throughput = " at " + format.format( kbPerSec ) + " KB/sec";
|
throughput = " at " + format.format( kbPerSec ) + " KB/sec";
|
||||||
}
|
}
|
||||||
|
|
||||||
out.println( type + ": " + artifact.getRepositoryUrl() + artifact.getResourceName() + " (" + len
|
out.println( type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len
|
||||||
+ throughput + ")" );
|
+ throughput + ")" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue