public void nameClassLoader(Artifact artifactId, ClassLoader loader, boolean recursive) { DependentLoaderImplementation theLoader = null; theLoader = new DependentLoaderImplementation(artifactId, loader, exposed, parentLoader); if (artifactId != null) { assert (theLoader != null); setLoader(theLoader); assert (loaderMap.get(toString(artifactId)) != null); } if (recursive) { OutputBouble bouble = OutputBouble.push(); try { List<Artifact> dependencies = dependencyManager.getDirectDependencies(artifactId); for (Artifact dependency : dependencies) { if (!loaderMap.containsKey(toString(dependency))) { nameClassLoader(dependency, theLoader, recursive); } } } catch (Exception e) { OutputBouble.reportError(e); } finally { bouble.pop(); if (bouble.isError) bouble.writeToParent(); } } visitLoader(theLoader); }
public void copy(String fromRepo, String toRepo, String filter, String[] flags) throws ArtifactResolutionException { Boolean includeConfigDependencies = false; for (String flag : flags) { if ("-includeconfig".equals(flag)) includeConfigDependencies = true; } dependencyManager.copy(fromRepo, toRepo, filter, includeConfigDependencies); }
public File getAsFile(Artifact artifactId) { File overrideFile = findOverrideFile(artifactId); if (overrideFile != null && overrideFile.exists()) return overrideFile; Result<File> localFileName = dependencyManager.getLocalFile(artifactId); if (localFileName.success()) return localFileName.val; return null; }
public void getJar(Artifact artifactId) { OutputBouble bouble = OutputBouble.push(); // Fetch jar and dependencies. try { Result<File> localFileName = dependencyManager.getLocalFile(artifactId); List<Artifact> dependencies = dependencyManager.getDirectDependencies(artifactId); int i = 0; for (Artifact dependencyId : dependencies) { if (!loaderMap.containsKey(toString(dependencyId))) { getJar(dependencyId); } } } catch (Exception e) { OutputBouble.reportError(e); } finally { bouble.pop(); if (bouble.isError) bouble.writeToParent(); } }
public void downloadFlat(String artifact, String copyToDir) { OutputBouble bouble = OutputBouble.push(); try { Artifact theArtifact = new DefaultArtifact(artifact); HashSet<Artifact> downloadThese = new HashSet<Artifact>(); downloadThese.add(theArtifact); Stack<Artifact> downloadDependenciesOfThese = new Stack<Artifact>(); downloadDependenciesOfThese.add(theArtifact); while (!downloadDependenciesOfThese.isEmpty()) { Artifact getDependenciesOfThis = downloadDependenciesOfThese.pop(); List<Artifact> dependencies = dependencyManager.getDirectDependencies(getDependenciesOfThis); for (Artifact a : dependencies) { if (!downloadThese.contains(a)) { downloadThese.add(a); downloadDependenciesOfThese.add(a); } } } File destination = new File(copyToDir); destination.mkdirs(); for (Artifact a : downloadThese) { File theFile = getAsFile(a); Files.copy(theFile.toPath(), new File(destination, theFile.getName()).toPath()); } } catch (Exception e) { OutputBouble.reportError(e); } finally { bouble.pop(); if (bouble.isError) bouble.writeToParent(); } }
public String[] listArtifacts(String repository) { return dependencyManager.listArtifacts(repository); }
public String[] listRepositories() { return dependencyManager.listRepositories(); }
public DependentLoaderImplementation enshureJarLoaded(Artifact _artifactId) { Artifact artifactId = unify(_artifactId); if ("dependent".equals(artifactId.getArtifactId()) && "no.dbwatch".equals(artifactId.getGroupId())) { return null; } DependentLoaderImplementation theLoader = findOverride(artifactId); if (theLoader != null) { visitLoader(theLoader); return theLoader; } if (loaderMap.containsKey(toString(artifactId))) return loaderMap.get(toString(artifactId)); // Fetch jar and dependencies. OutputBouble bouble = OutputBouble.push(); try { Result<File> localFileName = dependencyManager.getLocalFile(artifactId); if (localFileName.success()) theLoader = new DependentLoaderImplementation( artifactId, localFileName.val.getAbsoluteFile().toURI().toURL(), exposed, parentLoader); else theLoader = new DependentLoaderImplementation(artifactId, exposed, parentLoader); setLoader(theLoader); List<Artifact> dependencies = dependencyManager.getDirectDependencies(artifactId); DependentLoaderImplementation[] actualDependencies = new DependentLoaderImplementation[dependencies.size() + theLoader.dependencies.length]; int i = 0; for (DependentLoaderImplementation dependencyFromConf : theLoader.dependencies) { actualDependencies[i++] = dependencyFromConf; } for (Artifact dependencyId : dependencies) { DependentLoaderImplementation loader = enshureDependencyJarLoaded(artifactId, dependencyId); if (loader == null) { OutputBouble.logFile.println(artifactId.toString() + ":"); OutputBouble.logFile.println("\t Missing dependency " + dependencyId.toString()); OutputBouble.logFile.println("\t Ignoring"); } else { actualDependencies[i++] = loader; } } if (actualDependencies.length > i) { actualDependencies = Arrays.copyOf(actualDependencies, i); } theLoader.setDependencies(actualDependencies); extraDependencies.loaderAdded(theLoader); visitLoader(theLoader); return theLoader; } catch (Exception e) { OutputBouble.reportError(e); return theLoader; } finally { bouble.pop(); if (bouble.isError) bouble.writeToParent(); } // return null; }