Search in sources :

Example 1 with LazyModuleManager

use of org.eclipse.ceylon.model.loader.model.LazyModuleManager 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);
    }
}
Also used : AbstractModelLoader(org.eclipse.ceylon.model.loader.AbstractModelLoader) LazyModuleManager(org.eclipse.ceylon.model.loader.model.LazyModuleManager) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule)

Aggregations

AbstractModelLoader (org.eclipse.ceylon.model.loader.AbstractModelLoader)1 LazyModule (org.eclipse.ceylon.model.loader.model.LazyModule)1 LazyModuleManager (org.eclipse.ceylon.model.loader.model.LazyModuleManager)1