Java Code Examples for org.sonatype.aether.artifact.Artifact#getFile()
The following examples show how to use
org.sonatype.aether.artifact.Artifact#getFile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PluginDiscovery.java From presto with Apache License 2.0 | 6 votes |
public static Set<String> discoverPlugins(Artifact artifact, ClassLoader classLoader) throws IOException { if (!artifact.getExtension().equals("presto-plugin")) { throw new RuntimeException("Unexpected extension for main artifact: " + artifact); } File file = artifact.getFile(); if (!file.getPath().endsWith("/target/classes")) { throw new RuntimeException("Unexpected file for main artifact: " + file); } if (!file.isDirectory()) { throw new RuntimeException("Main artifact file is not a directory: " + file); } if (new File(file, SERVICES_FILE).exists()) { throw new RuntimeException("Unexpected services file in artifact directory: " + file); } return listClasses(file.toPath()).stream() .filter(name -> classInterfaces(name, classLoader).contains(Plugin.class.getName())) .collect(toImmutableSet()); }
Example 2
Source File: PluginManager.java From presto with Apache License 2.0 | 5 votes |
private PluginClassLoader createClassLoader(List<Artifact> artifacts, String name) throws IOException { log.debug("Classpath for %s:", name); List<URL> urls = new ArrayList<>(); for (Artifact artifact : sortedArtifacts(artifacts)) { if (artifact.getFile() == null) { throw new RuntimeException("Could not resolve artifact: " + artifact); } File file = artifact.getFile().getCanonicalFile(); log.debug(" %s", file); urls.add(file.toURI().toURL()); } return createClassLoader(urls); }
Example 3
Source File: MavenJarUtil.java From alchemy with Apache License 2.0 | 5 votes |
public MavenLoaderInfo forGAV(String gav) { try { CollectRequest e = this.createCollectRequestForGAV(gav); List artifacts = this.collectDependenciesIntoArtifacts(e); LinkedList urls = Lists.newLinkedList(); String[] gavs = gav.split(":"); String jarName = gavs[1] + "-" + gavs[2]; File targetFile = null; Iterator urlClassLoader = artifacts.iterator(); while (urlClassLoader.hasNext()) { Artifact artifact = (Artifact)urlClassLoader.next(); File file = artifact.getFile(); urls.add(file.toURI().toURL()); if (file.getName().contains(jarName)) { targetFile = file; } } URLClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<URLClassLoader>() { @Override public URLClassLoader run() { return new URLClassLoader((URL[])urls.toArray(new URL[urls.size()]), SHARE_NOTHING); } }); return new MavenLoaderInfo(classLoader, targetFile); } catch (Exception var11) { throw Throwables.propagate(var11); } }