You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2007/05/26 17:59:45 UTC

svn commit: r541906 - in /maven/ant-tasks/branches/maven-ant-tasks-2.0.x: ./ src/main/java/org/apache/maven/artifact/ant/

Author: jvanzyl
Date: Sat May 26 08:59:44 2007
New Revision: 541906

URL: http://svn.apache.org/viewvc?view=rev&rev=541906
Log:
MANTTASKS 66 Adding more information when run in verbose mode
Submitted by: Herve Boutemy

Modified:
    maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml
    maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
    maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AntResolutionListener.java
    maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java

Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml
URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml?view=diff&rev=541906&r1=541905&r2=541906
==============================================================================
--- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml (original)
+++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/sample.build.xml Sat May 26 08:59:44 2007
@@ -23,7 +23,7 @@
   <target name="initTaskDefs">
     <!-- don't forget to update the version! -->
     <path id="maven.classpath">
-      <pathelement location="target/maven-ant-tasks-1.0-SNAPSHOT-uber.jar" />
+      <pathelement location="target/maven-ant-tasks-2.1-SNAPSHOT.jar" />
     </path>
 
     <typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant">

Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java?view=diff&rev=541906&r1=541905&r2=541906
==============================================================================
--- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java (original)
+++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactTask.java Sat May 26 08:59:44 2007
@@ -197,6 +197,7 @@
         FileReader reader = null;
         try
         {
+            log( "Loading Maven settings file: " + settingsFile.getPath(), Project.MSG_VERBOSE );
             reader = new FileReader( settingsFile );
 
             SettingsXpp3Reader modelReader = new SettingsXpp3Reader();
@@ -441,6 +442,7 @@
         if ( profiles != null )
         {
             // TODO: not sure this is the best way to do this...
+            log( "Profiles not yet supported, ignoring profiles '" + profiles + "'", Project.MSG_WARN );
 //            System.setProperty( ProfileActivationUtils.ACTIVE_PROFILE_IDS, profiles );
         }
     }

Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AntResolutionListener.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AntResolutionListener.java?view=diff&rev=541906&r1=541905&r2=541906
==============================================================================
--- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AntResolutionListener.java (original)
+++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/AntResolutionListener.java Sat May 26 08:59:44 2007
@@ -36,10 +36,13 @@
     private String indent = "";
 
     private final Project project;
+    
+    private int logLevel;
 
-    public AntResolutionListener( Project project )
+    public AntResolutionListener( Project project, boolean verbose )
     {
         this.project = project;
+        logLevel = verbose ? Project.MSG_INFO : Project.MSG_VERBOSE;
     }
 
     public void testArtifact( Artifact node )
@@ -58,40 +61,40 @@
 
     public void includeArtifact( Artifact artifact )
     {
-        project.log( indent + artifact + " (selected)" );
+        project.log( indent + artifact + " (selected)", logLevel );
     }
 
     public void omitForNearer( Artifact omitted, Artifact kept )
     {
-        project.log( indent + omitted + " (removed - nearer found: " + kept.getVersion() + ")" );
+        project.log( indent + omitted + " (removed - nearer found: " + kept.getVersion() + ")", logLevel );
     }
 
     public void omitForCycle( Artifact omitted )
     {
-        project.log( indent + omitted + " (removed - causes a cycle in the graph)" );
+        project.log( indent + omitted + " (removed - causes a cycle in the graph)", logLevel );
     }
 
     public void updateScope( Artifact artifact, String scope )
     {
-        project.log( indent + artifact + " (setting scope to: " + scope + ")" );
+        project.log( indent + artifact + " (setting scope to: " + scope + ")", logLevel );
     }
 
     public void updateScopeCurrentPom( Artifact artifact, String scope )
     {
         project.log( indent + artifact + " (not setting scope to: " + scope + "; local scope " + artifact.getScope() +
-            " wins)" );
+            " wins)", logLevel );
     }
 
     public void selectVersionFromRange( Artifact artifact )
     {
         project.log( indent + artifact + " (setting version to: " + artifact.getVersion() + " from range: " +
-            artifact.getVersionRange() + ")" );
+            artifact.getVersionRange() + ")", logLevel );
     }
 
     public void restrictRange( Artifact artifact, Artifact replacement, VersionRange newRange )
     {
         project.log( indent + artifact + " (range restricted from: " + artifact.getVersionRange() + " and: " +
-            replacement.getVersionRange() + " to: " + newRange + " )" );
+            replacement.getVersionRange() + " to: " + newRange + " )", logLevel );
     }
 
     public void manageArtifact( Artifact artifact, Artifact replacement )
@@ -107,6 +110,6 @@
             msg += "applying scope: " + replacement.getScope();
         }
         msg += ")";
-        project.log( msg );
+        project.log( msg, logLevel );
     }
 }

Modified: maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java?view=diff&rev=541906&r1=541905&r2=541906
==============================================================================
--- maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java (original)
+++ maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java Sat May 26 08:59:44 2007
@@ -43,11 +43,14 @@
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Path;
 
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 
 /**
@@ -77,7 +80,10 @@
 
     protected void doExecute()
     {
+        showVersion();
+        
         ArtifactRepository localRepo = createLocalArtifactRepository();
+        log( "Using local repository: " + localRepo.getBasedir(), Project.MSG_VERBOSE );
 
         ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
         MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
@@ -136,11 +142,7 @@
             Artifact pomArtifact = artifactFactory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(), pom
                 .getVersion(), pom.getPackaging() );
 
-            List listeners = Collections.EMPTY_LIST;
-            if ( verbose )
-            {
-                listeners = Collections.singletonList( new AntResolutionListener( getProject() ) );
-            }
+            List listeners = Collections.singletonList( new AntResolutionListener( getProject(), verbose ) );
 
             // TODO: managed dependencies
             Map managedDependencies = Collections.EMPTY_MAP;
@@ -229,6 +231,7 @@
 
                 if ( sourcesFilesetId != null )
                 {
+                    log( "Resolving dependencies sources...", Project.MSG_VERBOSE );
                     // get sources
                     Artifact sourcesArtifact =
                         artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(),
@@ -278,12 +281,35 @@
         }
     }
 
+    private static String statusAsString( RepositoryPolicy policy )
+    {
+        return (policy == null) || policy.isEnabled() ? "enabled" : "disabled";
+    }
+
     private List createRemoteArtifactRepositories( List remoteRepositories )
     {
+        log( "Using remote repositories:", Project.MSG_VERBOSE );
         List list = new ArrayList();
         for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
         {
-            list.add( createRemoteArtifactRepository( (RemoteRepository) i.next() ) );
+            RemoteRepository remoteRepository = (RemoteRepository) i.next();
+
+            StringBuffer msg = new StringBuffer();
+            msg.append( "  - id=" + remoteRepository.getId() );
+            msg.append( ", url=" + remoteRepository.getUrl() );
+            msg.append( ", releases=" + statusAsString( remoteRepository.getReleases() ) );
+            msg.append( ", snapshots=" + statusAsString( remoteRepository.getSnapshots() ) );
+            if ( remoteRepository.getAuthentication() != null )
+            {
+                msg.append( ", authentication=" + remoteRepository.getAuthentication().getUserName() );
+            }
+            if ( remoteRepository.getProxy() != null )
+            {
+                msg.append( ", proxy=" + remoteRepository.getProxy().getHost() );
+            }
+            getProject().log( msg.toString(), Project.MSG_VERBOSE );
+
+            list.add( createRemoteArtifactRepository( remoteRepository ) );
         }
         return list;
     }
@@ -353,5 +379,29 @@
         this.type = type;
     }
 
+    private void showVersion()
+    {
+        InputStream resourceAsStream;
+        try
+        {
+            Properties properties = new Properties();
+            resourceAsStream = DependenciesTask.class.getClassLoader().getResourceAsStream(
+                "META-INF/maven/org.apache.maven/maven-ant-tasks/pom.properties" );
+            properties.load( resourceAsStream );
 
+            if ( properties.getProperty( "builtOn" ) != null )
+            {
+                log( "Maven Ant Tasks version: " + properties.getProperty( "version", "unknown" ) + " built on "
+                                + properties.getProperty( "builtOn" ), Project.MSG_VERBOSE );
+            }
+            else
+            {
+                log( "Maven Ant Tasks version: " + properties.getProperty( "version", "unknown" ), Project.MSG_VERBOSE );
+            }
+        }
+        catch ( IOException e )
+        {
+            log( "Unable determine version from Maven Ant Tasks JAR file: " + e.getMessage(), Project.MSG_WARN );
+        }
+    }
 }