use of org.eclipse.ceylon.cmr.ceylon.loader.ModuleNotFoundException in project ceylon by eclipse.
the class ModuleLoaderTest method testBug7084.
@Test
public void testBug7084() throws IOException {
Path flatRepo = Files.createTempDirectory("flat-repo");
try {
RepositoryManager repositoryManager = CeylonUtils.repoManager().systemRepo("../dist/dist/repo").userRepos(Arrays.asList("flat:" + flatRepo.toAbsolutePath().toString())).buildManager();
File artifact = repositoryManager.getArtifact(null, "ceylon.collection", "1.3.2");
Assert.assertNotNull(artifact);
Files.copy(artifact.toPath(), flatRepo.resolve("ceylon.collection-1.3.2.jar"));
ModuleLoader moduleLoader = new FlatpathModuleLoader(repositoryManager, null, Collections.<String, String>emptyMap(), true);
try {
moduleLoader.loadModule("ceylon.collection", "1.3.2");
} catch (ModuleNotFoundException e) {
throw new RuntimeException(e);
}
} finally {
IOUtils.deleteRecursively(flatRepo.toFile());
}
}
use of org.eclipse.ceylon.cmr.ceylon.loader.ModuleNotFoundException in project ceylon by eclipse.
the class LazyModuleSourceMapper method preResolveDependenciesIfRequired.
@Override
public void preResolveDependenciesIfRequired(RepositoryManager repositoryManager) {
AbstractModelLoader modelLoader = getModuleManager().getModelLoader();
if (!modelLoader.isFullyExportMavenDependencies())
return;
if (statusPrinter != null) {
statusPrinter.clearLine();
statusPrinter.log("Pre-resolving dependencies");
}
if (verbose) {
log.printRawLines(WriterKind.NOTICE, "[Pre-resolving dependencies]");
}
Set<Module> compiledModules = getCompiledModules();
Map<String, String> modules = new HashMap<>();
ModuleImport anyImport = null;
for (Module module : compiledModules) {
for (ModuleImport imp : module.getImports()) {
if (imp.getModule() == null || !compiledModules.contains(imp.getModule())) {
if (anyImport == null)
anyImport = imp;
String name = imp.getModule().getNameAsString();
if (imp.getNamespace() != null)
name = imp.getNamespace() + ":" + name;
modules.put(name, imp.getModule().getVersion());
}
}
}
if (statusPrinter != null) {
statusPrinter.clearLine();
statusPrinter.log("Pre-resolving found " + modules.size() + " to pre-resolve");
}
if (verbose) {
log.printRawLines(WriterKind.NOTICE, "[Pre-resolving " + modules.size() + " modules]");
}
if (modules.isEmpty())
return;
Entry<String, String> first = modules.entrySet().iterator().next();
CompilerModuleLoader ml = new CompilerModuleLoader(repositoryManager, null, modules, verbose, statusPrinter, log);
boolean giveup = false;
try {
ml.loadModule(first.getKey(), first.getValue(), ModuleScope.COMPILE);
} catch (ModuleNotFoundException e) {
attachErrorToDependencyDeclaration(anyImport, "Pre-resolving of module failed: " + e.getMessage(), true);
giveup = true;
}
if (statusPrinter != null) {
statusPrinter.clearLine();
// don't try to read the module count if pre-resolving failed
if (giveup)
statusPrinter.log("Pre-resolving failed");
else
statusPrinter.log("Pre-resolving resolved " + ml.getModuleCount());
}
if (verbose) {
// don't try to read the module count if pre-resolving failed
if (giveup)
log.printRawLines(WriterKind.NOTICE, "[Pre-resolved failed]");
else
log.printRawLines(WriterKind.NOTICE, "[Pre-resolved " + ml.getModuleCount() + " modules]");
}
if (giveup)
return;
Overrides overrides = repositoryManager.getOverrides();
if (overrides == null) {
overrides = Overrides.create();
repositoryManager.setOverrides(overrides);
}
ml.setupOverrides(overrides);
ml.cleanup();
}
Aggregations