use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class CeylonRunJsTool method getArtifact.
// Make sure JS and JS_MODEL artifacts exist and try to obtain the RESOURCES as well
protected File getArtifact(RepositoryManager repoman, String modName, String modVersion, boolean optional) {
final int colonIdx = modName.indexOf(':');
String namespace = null;
if (colonIdx > 0) {
namespace = modName.substring(0, colonIdx);
modName = modName.substring(colonIdx + 1);
}
ArtifactContext ac = new ArtifactContext(namespace, modName, modVersion, ArtifactContext.JS, ArtifactContext.JS_MODEL, ArtifactContext.RESOURCES);
ac.setIgnoreDependencies(true);
ac.setThrowErrorIfMissing(false);
List<ArtifactResult> results = repoman.getArtifactResults(ac);
ArtifactResult code = getArtifactType(results, ArtifactContext.JS);
ArtifactResult model = getArtifactType(results, ArtifactContext.JS_MODEL);
if (code == null || model == null) {
if (optional) {
return null;
} else if (code != null && "npm".equals(namespace)) {
return null;
}
throw new CeylonRunJsException("Cannot find module " + ModuleUtil.makeModuleName(modName, modVersion) + " in specified module repositories");
}
return model.artifact();
}
use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.
the class ImportJarToolTests method checkModuleDescriptor.
protected void checkModuleDescriptor(RepositoryManager repository, String module, String version) throws Exception {
System.err.println("Checking " + module + "/" + version);
File artifact = repository.getArtifact(new ArtifactContext(null, module, version, ArtifactContext.CAR, ArtifactContext.JAR));
File descr = new File(artifact.getParentFile(), "module.xml");
Assert.assertNotNull(artifact);
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
CeylonImportJarTool tool;
List<String> options = toolOptions("--dry-run", "--allow-cars", "--descriptor", descr.getAbsolutePath(), module + "/" + version, artifact.getAbsolutePath());
if (module.equals("org.apache.commons.logging")) {
options.addAll(0, Arrays.asList("--missing-dependency-packages", "org.apache.avalon.framework/4.1.3=org.apache.avalon.framework.**", "--missing-dependency-packages", "org.apache.log4j/1.2.12=org.apache.log4j.**", "--missing-dependency-packages", "org.apache.logkit/1.0.1=org.apache.log.**"));
}
if (module.startsWith("org.eclipse.ceylon.aether")) {
options.addAll(0, Arrays.asList("--ignore-annotations"));
}
tool = pluginFactory.bindArguments(model, getMainTool(), options);
tool.run();
}
Aggregations