Changeset 6249
- Timestamp:
- 02/05/08 22:29:51 (5 years ago)
- Location:
- lang/java/mvnbeans/trunk
- Files:
-
- 1 added
- 4 modified
-
. (modified) (1 prop)
-
src/main/java/jp/javelindev/mvnbeans/App.java (modified) (7 diffs)
-
src/main/java/jp/javelindev/mvnbeans/App2.java (added)
-
src/main/java/jp/javelindev/mvnbeans/Artifact.java (modified) (3 diffs)
-
src/main/java/jp/javelindev/mvnbeans/RepositoryManager.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/java/mvnbeans/trunk
- Property svn:ignore
-
old new 1 1 target 2 3 .*
-
- Property svn:ignore
-
lang/java/mvnbeans/trunk/src/main/java/jp/javelindev/mvnbeans/App.java
r4150 r6249 7 7 import java.io.InputStream; 8 8 import java.nio.channels.Channels; 9 import java.util.ArrayList;10 9 import java.util.EnumSet; 11 10 import java.util.HashSet; … … 14 13 import java.util.logging.Level; 15 14 import java.util.logging.Logger; 15 16 16 import org.apache.commons.cli.CommandLine; 17 17 import org.apache.commons.cli.CommandLineParser; … … 26 26 * 27 27 */ 28 public class App 28 public class App 29 29 { 30 30 enum Command { 31 FETCH("fetch"), 32 SEARCH("search"), 33 INFO("info"), 31 FETCH("fetch"), 32 SEARCH("search"), 33 INFO("info"), 34 34 DEPS("showdeps"); 35 35 … … 43 43 EnumSet<Command> enumSet = EnumSet.allOf(Command.class); 44 44 for (App.Command command : enumSet) { 45 if(command.commandName.equals(cmdName)) return command; 45 if(command.commandName.equals(cmdName)) { 46 return command; 47 } 46 48 } 47 49 return null; … … 130 132 131 133 static String repeatString(final String original, final int count) { 132 if(original == null) return ""; 133 if(count <= 0) return ""; 134 if(original == null) { 135 return ""; 136 } 137 if(count <= 0) { 138 return ""; 139 } 134 140 StringBuilder sb = new StringBuilder(original.length()*count); 135 141 for(int i = 0; i < count; i++) { … … 164 170 System.out.println(repeatString("--", count) + "> processing " + fileName + "(" + artifact.getFileURL() + ")..."); 165 171 166 //the artifact has some dependencies, so we can not download the artifact just now 172 //the artifact has some dependencies, so we can not download the artifact just now 167 173 //and need to wait until the end of downloading of all the dependencies. 168 174 //the artifact will be download after downloading the dependencies, … … 176 182 for (Artifact dependency : artifact.getDependencies()) { 177 183 fetchAllArtifact(dependency, count + 1, reserved); 178 } 184 } 179 185 180 186 InputStream input = null; -
lang/java/mvnbeans/trunk/src/main/java/jp/javelindev/mvnbeans/Artifact.java
r3199 r6249 25 25 import java.util.ArrayList; 26 26 import java.util.List; 27 import java.util.logging.Level; 28 import java.util.logging.Logger; 27 29 28 import org.apache.commons.io.IOUtils; 30 29 import org.apache.commons.vfs.FileObject; … … 42 41 */ 43 42 class Artifact { 44 enum ResourceType { 43 enum ResourceType { 45 44 POM(".pom"), JAR(".jar"); 46 45 … … 88 87 if(depScope == null || !depScope.equalsIgnoreCase("test")) { 89 88 Artifact dep = new Artifact(depGroupId, depArtifactId, depVersion, this.repositories); 90 artifactList.add(dep); 89 artifactList.add(dep); 91 90 } 92 91 } -
lang/java/mvnbeans/trunk/src/main/java/jp/javelindev/mvnbeans/RepositoryManager.java
r3199 r6249 26 26 import java.util.List; 27 27 import java.util.Properties; 28 28 29 import org.apache.commons.io.IOUtils; 29 30 … … 37 38 38 39 void initialize(boolean useLocalRepository) throws FileNotFoundException, IOException, EnvVarNotFoundException { 39 String beansHome = System.getenv("MVNBEANS_HOME"); 40 if(beansHome == null) { 41 throw new EnvVarNotFoundException("MVNBEANS_HOME"); 42 } 43 44 if(!beansHome.endsWith("/")) { 45 beansHome = beansHome + "/"; 46 } 47 48 File propFile = new File(beansHome + "repositories.properties"); 49 if(!propFile.exists()) { 50 throw new FileNotFoundException("Can not find '" + beansHome + "repositories.properties'"); 51 } 52 if(!propFile.canRead()) { 53 throw new IllegalStateException("the file " + beansHome + "repositories.properties is not readable."); 54 } 55 56 Properties prop = new Properties(); 57 FileInputStream fis = null; 58 try { 59 fis = new FileInputStream(propFile); 60 prop.load(fis); 61 } finally { 62 IOUtils.closeQuietly(fis); 63 } 64 40 String beansHome = System.getenv("MVNBEANS_HOME"); 41 if(beansHome == null) { 42 throw new EnvVarNotFoundException("MVNBEANS_HOME"); 43 } 44 45 if(!beansHome.endsWith("/")) { 46 beansHome = beansHome + "/"; 47 } 48 49 File propFile = new File(beansHome + "repositories.properties"); 50 if(!propFile.exists()) { 51 throw new FileNotFoundException("Can not find '" + beansHome + "repositories.properties'"); 52 } 53 if(!propFile.canRead()) { 54 throw new IllegalStateException("the file " + beansHome + "repositories.properties is not readable."); 55 } 56 57 Properties prop = new Properties(); 58 FileInputStream fis = null; 59 try { 60 fis = new FileInputStream(propFile); 61 prop.load(fis); 62 } finally { 63 IOUtils.closeQuietly(fis); 64 } 65 66 initialize(useLocalRepository, prop); 67 } 68 69 void initialize(boolean useLocalRepository, Properties prop) { 65 70 if(useLocalRepository) { 66 71 String localRep = prop.getProperty("localrepository"); … … 91 96 } 92 97 98 public static RepositoryManager getInstance(boolean useLocalRepository, Properties prop) { 99 synchronized(RepositoryManager.class) { 100 if(INSTANCE == null) { 101 INSTANCE = new RepositoryManager(); 102 INSTANCE.initialize(useLocalRepository, prop); 103 } 104 return INSTANCE; 105 } 106 } 107 93 108 public Iterator<Repository> iterator() { 94 109 return new ArrayList<Repository>(this.repositories).iterator(); //diffensive copy
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)