/** * Try to resolve a Maven JAR artifact. Calling this method is identical to calling * {@code resolveJarArtifact(qualifier, "jar")}. * * @param coordinates the non-{@code null} Maven coordinates object * @return the absolute path to the artifact, or {@code null} if none exists * @throws IOException if acquiring the artifact path failed for some reason */ default File resolveJarArtifact(final ArtifactCoordinates coordinates) throws IOException { return resolveArtifact(coordinates, "jar"); }
/** * A utility method to create a Maven artifact resource loader for the given artifact name. * * @param name the artifact name * @return the resource loader * @throws IOException if the artifact could not be resolved */ public static ResourceLoader createMavenArtifactLoader(final String name) throws IOException { return createMavenArtifactLoader(MavenResolver.createDefaultResolver(), name); }
/** * A utility method to create a Maven artifact resource loader for the given artifact coordinates. * * @param name the resource root name to use (must not be {@code null}) * @param coordinates the artifact coordinates to use (must not be {@code null}) * @param mavenResolver the Maven resolver to use (must not be {@code null}) * @return the resource loader * @throws IOException if the artifact could not be resolved */ public static ResourceLoader createMavenArtifactLoader(final MavenResolver mavenResolver, final ArtifactCoordinates coordinates, final String rootName) throws IOException { File fp = mavenResolver.resolveJarArtifact(coordinates); if (fp == null) return null; JarFile jarFile = JDKSpecific.getJarFile(fp, true); return ResourceLoaders.createJarResourceLoader(rootName, jarFile); }
/** * A utility method to create a Maven artifact resource loader for the given artifact coordinates. * * @param mavenResolver the Maven resolver to use (must not be {@code null}) * @param coordinates the artifact coordinates to use (must not be {@code null}) * @param rootName the resource root name to use (must not be {@code null}) * @return the resource loader * @throws IOException if the artifact could not be resolved */ public static ResourceLoader createMavenArtifactLoader(final MavenResolver mavenResolver, final ArtifactCoordinates coordinates, final String rootName) throws IOException { File fp = mavenResolver.resolveJarArtifact(coordinates); if (fp == null) return null; JarFile jarFile = JDKSpecific.getJarFile(fp, true); return ResourceLoaders.createJarResourceLoader(rootName, jarFile); }
private static void createMavenNativeArtifactLoader(final MavenResolver mavenResolver, final String name, final XmlPullParser reader, final ModuleSpec.Builder specBuilder) throws IOException, XmlPullParserException { File fp = mavenResolver.resolveJarArtifact(ArtifactCoordinates.fromString(name)); if (fp == null) throw new XmlPullParserException(String.format("Failed to resolve native artifact '%s'", name), reader, null); File lib = new File(fp.getParentFile(), "lib"); if (!lib.exists()) { if (!fp.getParentFile().canWrite()) throw new XmlPullParserException(String.format("Native artifact '%s' cannot be unpacked", name), reader, null); unzip(fp, fp.getParentFile()); } specBuilder.addResourceRoot(ResourceLoaderSpec.createResourceLoaderSpec(new NativeLibraryResourceLoader(lib), PathFilters.rejectAll())); }
@Override public File resolveArtifact(ArtifactCoordinates coordinates, String packaging) throws IOException { for (MavenResolver resolver : this.resolvers) { File result = resolver.resolveArtifact(coordinates, packaging); if (result != null) { return result; } } return null; } }
/** * A utility method to create a Maven artifact resource loader for the given artifact name. * * @param name the artifact name * @return the resource loader * @throws IOException if the artifact could not be resolved */ public static ResourceLoader createMavenArtifactLoader(final String name) throws IOException { return createMavenArtifactLoader(MavenResolver.createDefaultResolver(), name); }
@Override void apply(ModuleSpec.Builder builder) throws IOException { File artifact = MavenResolvers.get().resolveJarArtifact(this.descriptor.mscCoordinates()); if (artifact == null) { throw new IOException("Unable to locate artifact: " + this.descriptor.mscGav()); } builder.addResourceRoot( ResourceLoaderSpec.createResourceLoaderSpec( ResourceLoaders.createJarResourceLoader(artifact.getName(), new JarFile(artifact)) ) ); }
@Override public File resolveArtifact(ArtifactCoordinates coordinates, String packaging) throws IOException { try (AutoCloseable handle = Performance.accumulate("artifact-resolver")) { for (MavenResolver resolver : this.resolvers) { File result = resolver.resolveArtifact(coordinates, packaging); if (result != null) { return result; } } return null; } catch (Exception e) { throw new RuntimeException(e); } }
/** * Parse a {@code module.xml} file. * * @param factory the resource root factory to use (must not be {@code null}) * @param rootPath the root path to send in to the resource root factory (must not be {@code null}) * @param source a stream of the {@code module.xml} content (must not be {@code null}) * @param moduleInfoFile the {@code File} of the {@code module.xml} content (must not be {@code null}) * @param moduleLoader the module loader to use for dependency specifications (must not be {@code null}) * @param moduleName the module name of the module to load * @return a module specification * @throws ModuleLoadException if a dependency could not be established or another error occurs * @throws IOException if I/O fails */ public static ModuleSpec parseModuleXml(final ResourceRootFactory factory, final String rootPath, InputStream source, final String moduleInfoFile, final ModuleLoader moduleLoader, final String moduleName) throws ModuleLoadException, IOException { return parseModuleXml(factory, MavenResolver.createDefaultResolver(), rootPath, source, moduleInfoFile, moduleLoader, moduleName); }
final File artifact = MavenResolvers.get().resolveJarArtifact(each.mscCoordinates()); archives.add(ShrinkWrap.create(ZipImporter.class, artifact.getName()) .importFrom(artifact)
return MavenResolvers.get().resolveArtifact( new ArtifactCoordinates( groupId,
/** * Parse a {@code module.xml} file. * * @param factory the resource root factory to use (must not be {@code null}) * @param rootPath the root path to send in to the resource root factory (must not be {@code null}) * @param source a stream of the {@code module.xml} content (must not be {@code null}) * @param moduleInfoFile the {@code File} of the {@code module.xml} content (must not be {@code null}) * @param moduleLoader the module loader to use for dependency specifications (must not be {@code null}) * @param moduleIdentifier the module identifier of the module to load * @return a module specification * @throws ModuleLoadException if a dependency could not be established or another error occurs * @throws IOException if I/O fails * @deprecated Use {@link #parseModuleXml(ResourceRootFactory, String, InputStream, String, ModuleLoader, String)} instead. */ @Deprecated public static ModuleSpec parseModuleXml(final ResourceRootFactory factory, final String rootPath, InputStream source, final String moduleInfoFile, final ModuleLoader moduleLoader, final ModuleIdentifier moduleIdentifier) throws ModuleLoadException, IOException { return parseModuleXml(factory, MavenResolver.createDefaultResolver(), rootPath, source, moduleInfoFile, moduleLoader, moduleIdentifier); }
File artifactFile = MavenResolvers.get().resolveJarArtifact(coords); if (artifactFile == null) { throw new RuntimeException("Unable to resolve artifact from coordinates: " + coords);
return MavenResolvers.get().resolveArtifact( new ArtifactCoordinates( groupId,
void apply(ModuleSpec.Builder builder, MavenArtifactDescriptor entry) throws IOException { File artifact = MavenResolvers.get().resolveJarArtifact(entry.mscCoordinates()); if (artifact == null) { throw new IOException("Unable to locate artifact: " + entry.mscGav()); } if (LOG.isTraceEnabled()) { LOG.trace("adding bootstrap artifact: " + artifact.getAbsolutePath()); } builder.addResourceRoot( ResourceLoaderSpec.createResourceLoaderSpec( ResourceLoaders.createJarResourceLoader(artifact.getName(), new JarFile(artifact)) ) ); }
classifier == null ? "" : classifier); return MavenResolvers.get().resolveArtifact(coords, packaging);
final File artifact = MavenResolvers.get().resolveJarArtifact(coords); if (artifact == null) { LOGGER.error("Unable to resolve artifact: " + coords);
classifier == null ? "" : classifier); return MavenResolvers.get().resolveArtifact(coords, packaging);
continue; final File artifact = MavenResolvers.get().resolveJarArtifact(each.mscCoordinates()); archives.put(artifact.getName(), ShrinkWrap.create(ZipImporter.class, artifact.getName()) .importFrom(artifact)