Author: dantran
Date: Wed Apr 26 21:56:58 2006
New Revision: 397395

URL: http://svn.apache.org/viewcvs?rev=397395&view=rev
Log:
Lookup missing version in populated dependency list prior to dependency 
management. MDEP-20

Modified:
    maven/plugins/trunk/maven-dependency-plugin/pom.xml
    
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java

Modified: maven/plugins/trunk/maven-dependency-plugin/pom.xml
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-dependency-plugin/pom.xml?rev=397395&r1=397394&r2=397395&view=diff
==============================================================================
--- maven/plugins/trunk/maven-dependency-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-dependency-plugin/pom.xml Wed Apr 26 21:56:58 2006
@@ -73,16 +73,17 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-utils</artifactId>
-      <version>[1.1,]</version>
+      <version>1.1</version>
     </dependency>
   </dependencies>
   <reporting>
     <plugins>
       <plugin>
-        <groupId>org.apache.mojo</groupId>
+        <groupId>org.codehaus.mojo</groupId>
         <artifactId>changes-maven-plugin</artifactId>
         <version>2.0-beta-1</version>
       </plugin>
     </plugins>
   </reporting>
+    
 </project>

Modified: 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
URL: 
http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java?rev=397395&r1=397394&r2=397395&view=diff
==============================================================================
--- 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
 (original)
+++ 
maven/plugins/trunk/maven-dependency-plugin/src/main/java/org/apache/maven/plugin/dependency/fromConfiguration/AbstractFromConfigurationMojo.java
 Wed Apr 26 21:56:58 2006
@@ -1,3 +1,4 @@
+
 /*
  *  Copyright 2005-2006 Brian Fox ([EMAIL PROTECTED])
  *
@@ -116,7 +117,7 @@
 
     /**
      * Resolves the Artifact from the remote repository if nessessary. If no 
version is specified, it will
-     * be retrieved from the DependencyManagement section of the pom.
+     * be retrieved from the dependency list or from the DependencyManagement 
section of the pom.
      *
      * @param artifactItem 
      *          containing information about artifact from plugin 
configuration.
@@ -133,12 +134,12 @@
 
         if ( artifactItem.getVersion() == null )
         {
-            fillArtifactVersionFromDependencyManagement( artifactItem );
+            fillMissingArtifactVersion( artifactItem );
 
             if ( artifactItem.getVersion() == null )
             {
                 throw new MojoExecutionException( "Unable to find artifact 
version of " + artifactItem.getGroupId()
-                    + ":" + artifactItem.getArtifactId() + " in project's 
dependency management." );
+                    + ":" + artifactItem.getArtifactId() + " in either 
dependency list or in project's dependency management." );
             }
 
         }
@@ -175,15 +176,15 @@
     }
 
     /**
-     * Tries to find missing version from dependancy management. If found, the 
artifact is updated with
-     * the correct version.
+     * Tries to find missing version from dependancy list and dependency 
management. 
+     * If found, the artifact is updated with the correct version.
      * @param artifact representing configured file.
      */
-    private void fillArtifactVersionFromDependencyManagement( ArtifactItem 
artifact )
+    private void fillMissingArtifactVersion( ArtifactItem artifact )
     {
-        this.getLog().debug( "Attempting to find missing version from 
dependency management." );
+        this.getLog().debug( "Attempting to find missing version in " + 
artifact.getGroupId() + ":" + artifact.getArtifactId() );
 
-        List list = this.project.getDependencyManagement().getDependencies();
+        List list = this.project.getDependencies();
 
         for ( int i = 0; i < list.size(); ++i )
         {
@@ -193,10 +194,29 @@
                 && dependency.getArtifactId().equals( artifact.getArtifactId() 
)
                 && dependency.getType().equals( artifact.getType() ) )
             {
-                this.getLog().debug( "Found missing version: " + 
dependency.getVersion() );
+                this.getLog().debug( "Found missing version: " + 
dependency.getVersion() + " in dependency list." );
+
+                artifact.setVersion( dependency.getVersion() );
+                
+                return;
+            }
+        }
+        
+        list = this.project.getDependencyManagement().getDependencies();
+
+        for ( int i = 0; i < list.size(); ++i )
+        {
+            Dependency dependency = (Dependency) list.get( i );
+
+            if ( dependency.getGroupId().equals( artifact.getGroupId() )
+                && dependency.getArtifactId().equals( artifact.getArtifactId() 
)
+                && dependency.getType().equals( artifact.getType() ) )
+            {
+                this.getLog().debug( "Found missing version: " + 
dependency.getVersion() + " in dependency management list" );
 
                 artifact.setVersion( dependency.getVersion() );
             }
         }
     }
 }
+


Reply via email to