1 6 package fr.jayasoft.ivy.report; 7 8 import java.io.File ; 9 import java.util.Arrays ; 10 import java.util.Collection ; 11 12 import fr.jayasoft.ivy.IvyNode; 13 import fr.jayasoft.ivy.util.Message; 14 15 19 public class LogReportOutputter implements ReportOutputter { 20 21 public String getName() { 22 return CONSOLE; 23 } 24 25 public void output(ResolveReport report, File destDir) { 26 IvyNode[] evicted = report.getEvictedNodes(); 27 if (evicted.length > 0) { 28 Message.info("\t:: evicted modules:"); 29 for (int i = 0; i < evicted.length; i++) { 30 Collection allEvictingNodes = evicted[i].getAllEvictingNodes(); 31 if (allEvictingNodes == null) { 32 Message.info("\t"+evicted[i]+" transitively in "+Arrays.asList(evicted[i].getEvictedConfs())); 33 } else if (allEvictingNodes.isEmpty()) { 34 Message.info("\t"+evicted[i]+" by [] ("+evicted[i].getAllEvictingConflictManagers()+") in "+Arrays.asList(evicted[i].getEvictedConfs())); 35 } else { 36 Message.info("\t"+evicted[i]+" by "+allEvictingNodes+" in "+Arrays.asList(evicted[i].getEvictedConfs())); 37 } 38 String [] confs = evicted[i].getEvictedConfs(); 39 for (int j = 0; j < confs.length; j++) { 40 IvyNode.EvictionData evictedData = evicted[i].getEvictedData(confs[j]); 41 Message.verbose("\t in "+evictedData.getNode()+" with "+evictedData.getConflictManager()); 42 } 43 } 44 } 45 46 char[] sep = new char[69]; 47 Arrays.fill(sep, '-'); 48 Message.rawinfo("\t"+new String (sep)); 49 StringBuffer line = new StringBuffer ("\t"); 50 append(line, "", 18); 51 append(line, "modules", 31); 52 line.append("|"); 53 append(line, "artifacts", 15); 54 line.append("|"); 55 Message.rawinfo(line.toString()); 56 57 line = new StringBuffer ("\t"); 58 append(line, "conf", 18); 59 append(line, "number", 7); 60 append(line, "search", 7); 61 append(line, "dwnlded", 7); 62 append(line, "evicted", 7); 63 line.append("|"); 64 append(line, "number", 7); 65 append(line, "dwnlded", 7); 66 line.append("|"); 67 Message.rawinfo(line.toString()); 68 Message.rawinfo("\t"+new String (sep)); 69 70 String [] confs = report.getConfigurations(); 71 for (int i = 0; i < confs.length; i++) { 72 output(report.getConfigurationReport(confs[i])); 73 } 74 Message.rawinfo("\t"+new String (sep)); 75 76 IvyNode[] unresolved = report.getUnresolvedDependencies(); 77 if (unresolved.length > 0) { 78 Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::"); 79 Message.warn("\t:: UNRESOLVED DEPENDENCIES ::"); 80 Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::"); 81 } 82 for (int i = 0; i < unresolved.length; i++) { 83 Message.warn("\t:: "+unresolved[i]+": "+unresolved[i].getProblem().getMessage()); 84 } 85 if (unresolved.length > 0) { 86 Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n"); 87 } 88 89 ArtifactDownloadReport[] errors = report.getFailedArtifactsReports(); 90 if (errors.length > 0) { 91 Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::"); 92 Message.warn("\t:: FAILED DOWNLOADS ::"); 93 Message.warn("\t:: ^ see resolution messages for details ^ ::"); 94 Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::"); 95 } 96 for (int i = 0; i < errors.length; i++) { 97 Message.warn("\t:: "+errors[i].getArtifact()); 98 } 99 if (errors.length > 0) { 100 Message.warn("\t::::::::::::::::::::::::::::::::::::::::::::::\n"); 101 } 102 } 103 104 public void output(ConfigurationResolveReport report) { 105 StringBuffer line = new StringBuffer ("\t"); 106 append(line, report.getConfiguration(), 18); 107 append(line, String.valueOf(report.getNodesNumber()), 7); 108 append(line, String.valueOf(report.getSearchedNodes().length), 7); 109 append(line, String.valueOf(report.getDownloadedNodes().length), 7); 110 append(line, String.valueOf(report.getEvictedNodes().length), 7); 111 line.append("|"); 112 append(line, String.valueOf(report.getArtifactsNumber()), 7); 113 append(line, String.valueOf(report.getDownloadedArtifactsReports().length), 7); 114 line.append("|"); 115 116 Message.rawinfo(line.toString()); 117 } 118 119 private void append(StringBuffer line, Object o, int limit) { 120 String v = String.valueOf(o); 121 if (v.length() >= limit) { 122 v = v.substring(0, limit); 123 } else { 124 int missing = limit - v.length(); 125 int half = missing / 2; 126 char[] c = new char[limit]; 127 Arrays.fill(c, ' '); 128 System.arraycopy(v.toCharArray(), 0, c, missing - half, v.length()); 129 v = new String (c); 130 } 131 line.append("|"); 132 line.append(v); 133 } 134 135 } 136 | Popular Tags |