mirror of https://github.com/apache/maven.git
add verbose mode for ant tasks
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@192970 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f2653b0cb7
commit
c0e768cc1d
|
@ -55,7 +55,7 @@
|
|||
<fileset refid="dependency.fileset"/>
|
||||
</copy>
|
||||
|
||||
<artifact:dependencies filesetId="my.dependency.fileset">
|
||||
<artifact:dependencies filesetId="my.dependency.fileset" verbose="true">
|
||||
<pom refid="maven.project"/>
|
||||
</artifact:dependencies>
|
||||
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
package org.apache.maven.artifact.ant;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.Artifact;
|
||||
import org.apache.maven.artifact.resolver.ResolutionListener;
|
||||
import org.apache.tools.ant.Project;
|
||||
|
||||
/**
|
||||
* Show resolution information in Ant.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AntResolutionListener
|
||||
implements ResolutionListener
|
||||
{
|
||||
private String indent = "";
|
||||
|
||||
private final Project project;
|
||||
|
||||
public AntResolutionListener( Project project )
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void testArtifact( Artifact node )
|
||||
{
|
||||
}
|
||||
|
||||
public void startProcessChildren( Artifact artifact )
|
||||
{
|
||||
indent += " ";
|
||||
}
|
||||
|
||||
public void endProcessChildren( Artifact artifact )
|
||||
{
|
||||
indent = indent.substring( 2 );
|
||||
}
|
||||
|
||||
public void includeArtifact( Artifact artifact )
|
||||
{
|
||||
project.log( indent + artifact.getId() + " (selected)" );
|
||||
}
|
||||
|
||||
public void omitForNearer( Artifact omitted, Artifact kept )
|
||||
{
|
||||
project.log( indent + omitted.getId() + " (removed - nearer found: " + kept.getVersion() + ")" );
|
||||
}
|
||||
|
||||
public void omitForCycle( Artifact omitted )
|
||||
{
|
||||
project.log( indent + omitted.getId() + " (removed - causes a cycle in the graph)" );
|
||||
}
|
||||
|
||||
public void updateScope( Artifact artifact, String scope )
|
||||
{
|
||||
project.log( indent + artifact.getId() + " (settings scope to: " + scope + ")" );
|
||||
}
|
||||
|
||||
public void manageArtifact( Artifact artifact, Artifact replacement )
|
||||
{
|
||||
String msg = indent + artifact.getId();
|
||||
msg += " (";
|
||||
if ( replacement.getVersion() != null )
|
||||
{
|
||||
msg += "applying version: " + replacement.getVersion() + ";";
|
||||
}
|
||||
if ( replacement.getScope() != null )
|
||||
{
|
||||
msg += "applying scope: " + replacement.getScope();
|
||||
}
|
||||
msg += ")";
|
||||
project.log( msg );
|
||||
}
|
||||
}
|
|
@ -32,6 +32,7 @@ import org.apache.tools.ant.types.FileSet;
|
|||
import org.apache.tools.ant.types.Path;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -53,6 +54,8 @@ public class DependenciesTask
|
|||
|
||||
private String filesetId;
|
||||
|
||||
private boolean verbose;
|
||||
|
||||
public void execute()
|
||||
{
|
||||
ArtifactRepository localRepo = createLocalArtifactRepository();
|
||||
|
@ -101,10 +104,16 @@ public class DependenciesTask
|
|||
Artifact pomArtifact = artifactFactory.createArtifact( pom.getGroupId(), pom.getArtifactId(),
|
||||
pom.getVersion(), null, pom.getPackaging() );
|
||||
|
||||
List listeners = Collections.EMPTY_LIST;
|
||||
if ( verbose )
|
||||
{
|
||||
listeners = Collections.singletonList( new AntResolutionListener( getProject() ) );
|
||||
}
|
||||
|
||||
List remoteArtifactRepositories = createRemoteArtifactRepositories( getRemoteRepositories() );
|
||||
// TODO: managed dependencies
|
||||
result = resolver.resolveTransitively( artifacts, pomArtifact, remoteArtifactRepositories, localRepo,
|
||||
metadataSource );
|
||||
metadataSource, listeners );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
|
@ -209,4 +218,9 @@ public class DependenciesTask
|
|||
{
|
||||
this.filesetId = filesetId;
|
||||
}
|
||||
|
||||
public void setVerbose( boolean verbose )
|
||||
{
|
||||
this.verbose = verbose;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,12 +43,12 @@ public class DebugResolutionListener
|
|||
|
||||
public void startProcessChildren( Artifact artifact )
|
||||
{
|
||||
indent += " ";
|
||||
indent += " ";
|
||||
}
|
||||
|
||||
public void endProcessChildren( Artifact artifact )
|
||||
{
|
||||
indent = indent.substring( 1 );
|
||||
indent = indent.substring( 2 );
|
||||
}
|
||||
|
||||
public void includeArtifact( Artifact artifact )
|
||||
|
|
|
@ -151,8 +151,6 @@ public class DefaultArtifactResolver
|
|||
ArtifactFilter filter )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactResolutionResult artifactResolutionResult;
|
||||
|
||||
// TODO: this is simplistic
|
||||
List listeners = new ArrayList();
|
||||
if ( getLogger().isDebugEnabled() )
|
||||
|
@ -160,6 +158,18 @@ public class DefaultArtifactResolver
|
|||
listeners.add( new DebugResolutionListener( getLogger() ) );
|
||||
}
|
||||
|
||||
return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
|
||||
remoteRepositories, source, filter, listeners );
|
||||
|
||||
}
|
||||
|
||||
private ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
Map managedVersions, ArtifactRepository localRepository,
|
||||
List remoteRepositories, ArtifactMetadataSource source,
|
||||
ArtifactFilter filter, List listeners )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
ArtifactResolutionResult artifactResolutionResult;
|
||||
artifactResolutionResult = artifactCollector.collect( artifacts, originatingArtifact, managedVersions,
|
||||
localRepository, remoteRepositories, source, filter,
|
||||
artifactFactory, listeners );
|
||||
|
@ -181,4 +191,13 @@ public class DefaultArtifactResolver
|
|||
return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null );
|
||||
}
|
||||
|
||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
List remoteRepositories, ArtifactRepository localRepository,
|
||||
ArtifactMetadataSource source, List listeners )
|
||||
throws ArtifactResolutionException
|
||||
{
|
||||
return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository,
|
||||
remoteRepositories, source, null, listeners );
|
||||
}
|
||||
|
||||
}
|
|
@ -44,6 +44,11 @@ public interface ArtifactResolver
|
|||
ArtifactRepository localRepository, ArtifactMetadataSource source )
|
||||
throws ArtifactResolutionException;
|
||||
|
||||
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories,
|
||||
ArtifactRepository localRepository, ArtifactMetadataSource source,
|
||||
List listeners )
|
||||
throws ArtifactResolutionException;
|
||||
|
||||
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||
ArtifactRepository localRepository, List remoteRepositories,
|
||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||
|
|
Loading…
Reference in New Issue