use of org.eclipse.ceylon.cmr.api.RepositoryManager in project ceylon by eclipse.
the class AetherTestCase method testScopes.
@Test
public void testScopes() throws Throwable {
CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
RepositoryManager manager = new SimpleRepositoryManager(repository, log);
ArtifactResult artifact = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.jboss.xnio:xnio-api", "3.1.0.Beta7");
File file = null;
try {
Assert.assertNotNull(artifact);
file = artifact.artifact();
Assert.assertTrue(file.exists());
// http://search.maven.org/remotecontent?filepath=org/jboss/xnio/xnio-api/3.1.0.Beta7/xnio-api-3.1.0.Beta7.pom
// there should be org.jboss.logging:jboss-logging
Assert.assertTrue(artifact.dependencies().size() > 0);
} finally {
if (file != null && file.exists()) {
// delete this one
Assert.assertTrue(file.delete());
}
}
}
use of org.eclipse.ceylon.cmr.api.RepositoryManager in project ceylon by eclipse.
the class AetherTestCase method testAetherWithExternalSettings.
@Test
public void testAetherWithExternalSettings() throws Throwable {
CmrRepository repository = createAetherRepository();
RepositoryManager manager = new SimpleRepositoryManager(repository, log);
ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.apache.camel:camel-core", "2.9.2");
Assert.assertNotNull(result);
Assert.assertEquals(result.name(), "org.apache.camel:camel-core");
File artifact = result.artifact();
boolean exists = false;
try {
Assert.assertNotNull(artifact);
Assert.assertTrue(artifact.exists());
exists = true;
List<ArtifactResult> deps = result.dependencies();
log.debug("deps = " + deps);
List<ArtifactResult> compileDeps = new ArrayList<>(deps.size());
for (ArtifactResult dep : deps) {
if (dep.moduleScope() == ModuleScope.COMPILE || dep.moduleScope() == ModuleScope.PROVIDED)
compileDeps.add(dep);
}
Assert.assertEquals(2, compileDeps.size());
Assert.assertEquals("org.slf4j:slf4j-api", compileDeps.get(0).name());
Assert.assertEquals("1.6.1", compileDeps.get(0).version());
Assert.assertEquals("org.osgi:org.osgi.core", compileDeps.get(1).name());
Assert.assertEquals("4.2.0", compileDeps.get(1).version());
Assert.assertTrue(compileDeps.get(1).optional());
log.debug("deps = " + compileDeps);
} 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 AetherTestCase method testWithSources.
@Test
public void testWithSources() throws Throwable {
CmrRepository repository = AetherRepository.createRepository(log, false, 60000);
RepositoryManager manager = new SimpleRepositoryManager(repository, log);
ArtifactResult result = manager.getArtifactResult(new ArtifactContext(MavenRepository.NAMESPACE, "org.slf4j:slf4j-api", "1.6.4", ArtifactContext.LEGACY_SRC));
Assert.assertNotNull(result);
File artifact = result.artifact();
boolean exists = false;
try {
Assert.assertNotNull(artifact);
Assert.assertTrue(artifact.exists());
exists = true;
} 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 ResolverTestCase method doTest.
private void doTest(Tester tester) throws Exception {
CmrRepository repository = createAetherRepository();
RepositoryManager manager = new SimpleRepositoryManager(repository, log);
ArtifactResult result = manager.getArtifactResult(MavenArtifactContext.NAMESPACE, "org.apache.camel:camel-core", "2.9.2");
Assert.assertNotNull(result);
Assert.assertEquals(result.name(), "org.apache.camel:camel-core");
File artifact = result.artifact();
boolean exists = false;
try {
Assert.assertNotNull(artifact);
Assert.assertTrue(artifact.exists());
exists = true;
tester.run(repository, artifact);
} 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 CeylonDocTool method initialize.
@Override
public void initialize(CeylonTool mainTool) throws Exception {
super.initialize(mainTool);
TypeCheckerBuilder builder = new TypeCheckerBuilder();
for (File src : sourceFolders) {
builder.addSrcDirectory(src);
}
// set up the artifact repository
RepositoryManager repository = getRepositoryManager();
builder.setRepositoryManager(repository);
// make a destination repo
outputRepositoryManager = getOutputRepositoryManager();
// create the actual list of modules to process
List<File> srcs = FileUtil.applyCwd(cwd, sourceFolders);
Collection<String> expandedModules = ModuleWildcardsHelper.expandWildcards(srcs, moduleSpecs, null);
final List<ModuleSpec> modules = ModuleSpec.parseEachList(expandedModules);
final Callable<PhasedUnits> getPhasedUnits = new Callable<PhasedUnits>() {
@Override
public PhasedUnits call() throws Exception {
return typeChecker.getPhasedUnits();
}
};
// we need to plug in the module manager which can load from .cars
builder.moduleManagerFactory(new ModuleManagerFactory() {
@Override
public ModuleManager createModuleManager(Context context) {
return new PhasedUnitsModuleManager(getPhasedUnits, context, modules, outputRepositoryManager, bootstrapCeylon, getLogger());
}
@Override
public ModuleSourceMapper createModuleManagerUtil(Context context, ModuleManager moduleManager) {
return new LazyModuleSourceMapper(context, (PhasedUnitsModuleManager) moduleManager, null, false, null, getEncoding());
}
});
// only parse what we asked for
List<String> moduleFilters = new LinkedList<String>();
for (ModuleSpec spec : modules) {
moduleFilters.add(spec.getName());
if (spec.getName().equals(Module.LANGUAGE_MODULE_NAME) && !bootstrapCeylon) {
throw new CeylondException("error.languageModuleBootstrapOptionMissing");
}
}
builder.setModuleFilters(moduleFilters);
String fileEncoding = getEncoding();
if (fileEncoding == null) {
fileEncoding = CeylonConfig.get(DefaultToolOptions.DEFAULTS_ENCODING);
}
if (fileEncoding != null) {
builder.encoding(fileEncoding);
}
// We do this ourselves, so we can report on the resolution errors before
// running typeChecker.process();
builder.skipDependenciesVerification();
typeChecker = builder.getTypeChecker();
{
PhasedUnits phasedUnits = typeChecker.getPhasedUnits();
phasedUnits.getModuleManager().prepareForTypeChecking();
phasedUnits.visitModules();
phasedUnits.getModuleManager().modulesVisited();
}
ModuleValidator moduleValidator = new ModuleValidator(typeChecker.getContext(), typeChecker.getPhasedUnits());
moduleValidator.verifyModuleDependencyTree();
AssertionVisitor av = new AssertionVisitor();
for (PhasedUnit pu : typeChecker.getPhasedUnits().getPhasedUnits()) {
pu.getCompilationUnit().visit(av);
}
if (haltOnError && av.getErrors() > 0) {
throw new CeylondException("error.failedParsing", new Object[] { av.getErrors() }, null);
}
typeChecker.process();
if (haltOnError && typeChecker.getErrors() > 0) {
throw new CeylondException("error.failedTypechecking", new Object[] { typeChecker.getErrors() }, null);
}
initModules(modules);
initPhasedUnits();
}
Aggregations