use of org.eclipse.ceylon.cmr.api.RepositoryManager in project ceylon by eclipse.
the class AetherTestCase method testListVersionsAether.
@Test
public void testListVersionsAether() throws Exception {
CmrRepository repository = createAetherRepository();
RepositoryManager manager = new SimpleRepositoryManager(repository, log);
ModuleVersionQuery lookup = new ModuleVersionQuery("com.sparkjava:spark-core", "1.", Type.JAR);
ModuleVersionResult result = manager.completeVersions(lookup);
Assert.assertEquals(3, result.getVersions().size());
Assert.assertNotNull(result.getVersions().get("1.0"));
Assert.assertNotNull(result.getVersions().get("1.1"));
Assert.assertNotNull(result.getVersions().get("1.1.1"));
for (ModuleVersionDetails res : result.getVersions().values()) {
Assert.assertEquals("Spark\nA Sinatra inspired java web framework\nhttp://www.sparkjava.com", res.getDoc());
Assert.assertEquals("The Apache Software License, Version 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0.txt", res.getLicense());
NavigableSet<ModuleDependencyInfo> deps = res.getDependencies();
List<ModuleDependencyInfo> compileDeps = new ArrayList<>(deps.size());
for (ModuleDependencyInfo dep : res.getDependencies()) {
if (dep.getModuleScope() == ModuleScope.COMPILE || dep.getModuleScope() == ModuleScope.PROVIDED)
compileDeps.add(dep);
}
Assert.assertEquals(4, compileDeps.size());
}
lookup = new ModuleVersionQuery("com.sparkjava:spark-core", null, Type.JAR);
result = manager.completeVersions(lookup);
// Count the version up to 2.3
int cnt = 0;
for (ModuleVersionDetails mvd : result.getVersions().values()) {
cnt++;
if ("2.3".equals(mvd.getVersion())) {
break;
}
}
Assert.assertEquals(7, cnt);
// now check that we only downloaded the POMs for that, and not the jars
File repo = new File("build/test-classes/maven-settings/repository");
File folder = new File(repo, "com/sparkjava/spark-core/1.0");
Assert.assertTrue(new File(folder, "spark-core-1.0.pom").exists());
Assert.assertFalse(new File(folder, "spark-core-1.0.jar").exists());
Assert.assertFalse(new File(repo, "org/eclipse/jetty/jetty-server/9.0.2.v20130417/jetty-server-9.0.2.v20130417.jar").exists());
// this one has a conflict if we do resolve it non-lazily
lookup = new ModuleVersionQuery("org.hibernate:hibernate-validator", "3.", Type.JAR);
result = manager.completeVersions(lookup);
Assert.assertEquals(4, result.getVersions().size());
}
use of org.eclipse.ceylon.cmr.api.RepositoryManager in project ceylon by eclipse.
the class AetherTestCase method testReplaceOverrides.
@Test
public void testReplaceOverrides() throws Throwable {
CmrRepository repository = createAetherRepository();
RepositoryManager manager = new SimpleRepositoryManager(repository, log, RepositoryManagerBuilder.parseOverrides(getOverridesFileName()));
ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.apache.camel:camel-core", "2.9.2");
Assert.assertNotNull(result);
Assert.assertEquals(result.name(), "org.osgi:org.osgi.core");
File artifact = result.artifact();
boolean exists = false;
try {
Assert.assertNotNull(artifact);
Assert.assertTrue(artifact.exists());
exists = true;
List<ArtifactResult> deps = result.dependencies();
Assert.assertEquals(deps.size(), 0);
} finally {
if (exists) {
// delete this one
Assert.assertTrue(artifact.delete());
}
}
}
use of org.eclipse.ceylon.cmr.api.RepositoryManager in project ceylon by eclipse.
the class ModelLoaderTests method verifyRuntimeClassLoading.
protected void verifyRuntimeClassLoading(RunnableTest test) {
RepositoryManager repoManager = CeylonUtils.repoManager().systemRepo(getSysRepPath()).buildManager();
VFS vfs = new VFS();
org.eclipse.ceylon.compiler.typechecker.context.Context context = new org.eclipse.ceylon.compiler.typechecker.context.Context(repoManager, vfs);
RuntimeModuleManager moduleManager = new RuntimeModuleManager(null);
context.setModules(new Modules());
moduleManager.initCoreModules(new Modules());
moduleManager.loadModule(AbstractModelLoader.CEYLON_LANGUAGE, Versions.CEYLON_VERSION_NUMBER, repoManager.getArtifactResult(null, "ceylon.language", Versions.CEYLON_VERSION_NUMBER), getClass().getClassLoader());
RuntimeModelLoader modelLoader = moduleManager.getModelLoader();
modelLoader.setupWithNoStandardModules();
modelLoader.loadStandardModules();
test.test(modelLoader);
}
use of org.eclipse.ceylon.cmr.api.RepositoryManager in project ceylon by eclipse.
the class ImportJarToolTests method testMissingOptionalPackages.
@Test
public void testMissingOptionalPackages() throws Exception {
// Jetty is compiled for JDK8
Assume.assumeTrue("Runs on JDK8", JDKUtils.jdk == JDKUtils.JDK.JDK8);
CeylonRepoManagerBuilder builder = CeylonUtils.repoManager();
RepositoryManager repository = builder.buildManager();
File artifact = repository.getArtifact(MavenArtifactContext.NAMESPACE, "org.eclipse.jetty:jetty-server", "9.3.2.v20150730");
Assert.assertNotNull(artifact);
ToolModel<CeylonImportJarTool> model = pluginLoader.loadToolModel("import-jar");
Assert.assertNotNull(model);
// no descriptor
CeylonImportJarTool tool;
StringBuilder b = new StringBuilder();
// make sure we don't get a missing package with array shit in there: [Ljavax.servlet;
try {
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.setOut(b);
tool.run();
Assert.fail();
} catch (ToolUsageError e) {
Assert.assertEquals("Problems were found, aborting. Try adding a descriptor file, see help for more information.", e.getMessage());
Assert.assertEquals("The following JDK modules are used and could be declared as imports:\n" + " java.base ... [shared]\n" + " java.jdbc ... [shared]\n" + " java.tls ... [shared]\n" + " javax.naming\n" + "Modules containing the following packages need to be declared as imports:\n" + "(Tip: try running again with the '--show-suggestions' option)\n" + " javax.servlet ... [shared]\n" + " javax.servlet.descriptor ... [shared]\n" + " javax.servlet.http ... [shared]\n" + " org.eclipse.jetty.http ... [shared]\n" + " org.eclipse.jetty.io ... [shared]\n" + " org.eclipse.jetty.io.ssl ... [shared]\n" + " org.eclipse.jetty.jmx ... [shared]\n" + " org.eclipse.jetty.util ... [shared]\n" + " org.eclipse.jetty.util.annotation ... [shared]\n" + " org.eclipse.jetty.util.component ... [shared]\n" + " org.eclipse.jetty.util.log ... [shared]\n" + " org.eclipse.jetty.util.resource ... [shared]\n" + " org.eclipse.jetty.util.ssl ... [shared]\n" + " org.eclipse.jetty.util.statistic ... [shared]\n" + " org.eclipse.jetty.util.thread ... [shared]\n", b.toString());
}
// all OK
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-module.properties", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // exact
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.eclipse.jetty.jmx", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // **
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.**.jmx", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // *
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.eclipse.jetty.jm*", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
try {
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // * with dots
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.*.jmx", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
Assert.fail();
} catch (ToolUsageError e) {
Assert.assertEquals("Problems were found, aborting.", e.getMessage());
}
// with missing module
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", // ?
"--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound/9.3.2.v20150730=org.eclipse.jetty.jm?", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
try {
// with invalid pattern
tool = pluginFactory.bindArguments(model, getMainTool(), toolOptions("--descriptor", "test/src/org/eclipse/ceylon/tools/test/jetty-server-missing-optional-module.properties", "--missing-dependency-packages", "org.eclipse.jetty:jetty-jmxnotfound", "org.eclipse.jetty.jetty-server/9.3.2.v20150730", artifact.getAbsolutePath()));
tool.run();
Assert.fail();
} catch (ToolError e) {
Assert.assertEquals("Invalid missing dependencies descriptor : 'org.eclipse.jetty:jetty-jmxnotfound'. 'Syntax is module-name/module-version=package-wildcard(,package-wildcard)*'.", e.getMessage());
}
}
use of org.eclipse.ceylon.cmr.api.RepositoryManager in project ceylon by eclipse.
the class CeylonEnter method addOutputModuleToClassPath.
public void addOutputModuleToClassPath(Module module) {
RepositoryManager repositoryManager = fileManager.getOutputRepositoryManager();
ArtifactResult artifact = null;
try {
ArtifactContext ctx = new ArtifactContext(null, module.getNameAsString(), module.getVersion(), ArtifactContext.CAR, ArtifactContext.JAR);
artifact = repositoryManager.getArtifactResult(ctx);
} catch (InvalidArchiveException e) {
log.warning("ceylon", "Module car " + e.getPath() + " obtained from repository " + e.getRepository() + " has an invalid SHA1 signature:" + " it will be overwritten but if the problem" + " persists you need to remove it and rebuild the module, since it may be corrupted.");
} catch (Exception e) {
String moduleName = module.getNameAsString();
if (!module.isDefaultModule())
moduleName += "/" + module.getVersion();
log.error("ceylon", "Exception occured while trying to resolve module " + moduleName);
e.printStackTrace();
}
if (artifact == null || JarUtils.isValidJar(artifact.artifact())) {
addModuleToClassPath(module, false, artifact);
} else {
log.warning("ceylon", "Module car " + artifact.artifact() + " obtained from repository " + artifact.repository() + " could not be read:" + " it will be overwritten but if the problem" + " persists you need to remove it and rebuild the module, since it may be corrupted.");
}
}
Aggregations