Search in sources :

Example 61 with ArtifactContext

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();
}
Also used : ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

Example 62 with ArtifactContext

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();
}
Also used : CeylonImportJarTool(org.eclipse.ceylon.tools.importjar.CeylonImportJarTool) MavenArtifactContext(org.eclipse.ceylon.cmr.api.MavenArtifactContext) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) File(java.io.File)

Aggregations

ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)62 File (java.io.File)33 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)25 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)22 Test (org.junit.Test)20 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)17 IOException (java.io.IOException)13 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)9 MavenArtifactContext (org.eclipse.ceylon.cmr.api.MavenArtifactContext)7 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)6 ArrayList (java.util.ArrayList)5 RepositoryManagerBuilder (org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)5 Manifest (java.util.jar.Manifest)4 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)4 Module (org.eclipse.ceylon.model.typechecker.model.Module)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 FileWriter (java.io.FileWriter)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3