@Override protected File download(Exception previousException) throws Exception { return resolver.resolve(url, previousException); }
private boolean canResolveAllFeatureUris(List<Repository> repositories) { for (Repository repository : repositories) { for (URI featureUri : repository.getFeatureUris()) { try { if (m_mavenResolver.resolve(featureUri.toString()) == null) { return false; } } catch (Exception e) { return false; } } } return true; }
private boolean canResolveAllFeatureUris(List<Repository> repositories) { for (Repository repository : repositories) { for (URI featureUri : repository.getFeatureUris()) { try { if (m_mavenResolver.resolve(featureUri.toString()) == null) { return false; } } catch (Exception e) { return false; } } } return true; }
@Override public File resolve(String groupId, String artifactId, String classifier, String extension, String version) throws IOException { File file = reactor.findArtifact(new DefaultArtifact(groupId, artifactId, classifier, extension, version)); return file == null ? fallback.resolve(String.format("mvn:%s/%s/%s/%s/%s", groupId, artifactId, version, extension, classifier)) : file; }
@Override public File resolve(String groupId, String artifactId, String classifier, String extension, String version) throws IOException { File file = reactor.findArtifact(new DefaultArtifact(groupId, artifactId, classifier, extension, version)); return file == null ? fallback.resolve(String.format("mvn:%s/%s/%s/%s/%s", groupId, artifactId, version, extension, classifier)) : file; }
@Override public File resolve(String groupId, String artifactId, String classifier, String extension, String version, Exception previousException) throws IOException { File file = reactor.findArtifact(new DefaultArtifact(groupId, artifactId, classifier, extension, version)); return file == null ? fallback.resolve(String.format("mvn:%s/%s/%s/%s/%s", groupId, artifactId, version, extension, classifier), previousException) : file; }
@Override public File resolve(String groupId, String artifactId, String classifier, String extension, String version, Exception previousException) throws IOException { File file = reactor.findArtifact(new DefaultArtifact(groupId, artifactId, classifier, extension, version)); return file == null ? fallback.resolve(String.format("mvn:%s/%s/%s/%s/%s", groupId, artifactId, version, extension, classifier), previousException) : file; }
private void unzipMvnArtifact(String aConfigtMvnUrlStr, String aConfigFolderPath) throws IOException { RuntimeUtil.registerMavenUrlHandler(); MavenResolver mavenResolver = MavenResolvers.createMavenResolver(null, ServiceConstants.PID); File artifactToUnzip = mavenResolver.resolve(aConfigtMvnUrlStr); try (ZipFile zipFile = new ZipFile(artifactToUnzip)) { try { Enumeration<? extends ZipEntry> entries = zipFile.entries(); while (entries.hasMoreElements()) { ZipEntry entry = entries.nextElement(); File entryDestination = new File(aConfigFolderPath, entry.getName()); if (entry.isDirectory()) { entryDestination.mkdirs(); } else { entryDestination.getParentFile().mkdirs(); InputStream in = zipFile.getInputStream(entry); OutputStream out = new FileOutputStream(entryDestination); IOUtils.copy(in, out); IOUtils.closeQuietly(in); out.close(); } } } finally { zipFile.close(); } } }
@Override public File resolve(String url) throws IOException { Artifact artifact = toArtifact(url); File file = reactor.findArtifact(artifact); return file == null ? fallback.resolve(url) : file; }
@Override public File resolve(String url, Exception previousException) throws IOException { Artifact artifact = toArtifact(url); File file = reactor.findArtifact(artifact); return file == null ? fallback.resolve(url, previousException) : file; }
@Override public File resolve(String url, Exception previousException) throws IOException { Artifact artifact = toArtifact(url); File file = reactor.findArtifact(artifact); return file == null ? fallback.resolve(url, previousException) : file; }
@Override public File resolve(String url) throws IOException { Artifact artifact = toArtifact(url); File file = reactor.findArtifact(artifact); return file == null ? fallback.resolve(url) : file; }
String version = getVersion(distribution, "RELEASE"); String[] dist = distribution.split(":"); File distFile = resolver.resolve(dist[0], dist[1], null, "zip", version); String resolvedVersion = distFile.getName().substring(dist[1].length() + 1, distFile.getName().length() - 4); String dir = distDir;
String version = getVersion(distribution, "RELEASE"); String[] dist = distribution.split(":"); File distFile = resolver.resolve(dist[0], dist[1], null, "zip", version); String resolvedVersion = distFile.getName().substring(dist[1].length() + 1, distFile.getName().length() - 4); String dir = distDir;
private static void createAndDeployArtifact() throws IOException { // create jar file File tempFile = File.createTempFile("comps-api-tests", ".jar"); try { // adds a dep.txt entry LOG.debug("created temp artifact jar" + tempFile.getAbsolutePath()); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(tempFile)); String depsEntryPath = "META-INF/maven/" + TEST_GROUPID + "/" + TEST_ARTEFACTID + "/dependencies.txt"; ZipEntry e = new ZipEntry(depsEntryPath); out.putNextEntry(e); InputStream depTxtStream = DependenciesReaderTest.class.getResourceAsStream("/" + depsEntryPath); byte[] data = IOUtils.toByteArray(depTxtStream); out.write(data, 0, data.length); out.closeEntry(); out.close(); // deploy it MavenResolver mavenResolver = MavenResolvers.createMavenResolver(null, "foo"); mavenResolver.upload(TEST_GROUPID, TEST_ARTEFACTID, "jar", "jar", TEST_VERSION, tempFile); tempMavenFilePath = mavenResolver.resolve(TEST_GROUPID, TEST_ARTEFACTID, "jar", "jar", TEST_VERSION) .getAbsolutePath(); LOG.debug("artifact deployed:" + tempMavenFilePath); } finally { // remove it tempFile.delete(); } }
/** * Test method for * {@link org.talend.components.api.component.runtime.DependenciesReader#extractDependenciesFromStream(org.talend.components.api.component.runtime.DependenciesReader, java.lang.String, java.util.jar.JarInputStream)} * . * * @throws IOException * @throws MalformedURLException */ @Ignore("we can't use components-api-full-example here because it brings cyclic dependency. Should be fixed by using another test module") @Test public void testExtracDependencyFromStream() throws MalformedURLException, IOException { MavenResolver mavenResolver = MavenResolvers.createMavenResolver(null, "foo"); File jarWithDeps = mavenResolver.resolve("mvn:org.talend.components/components-api-full-example/0.1.0"); try (JarInputStream jis = new JarInputStream(new FileInputStream(jarWithDeps))) { List<URL> dependencyFromStream = DependenciesReader.extractDependencies(new DependenciesReader(null), DependenciesReader.computeDependenciesFilePath("org.talend.components", "components-full-example"), jis); checkFullExampleDependencies(dependencyFromStream); } }
final File resolvedLocation = resolver.resolve(info.getLocation()); if (copyFileToDirectory(resolvedLocation, dest)) { System.out.println("Exported '" + feature.getName() + "/" + feature.getVersion() + "' bundle: " + info.getLocation());
final File resolvedLocation = resolver.resolve(info.getLocation()); if (copyFileToDirectory(resolvedLocation, dest)) { System.out.println("Exported '" + feature.getName() + "/" + feature.getVersion() + "' bundle: " + info.getLocation());
/** * Test method for {@link org.talend.components.api.component.runtime.JarRuntimeInfo#getMavenUrlDependencies()}. * * @throws IOException */ @Ignore("we can't use components-api-full-example here because it brings cyclic dependency. Should be fixed by using another test module") @Test public void testGetMavenUrlDependencies() throws IOException { MavenResolver mavenResolver = MavenResolvers.createMavenResolver(null, "foo"); File jarWithDeps = mavenResolver.resolve("mvn:org.talend.components/components-api-full-example/0.1.0"); // the artifact id used to compute the file path is different from the actual artifact ID. // I don't know why but this does not matter. JarRuntimeInfo jarRuntimeInfo = new JarRuntimeInfo(jarWithDeps.toURI().toURL(), DependenciesReader.computeDependenciesFilePath("org.talend.components", "components-full-example"), null); List<URL> mavenUrlDependencies = jarRuntimeInfo.getMavenUrlDependencies(); checkFullExampleDependencies(mavenUrlDependencies); }