/** * 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 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)) ) ); }
final File artifact = MavenResolvers.get().resolveJarArtifact(each.mscCoordinates()); archives.add(ShrinkWrap.create(ZipImporter.class, artifact.getName()) .importFrom(artifact)
File artifactFile = MavenResolvers.get().resolveJarArtifact(coords); if (artifactFile == null) { throw new RuntimeException("Unable to resolve artifact from coordinates: " + coords);
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)) ) ); }
final File artifact = MavenResolvers.get().resolveJarArtifact(coords); if (artifact == null) { LOGGER.error("Unable to resolve artifact: " + coords);
continue; final File artifact = MavenResolvers.get().resolveJarArtifact(each.mscCoordinates()); archives.put(artifact.getName(), ShrinkWrap.create(ZipImporter.class, artifact.getName()) .importFrom(artifact)
protected void addDependencies(ModuleSpec.Builder builder, ApplicationEnvironment env) { env.getDependencies() .forEach((dep) -> { String[] parts = dep.split(":"); ArtifactCoordinates coords = null; if (!parts[2].equals("jar")) { return; } if (parts.length == 4) { coords = new ArtifactCoordinates(parts[0], parts[1], parts[3]); } else if (parts.length == 5) { coords = new ArtifactCoordinates(parts[0], parts[1], parts[4], parts[3]); } try { File artifact = MavenResolvers.get().resolveJarArtifact(coords); if (artifact == null) { LOG.error("Unable to find artifact for " + coords); return; } JarFile jar = JarFileManager.INSTANCE.addJarFile(artifact); builder.addResourceRoot( ResourceLoaderSpec.createResourceLoaderSpec( ResourceLoaders.createJarResourceLoader(artifact.getName(), jar) ) ); } catch (IOException e) { throw new RuntimeException(e); } }); }
.forEach((coords) -> { try { File artifact = MavenResolvers.get().resolveJarArtifact(coords); if (artifact == null) { throw new RuntimeException("Unable to resolve artifact from coordinates: " + coords);
try { coordinates = ArtifactCoordinates.fromString(name); final File file = mavenResolver.resolveJarArtifact(coordinates); resourceLoader = factory.createResourceLoader("", file.getPath(), name); } catch (IOException | IllegalArgumentException e) {