Changeset 4150

Show
Ignore:
Timestamp:
01/07/08 04:33:38 (5 years ago)
Author:
t_yano
Message:

fix some bugs related to eternal looping for resolving dependencies.

Location:
lang/java/mvnbeans/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/java/mvnbeans/trunk

    • Property svn:ignore set to
      target
  • lang/java/mvnbeans/trunk/pom.xml

    r3199 r4150  
    2727                    <source>1.5</source> 
    2828                    <target>1.5</target> 
     29                    <encoding>UTF-8</encoding> 
     30                </configuration> 
     31            </plugin> 
     32            <plugin> 
     33                <artifactId>maven-resources-plugin</artifactId> 
     34                <version>RELEASE</version> 
     35                <configuration> 
     36                    <encoding>UTF-8</encoding> 
    2937                </configuration> 
    3038            </plugin> 
  • lang/java/mvnbeans/trunk/src/main/java/jp/javelindev/mvnbeans/App.java

    r3199 r4150  
    77import java.io.InputStream; 
    88import java.nio.channels.Channels; 
     9import java.util.ArrayList; 
    910import java.util.EnumSet; 
     11import java.util.HashSet; 
    1012import java.util.List; 
     13import java.util.Set; 
    1114import java.util.logging.Level; 
    1215import java.util.logging.Logger; 
     
    105108        switch(cmd) { 
    106109            case FETCH: 
    107                 fetchAllArtifact(artifact, 0); 
     110                fetchAllArtifact(artifact, 0, null); 
    108111                break; 
    109112            case SEARCH: 
     
    136139    } 
    137140     
    138     static void fetchAllArtifact(Artifact artifact, int count) throws RepositoryIOException, IOException { 
     141    static void fetchAllArtifact(Artifact artifact, int count, Set<Artifact> reserved) throws RepositoryIOException, IOException { 
     142        Set<Artifact> reservedArtifacts = null; 
     143        if(reserved == null) { 
     144            reservedArtifacts = new HashSet<Artifact>(); 
     145        } else { 
     146            reservedArtifacts = reserved; 
     147        } 
     148         
    139149        String fileName = artifact.getArtifactId() + "-" + artifact.getVersion() + ".jar"; 
    140150        File artifactFile = new File(fileName); 
     
    143153            if(artifactFile.exists()) { 
    144154                System.out.println(repeatString("--", count) + "> " + fileName + "...already exists."); 
     155            } else if(reservedArtifacts.contains(artifact)) { 
     156                //the artifact is already reserved for downloading. 
     157                System.out.println(repeatString("--", count) + "> " + fileName + "...is already reserved for downloading."); 
    145158            } else { 
    146159                 
     
    150163                if(deps.size() > 0) { 
    151164                    System.out.println(repeatString("--", count) + "> processing " + fileName + "(" + artifact.getFileURL() + ")..."); 
     165                     
     166                    //the artifact has some dependencies, so we can not download the artifact just now  
     167                    //and need to wait until the end of downloading of all the dependencies. 
     168                    //the artifact will be download after downloading the dependencies, 
     169                    //we hold the instance into our reminder cache. 
     170                    reservedArtifacts.add(artifact); 
    152171                } else { 
    153172                    System.out.print(repeatString("--", count) + "> processing " + fileName + "(" + artifact.getFileURL() + ")..."); 
     
    156175                //download all the dependencies. 
    157176                for (Artifact dependency : artifact.getDependencies()) { 
    158                     fetchAllArtifact(dependency, count + 1); 
     177                    fetchAllArtifact(dependency, count + 1, reserved); 
    159178                }       
    160179                 
     
    183202                if(deps.size() > 0) { 
    184203                    System.out.println(repeatString("--", count) + "> end."); 
     204                     
     205                    //finally we have download the artifact. 
     206                    //remove the instance from our reminder cache. 
     207                    reservedArtifacts.remove(artifact); 
    185208                } else { 
    186209                    System.out.println("end.");