use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method downloadZipped.
private ArtifactResult downloadZipped(Node node, ArtifactContext context) {
ArtifactContext zippedContext = context.getZipContext();
ArtifactResult zipResult = getArtifactResult(zippedContext);
if (zipResult != null) {
String zipName = zipResult.artifact().getName();
File unzippedFolder = new File(zipResult.artifact().getParentFile(), zipName.substring(0, zipName.length() - 4));
try {
IOUtils.extractArchive(zipResult.artifact(), unzippedFolder);
} catch (IOException e) {
throw new RepositoryException("Failed to unzip folder downloaded from Herd: " + zipResult.artifact(), e);
}
return new FileArtifactResult(zipResult.repository(), this, zipResult.name(), zipResult.version(), unzippedFolder, zipResult.repositoryDisplayString());
} else {
return null;
}
}
use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method getArtifactResult.
public ArtifactResult getArtifactResult(ArtifactContext context) throws RepositoryException {
context = applyOverrides(context);
final Node node = getLeafNode(context);
if (node != null) {
String foundSuffix = ArtifactContext.getSuffixFromNode(node);
// First handle all the artifact we didn't find
ArtifactResult result = handleNotFound(context, foundSuffix);
if (result != null) {
// Seems we were able to find this artifact anyway, so lets return it
return result;
} else {
// Now return the artifact we found
// Make sure we'll have only one suffix
context.setSuffixes(foundSuffix);
if (ArtifactContext.isDirectoryName(node.getLabel())) {
return getFolder(context, node);
} else {
return getArtifactResult(context, node);
}
}
} else {
return handleNotFound(context, null);
}
}
use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class AbstractNodeRepositoryManager method handleNotFound.
private ArtifactResult handleNotFound(ArtifactContext context, String foundSuffix) {
String[] suffixes = context.getSuffixes();
for (String suffix : suffixes) {
if (suffix.equals(foundSuffix)) {
break;
}
// Make sure we'll have only one suffix
context.setSuffixes(suffix);
ArtifactResult result = artifactNotFound(context);
if (result != null) {
// Seems we were able to find this artifact anyway, so lets return it
return result;
}
}
// Restore the original suffixes
context.setSuffixes(suffixes);
return null;
}
use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class BytecodeUtils method resolve.
@Override
public ModuleInfo resolve(DependencyContext context, Overrides overrides) {
if (context.ignoreInner()) {
return null;
}
ArtifactResult result = context.result();
File mod = result.artifact();
if (mod != null && IOUtils.isZipFile(mod)) {
return readModuleInformation(result.name(), result.artifact(), overrides);
} else {
return null;
}
}
use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.
the class LegacyImporter method addTransitiveDependenciesClasses.
private void addTransitiveDependenciesClasses(ArtifactResult result, Set<String> classes, Set<String> visited, ModuleDependencyInfo originalDependency) throws Exception {
log.info("Visiting transitive dependencies for " + result.name() + "/" + result.version());
try {
for (ArtifactResult dep : result.dependencies()) {
// Skip Test modules
if (dep.moduleScope() == ModuleScope.TEST)
continue;
// skip non-shared dependencies
if (dep.exported()) {
// skip already-visited dependencies
if (!visited.add(dep.name() + "/" + dep.version()))
continue;
/* FIXME: this is just wrong:
* - We should check for JDK
* - We should report errors with transitive paths
* - Finding a dep transitively puts it in the visited set and prevents toplevel imports from
* being checked
*/
// skip JDK checks
String name = dep.name();
if (JDKUtils.jdk.providesVersion(JDK.JDK9.version)) {
// unalias jdk7-8 module names if we're running on jdk9+
name = JDKUtils.getJava9ModuleName(name, dep.version());
}
if (jdkProvider.isJDKModule(name))
continue;
log.info(" dep " + dep.name() + "/" + dep.version());
// look it up
ArtifactContext context = new ArtifactContext(dep.namespace(), dep.name(), dep.version(), ArtifactContext.CAR, ArtifactContext.JAR);
ArtifactResult depResult = lookupRepoman.getArtifactResult(context);
File artifact = depResult != null ? depResult.artifact() : null;
log.info("Result: " + depResult);
if (artifact != null && artifact.exists()) {
try {
Set<String> importedClasses = JarUtils.gatherClassnamesFromJar(artifact);
classes.addAll(importedClasses);
addTransitiveDependenciesClasses(depResult, classes, visited, originalDependency);
} catch (IOException x) {
feedback.dependency(DependencyResults.DEP_TRANSITIVE_ERROR, originalDependency);
hasErrors = true;
}
} else {
feedback.dependency(DependencyResults.DEP_TRANSITIVE_ERROR, originalDependency);
hasErrors = true;
}
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}
Aggregations