use of org.eclipse.ceylon.model.loader.model.LazyModule in project ceylon by eclipse.
the class PhasedUnitsModelLoader method addModuleToClassPath.
@Override
public void addModuleToClassPath(final Module module, ArtifactResult artifact) {
// don't add the same module more than once
if (artifact == null || !modulesAddedToClassPath.add(module))
return;
File file = artifact.artifact();
// do not load classes from it if it's the language module, since it's already in our ClassLoader and
// that would create multiple instances of the same class
classLoader.addJar(artifact, module, module == modules.getLanguageModule());
log.debug("Adding jar to classpath: " + file);
if (module instanceof LazyModule) {
((LazyModule) module).loadPackageList(artifact);
}
}
use of org.eclipse.ceylon.model.loader.model.LazyModule in project ceylon by eclipse.
the class PhasedUnitsModuleManager method createModule.
@Override
protected Module createModule(List<String> moduleName, String version) {
String name = org.eclipse.ceylon.compiler.java.util.Util.getName(moduleName);
// never create a reflection module for ceylon.language when we're documenting it
Module module;
if (name.equals(AbstractModelLoader.CEYLON_LANGUAGE) && isModuleLoadedFromSource(AbstractModelLoader.CEYLON_LANGUAGE))
module = new Module();
else
module = new ReflectionModule(this);
module.setName(moduleName);
module.setVersion(version);
if (module instanceof ReflectionModule)
setupIfJDKModule((LazyModule) module);
return module;
}
use of org.eclipse.ceylon.model.loader.model.LazyModule in project ceylon by eclipse.
the class LazyModuleSourceMapper method resolveModule.
@Override
public void resolveModule(ArtifactResult artifact, Module module, ModuleImport moduleImport, LinkedList<Module> dependencyTree, List<PhasedUnits> phasedUnitsOfDependencies, boolean forCompiledModule) {
String moduleName = module.getNameAsString();
LazyModuleManager moduleManager = getModuleManager();
boolean moduleLoadedFromSource = moduleManager.isModuleLoadedFromSource(moduleName);
boolean isLanguageModule = module == module.getLanguageModule();
AbstractModelLoader modelLoader = moduleManager.getModelLoader();
if (modelLoader.getJdkProviderModule() == module) {
modelLoader.setupAlternateJdk(module, artifact);
}
// module in question will be in the classpath
if (moduleLoadedFromSource || forCompiledModule) {
if (shouldAbortOnDuplicateModule(module, moduleName, modelLoader, dependencyTree))
return;
}
if (moduleLoadedFromSource) {
super.resolveModule(artifact, module, moduleImport, dependencyTree, phasedUnitsOfDependencies, forCompiledModule);
} else if (forCompiledModule || isLanguageModule || moduleManager.shouldLoadTransitiveDependencies()) {
// we only add stuff to the classpath and load the modules if we need them to compile our modules
// To be able to load it from the corresponding archive
modelLoader.addModuleToClassPath(module, artifact);
LazyModule lazyModule = (LazyModule) module;
if (!module.isDefaultModule()) {
if (artifact.groupId() != null)
module.setGroupId(artifact.groupId());
if (artifact.artifactId() != null)
module.setArtifactId(artifact.artifactId());
if (artifact.classifier() != null)
module.setClassifier(artifact.classifier());
if (!modelLoader.loadCompiledModule(module)) {
setupJavaModule(moduleImport, lazyModule, modelLoader, moduleManager, artifact);
} else {
setupCeylonModule(moduleImport, lazyModule, modelLoader, moduleManager, artifact, dependencyTree);
}
}
// module is now available
module.setAvailable(true);
}
}
use of org.eclipse.ceylon.model.loader.model.LazyModule in project ceylon by eclipse.
the class ReflectionModuleManager method createModule.
@Override
protected Module createModule(List<String> moduleName, String version) {
Module module;
if (isModuleLoadedFromSource(JvmBackendUtil.getName(moduleName)))
module = new Module();
else
module = new ReflectionModule(this);
module.setName(moduleName);
module.setVersion(version);
if (module instanceof ReflectionModule)
setupIfJDKModule((LazyModule) module);
return module;
}
use of org.eclipse.ceylon.model.loader.model.LazyModule in project ceylon by eclipse.
the class RuntimeModuleManager method createModule.
@Override
protected Module createModule(List<String> moduleName, String version) {
Module module;
module = new ReflectionModule(this);
module.setName(moduleName);
module.setVersion(version);
if (module instanceof ReflectionModule)
setupIfJDKModule((LazyModule) module);
return module;
}
Aggregations