public String[] getFiles(File base, String prefix) { if (!base.canRead() || !base.isDirectory()) { throw new IllegalArgumentException(base.getAbsolutePath()); } List list = new ArrayList(); File[] hits = base.listFiles(); for (int i = 0; i < hits.length; i++) { File hit = hits[i]; if (hit.canRead()) { if (hit.isDirectory()) { list.addAll(Arrays.asList(getFiles(hit, prefix.equals("") ? hit.getName() : prefix + "/" + hit.getName()))); } else { list.add(prefix.equals("") ? hit.getName() : prefix + "/" + hit.getName()); } } } return (String[]) list.toArray(new String[list.size()]); }
SortedSet set = list(); String targetGroup = query.getGroupId(); String targetArtifact = query.getArtifactId();
public SortedSet list() { SortedSet artifacts = new TreeSet(); String[] names = getFiles(rootFile, ""); Matcher matcher = MAVEN_1_PATTERN.matcher(""); for (int i = 0; i < names.length; i++) { matcher.reset(names[i]); if (matcher.matches()) { String groupId = matcher.group(1); String artifactId = matcher.group(3); String version = matcher.group(4); String type = matcher.group(2); if(groupId.indexOf('/') > -1 || artifactId.indexOf('/') > -1 || type.indexOf('/') > -1 || version.indexOf('/') > -1) { log.warn("could not resolve URI for malformed repository entry: " + names[i] + " - the filename should look like: <groupId>/<type>s/<artifactId>-<version>.<type> "+ "Perhaps you put in a file without a version number in the name?"); } else { artifacts.add(new Artifact(groupId, artifactId, version, type)); } } else { log.warn("could not resolve URI for malformed repository entry: " + names[i] + " - the filename should look like: <groupId>/<type>s/<artifactId>-<version>.<type> "+ "Perhaps you put in a file without a version number in the name?"); } } return artifacts; }