Search in sources :

Example 26 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.

the class AbstractModelLoader method loadStandardModules.

public void loadStandardModules() {
    // set up the type factory
    Timer nested = timer.nestedTimer();
    nested.startTask("load ceylon.language");
    Module languageModule = loadLanguageModuleAndPackage();
    nested.endTask();
    nested.startTask("load JDK");
    // make sure the jdk modules are loaded
    String jdkModuleSpec = getAlternateJdkModuleSpec();
    Module jdkModule = null;
    if (jdkModuleSpec != null) {
        ModuleSpec spec = ModuleSpec.parse(jdkModuleSpec);
        jdkModule = findOrCreateModule(spec.getName(), spec.getVersion());
    }
    if (jdkModule == null) {
        jdkProvider = new JdkProvider();
        loadJDKModules();
        jdkModule = findOrCreateModule(JAVA_BASE_MODULE_NAME, jdkProvider.getJDKVersion());
    }
    nested.endTask();
    /*
         * We start by loading java.lang and ceylon.language because we will need them no matter what.
         */
    nested.startTask("load standard packages");
    loadPackage(jdkModule, "java.lang", false);
    loadPackage(languageModule, "org.eclipse.ceylon.compiler.java.metadata", false);
    loadPackage(languageModule, "org.eclipse.ceylon.compiler.java.language", false);
    nested.endTask();
}
Also used : ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) Module(org.eclipse.ceylon.model.typechecker.model.Module) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule)

Example 27 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.

the class JvmBackendUtil method loadStaticMetamodel.

public static void loadStaticMetamodel(InputStream is, List<String> dexEntries, StaticMetamodelLoader staticMetamodelLoader) {
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
        String line;
        ModuleSpec module = null;
        SortedSet<String> packages = new TreeSet<>();
        List<ArtifactResult> imports = new LinkedList<ArtifactResult>();
        while ((line = reader.readLine()) != null) {
            if (line.startsWith("=")) {
                if (module != null)
                    finishLoadingModule(module, packages, imports, dexEntries, staticMetamodelLoader);
                module = ModuleSpec.parse(line.substring(1));
                packages.clear();
                imports.clear();
                continue;
            }
            boolean _optional = false;
            boolean _shared = false;
            if (line.startsWith("?")) {
                _optional = true;
                line = line.substring(1);
            }
            if (line.startsWith("+")) {
                _shared = true;
                line = line.substring(1);
            }
            // SERIOUSLY!!
            final boolean optional = _optional;
            final boolean shared = _shared;
            if (line.startsWith("@")) {
                packages.add(line.substring(1));
                continue;
            }
            // it's an import
            ModuleSpec importSpec = ModuleSpec.parse(line);
            final String namespace = ModuleUtil.getNamespaceFromUri(importSpec.getName());
            final String name = ModuleUtil.getModuleNameFromUri(importSpec.getName());
            final String version = importSpec.getVersion();
            imports.add(new ArtifactResult() {

                @Override
                public String namespace() {
                    return namespace;
                }

                @Override
                public String name() {
                    return name;
                }

                @Override
                public String version() {
                    return version;
                }

                @Override
                public boolean optional() {
                    return optional;
                }

                @Override
                public boolean exported() {
                    return shared;
                }

                @Override
                public ArtifactResultType type() {
                    // Is this important?
                    return ArtifactResultType.OTHER;
                }

                @Override
                public VisibilityType visibilityType() {
                    return VisibilityType.STRICT;
                }

                @Override
                public File artifact() throws RepositoryException {
                    return null;
                }

                @Override
                public PathFilter filter() {
                    return null;
                }

                @Override
                public List<ArtifactResult> dependencies() throws RepositoryException {
                    return null;
                }

                @Override
                public String artifactId() {
                    return ModuleUtil.getMavenArtifactIdIfMavenModule(name);
                }

                @Override
                public String groupId() {
                    return ModuleUtil.getMavenGroupIdIfMavenModule(name);
                }

                @Override
                public String classifier() {
                    return ModuleUtil.getMavenClassifierIfMavenModule(name);
                }

                @Override
                public String repositoryDisplayString() {
                    return "Android dependency";
                }

                @Override
                public Repository repository() {
                    return null;
                }

                @Override
                public ModuleScope moduleScope() {
                    return ModuleScope.COMPILE;
                }

                @Override
                public List<Exclusion> getExclusions() {
                    return null;
                }
            });
        }
        if (module != null)
            finishLoadingModule(module, packages, imports, dexEntries, staticMetamodelLoader);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : PathFilter(org.eclipse.ceylon.model.cmr.PathFilter) InputStreamReader(java.io.InputStreamReader) ModuleScope(org.eclipse.ceylon.model.cmr.ModuleScope) RepositoryException(org.eclipse.ceylon.model.cmr.RepositoryException) IOException(java.io.IOException) LinkedList(java.util.LinkedList) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Repository(org.eclipse.ceylon.model.cmr.Repository) ArtifactResultType(org.eclipse.ceylon.model.cmr.ArtifactResultType) ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) VisibilityType(org.eclipse.ceylon.model.cmr.VisibilityType) TreeSet(java.util.TreeSet) BufferedReader(java.io.BufferedReader) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 28 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.

the class CeylonCompileTool method initialize.

@Override
public void initialize(CeylonTool mainTool) throws Exception {
    super.initialize(mainTool);
    compiler = new Main("ceylon compile");
    helper.options.clear();
    Options.instance(new Context());
    includeDependencies = processCompileFlags(includeDependencies, DefaultToolOptions.getCompilerIncludeDependencies());
    if (modulesOrFiles.isEmpty() && !javac.contains("-help") && !javac.contains("-X") && !javac.contains("-version")) {
        throw new IllegalStateException("Argument moduleOrFile should appear at least 1 time(s)");
    }
    arguments = new ArrayList<>();
    if (cwd != null) {
        arguments.add("-cwd");
        arguments.add(cwd.getPath());
        validateWithJavac(org.eclipse.ceylon.langtools.tools.javac.main.Option.CEYLONCWD, "-cwd", cwd.getPath());
    }
    if (jdkProvider != null) {
        arguments.add("-jdk-provider");
        arguments.add(jdkProvider.toString());
    }
    if (aptModules != null) {
        for (ModuleSpec mod : aptModules) {
            arguments.add("-apt");
            arguments.add(mod.toString());
        }
    }
    for (File source : applyCwd(this.sources)) {
        arguments.add("-src");
        arguments.add(source.getPath());
        validateWithJavac(org.eclipse.ceylon.langtools.tools.javac.main.Option.CEYLONSOURCEPATH, "-sourcepath", source.getPath());
    }
    for (File resource : applyCwd(this.resources)) {
        arguments.add("-res");
        arguments.add(resource.getPath());
    }
    if (resourceRoot != null) {
        arguments.add("-resroot");
        arguments.add(resourceRoot);
    }
    if (continueOnErrors) {
        arguments.add("-continue");
    }
    if (progress) {
        arguments.add("-progress");
    }
    if (offline) {
        arguments.add("-offline");
    }
    if (timeout != -1) {
        arguments.add("-timeout");
        arguments.add(String.valueOf(timeout));
    }
    if (flatClasspath) {
        arguments.add("-flat-classpath");
    }
    if (autoExportMavenDependencies) {
        arguments.add("-auto-export-maven-dependencies");
    }
    if (fullyExportMavenDependencies) {
        arguments.add("-fully-export-maven-dependencies");
    }
    if (overrides != null) {
        arguments.add("-overrides");
        if (overrides.startsWith("classpath:")) {
            arguments.add(overrides);
        } else {
            arguments.add(applyCwd(new File(overrides)).getPath());
        }
    }
    if (jigsaw) {
        arguments.add("-module-info");
    }
    if (noOsgi) {
        arguments.add("-noosgi");
    }
    if (osgiProvidedBundles != null && !osgiProvidedBundles.isEmpty()) {
        arguments.add("-osgi-provided-bundles");
        arguments.add(osgiProvidedBundles);
    }
    if (noPom) {
        arguments.add("-nopom");
    }
    if (pack200) {
        arguments.add("-pack200");
    }
    if (verbose != null) {
        if (verbose.isEmpty()) {
            arguments.add("-verbose");
        } else {
            arguments.add("-verbose:" + verbose);
        }
    }
    if (out != null) {
        arguments.add("-out");
        arguments.add(out);
    }
    if (user != null) {
        arguments.add("-user");
        arguments.add(user);
    }
    if (pass != null) {
        arguments.add("-pass");
        arguments.add(pass);
    }
    String fileEncoding = encoding;
    if (fileEncoding == null) {
        fileEncoding = DefaultToolOptions.getDefaultEncoding();
    }
    if (fileEncoding != null) {
        try {
            Charset.forName(fileEncoding);
        } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
            throw new IllegalArgumentException("Unsupported encoding: " + fileEncoding);
        }
        arguments.add(org.eclipse.ceylon.langtools.tools.javac.main.Option.ENCODING.text);
        arguments.add(fileEncoding);
    }
    if (systemRepo != null) {
        arguments.add("-sysrep");
        arguments.add(systemRepo);
    }
    if (cacheRepo != null) {
        arguments.add("-cacherep");
        arguments.add(cacheRepo);
    }
    if (noDefRepos) {
        arguments.add("-nodefreps");
    }
    if (repos != null) {
        for (URI uri : this.repos) {
            arguments.add("-rep");
            arguments.add(uri.toString());
        }
    }
    if (suppressWarnings != null) {
        arguments.add("-suppress-warnings");
        arguments.add(EnumUtil.enumsToString(suppressWarnings));
    }
    if (targetVersion != null) {
        arguments.add("-source");
        arguments.add(targetVersion.toString());
        arguments.add("-target");
        arguments.add(targetVersion.toString());
    }
    if (ee) {
        arguments.add("-ee");
    }
    if (eeImport != null) {
        for (String eeImport : this.eeImport) {
            arguments.add("-ee-import");
            arguments.add(eeImport);
        }
    }
    if (eeAnnotation != null) {
        for (String eeAnnotation : this.eeAnnotation) {
            arguments.add("-ee-annotation");
            arguments.add(eeAnnotation);
        }
    }
    addJavacArguments(arguments, javac);
    List<File> srcs = applyCwd(this.sources);
    Collection<String> expandedModulesOrFiles = ModuleWildcardsHelper.expandWildcards(srcs, this.modulesOrFiles, Backend.Java);
    expandedModulesOrFiles = normalizeFileNames(expandedModulesOrFiles);
    if (expandedModulesOrFiles.isEmpty()) {
        String msg = CeylonCompileMessages.msg("error.no.sources");
        if (ModuleWildcardsHelper.onlyGlobArgs(this.modulesOrFiles)) {
            throw new NonFatalToolMessage(msg);
        } else {
            throw new ToolUsageError(msg);
        }
    }
    for (String moduleOrFile : expandedModulesOrFiles) {
        if (!org.eclipse.ceylon.langtools.tools.javac.main.Option.SOURCEFILE.matches(moduleOrFile)) {
            throw new IllegalArgumentException(CeylonCompileMessages.msg("argument.error", moduleOrFile));
        }
        validateWithJavac(org.eclipse.ceylon.langtools.tools.javac.main.Option.SOURCEFILE, moduleOrFile, moduleOrFile);
    }
    // We validate that all source arguments are correct
    SourceArgumentsResolver sar = new SourceArgumentsResolver(this.sources, this.resources, Constants.CEYLON_SUFFIX, Constants.JAVA_SUFFIX);
    sar.cwd(cwd).parse(expandedModulesOrFiles);
    if (includeDependencies != null && !COMPILE_NEVER.equals(includeDependencies)) {
        // Determine any dependencies that might need compiling as well
        SourceDependencyResolver sdr = new SourceDependencyResolver(getModuleVersionReader(), this.sources, Backends.JAVA);
        if (sdr.traverseDependencies(sar.getSourceFiles())) {
            for (ModuleVersionDetails mvd : sdr.getAdditionalModules()) {
                if (COMPILE_FORCE.equals(includeDependencies) || (COMPILE_CHECK.equals(includeDependencies) && shouldRecompile(getOfflineRepositoryManager(), mvd.getModule(), mvd.getVersion(), ModuleQuery.Type.JVM, true)) || (COMPILE_ONCE.equals(includeDependencies) && shouldRecompile(getOfflineRepositoryManager(), mvd.getModule(), mvd.getVersion(), ModuleQuery.Type.JVM, false))) {
                    expandedModulesOrFiles.add(mvd.getModule());
                    if (incremental) {
                        sar.parse(expandedModulesOrFiles);
                    }
                }
            }
        }
    }
    if (incremental) {
        next_module: for (String module : sar.getModules()) {
            // Determine module version from source
            ModuleVersionDetails mvd = getModuleVersionReader().fromSource(module);
            if (mvd != null) {
                // Find the module's CAR file
                ArtifactResult artifact = getModuleArtifact(getOfflineRepositoryManager(), mvd.getModule(), mvd.getVersion(), ModuleQuery.Type.JVM);
                if (artifact != null) {
                    // Check the language module version
                    for (ArtifactResult dep : artifact.dependencies()) {
                        if ("ceylon.language".equals(dep.name())) {
                            if (!Versions.CEYLON_VERSION_NUMBER.equals(dep.version())) {
                                // Skip handling of --incremental on this module
                                continue next_module;
                            }
                            break;
                        }
                    }
                    File carFile = artifact.artifact();
                    // Check if it has META-INF/errors.txt
                    Properties errors = getMetaInfErrors(carFile);
                    if (errors != null && !errors.isEmpty()) {
                        // TODO handle this incrementally
                        continue;
                    }
                    // Check if it has META-INF/hashes.txt
                    Properties oldHashes = getMetaInfHashes(carFile);
                    if (oldHashes != null) {
                        // Get the hashes for the new files
                        List<File> files = sar.getFilesByModule().get(module);
                        Properties newHashes = getFileHashes(module, files);
                        // Compare the two and make list of changed files
                        Collection<String> changedFiles = determineChangedFiles(module, oldHashes, newHashes, carFile);
                        if (changedFiles == null) {
                        // This shouldn't happen, but if it does we just skip any
                        // special treatment and compile this module normally
                        } else if (changedFiles.isEmpty()) {
                            // No files were changed, we shouldn't compile the module
                            expandedModulesOrFiles.remove(module);
                            // And we remove its files too if any were mentioned
                            Collection<String> remove = filesToStrings(module, files);
                            expandedModulesOrFiles.removeAll(remove);
                        } else {
                            if (expandedModulesOrFiles.contains(module)) {
                                // The module itself was mentioned on the command line
                                if (changedFiles.size() < files.size()) {
                                    // There were fewer changed files than the total number
                                    // So we remove the module
                                    expandedModulesOrFiles.remove(module);
                                    // And we remove its files too if any were mentioned
                                    Collection<String> remove = filesToStrings(module, files);
                                    expandedModulesOrFiles.removeAll(remove);
                                    // And then we add only those files that were changed
                                    expandedModulesOrFiles.addAll(changedFiles);
                                }
                            } else {
                                // Separate source files were mentioned on the command line
                                // So we remove the unchanged files
                                Collection<String> unchanged = filesToStrings(module, files);
                                unchanged.removeAll(changedFiles);
                                expandedModulesOrFiles.removeAll(unchanged);
                            }
                        }
                    }
                }
            }
        }
        if (expandedModulesOrFiles.isEmpty()) {
            String msg = CeylonCompileMessages.msg("error.no.need");
            throw new NonFatalToolMessage(msg);
        }
    }
    arguments.addAll(expandedModulesOrFiles);
    if (verbose != null) {
        System.out.println(arguments);
        System.out.flush();
    }
}
Also used : Context(org.eclipse.ceylon.langtools.tools.javac.util.Context) SourceArgumentsResolver(org.eclipse.ceylon.common.tools.SourceArgumentsResolver) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) SourceDependencyResolver(org.eclipse.ceylon.common.tools.SourceDependencyResolver) Properties(java.util.Properties) URI(java.net.URI) NonFatalToolMessage(org.eclipse.ceylon.common.tool.NonFatalToolMessage) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) IllegalCharsetNameException(java.nio.charset.IllegalCharsetNameException) ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) UnsupportedCharsetException(java.nio.charset.UnsupportedCharsetException) ToolUsageError(org.eclipse.ceylon.common.tool.ToolUsageError) Collection(java.util.Collection) List(java.util.List) ArrayList(java.util.ArrayList) Main(org.eclipse.ceylon.compiler.java.launcher.Main) File(java.io.File)

Example 29 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec 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();
}
Also used : ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) Context(org.eclipse.ceylon.compiler.typechecker.context.Context) TypeCheckerBuilder(org.eclipse.ceylon.compiler.typechecker.TypeCheckerBuilder) PhasedUnitsModuleManager(org.eclipse.ceylon.compiler.PhasedUnitsModuleManager) ModuleManager(org.eclipse.ceylon.model.typechecker.util.ModuleManager) AssertionVisitor(org.eclipse.ceylon.compiler.typechecker.util.AssertionVisitor) Callable(java.util.concurrent.Callable) LinkedList(java.util.LinkedList) ModuleValidator(org.eclipse.ceylon.compiler.typechecker.analyzer.ModuleValidator) PhasedUnit(org.eclipse.ceylon.compiler.typechecker.context.PhasedUnit) PhasedUnitsModuleManager(org.eclipse.ceylon.compiler.PhasedUnitsModuleManager) ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) PhasedUnits(org.eclipse.ceylon.compiler.typechecker.context.PhasedUnits) LazyModuleSourceMapper(org.eclipse.ceylon.compiler.java.loader.model.LazyModuleSourceMapper) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) LazyModuleSourceMapper(org.eclipse.ceylon.compiler.java.loader.model.LazyModuleSourceMapper) ModuleSourceMapper(org.eclipse.ceylon.compiler.typechecker.analyzer.ModuleSourceMapper) ModuleManagerFactory(org.eclipse.ceylon.compiler.typechecker.util.ModuleManagerFactory) File(java.io.File)

Example 30 with ModuleSpec

use of org.eclipse.ceylon.common.ModuleSpec in project ceylon by eclipse.

the class CeylonInfoTool method run.

@Override
public void run() throws Exception {
    if (showIncompatible != Incompatible.yes) {
        if (queryType.includes(ArtifactContext.CAR)) {
            jvmBinaryMajor = Versions.JVM_BINARY_MAJOR_VERSION;
            jvmBinaryMinor = Versions.JVM_BINARY_MINOR_VERSION;
        }
        if (queryType.includes(ArtifactContext.JS)) {
            jsBinaryMajor = Versions.JS_BINARY_MAJOR_VERSION;
            jsBinaryMinor = Versions.JS_BINARY_MINOR_VERSION;
        }
    }
    String msgkey = showIncompatible == Incompatible.no ? "module.not.found.compat" : "module.not.found";
    for (ModuleSpec module : modules) {
        String name = module.getName();
        if (!module.isVersioned() && (name.startsWith("*") || name.endsWith("*"))) {
            Collection<ModuleDetails> modules = getModules(getRepositoryManager(), module.getNamespace(), name, queryType, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
            if (modules.isEmpty()) {
                String err;
                if (name.startsWith("*") || name.endsWith("*")) {
                    err = CeylonInfoMessages.msg("no.match", name);
                } else {
                    err = getModuleNotFoundErrorMessage(getRepositoryManager(), module.getName(), module.getVersion(), msgkey);
                }
                errorAppend(err);
                errorNewline();
                continue;
            }
            outputModules(module, modules);
        } else {
            Collection<ModuleVersionDetails> versions = getModuleVersions(getRepositoryManager(), module.getNamespace(), module.getName(), module.getVersion(), false, queryType, jvmBinaryMajor, jvmBinaryMinor, jsBinaryMajor, jsBinaryMinor);
            if (versions.isEmpty()) {
                // try from source
                ModuleVersionDetails fromSource = getModuleVersionDetailsFromSource(name);
                if (fromSource != null) {
                    // is it the version we're after?
                    versions = Arrays.asList(fromSource);
                } else {
                    if (showIncompatible == Incompatible.auto && (jvmBinaryMajor != null || jvmBinaryMinor != null || jsBinaryMajor != null || jsBinaryMinor != null)) {
                        // If we were called with a specific version and we didn't find a "compatible"
                        // artifact then lets see if we can find an "incompatible" one
                        versions = getModuleVersions(getRepositoryManager(), module.getNamespace(), module.getName(), module.getVersion(), false, queryType, null, null, null, null);
                    }
                    if (versions.isEmpty()) {
                        String err = getModuleNotFoundErrorMessage(getRepositoryManager(), module.getName(), module.getVersion(), msgkey);
                        errorAppend(err);
                        errorNewline();
                        continue;
                    }
                }
            }
            if (module.getVersion() == null || module.getVersion().isEmpty() || versions.size() > 1) {
                outputVersions(module, versions);
            } else {
                outputDetails(module, versions.iterator().next());
            }
        }
    }
}
Also used : ModuleSpec(org.eclipse.ceylon.common.ModuleSpec) ModuleVersionDetails(org.eclipse.ceylon.cmr.api.ModuleVersionDetails) ModuleDetails(org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails)

Aggregations

ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)35 File (java.io.File)18 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)13 ArrayList (java.util.ArrayList)11 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)7 IOException (java.io.IOException)6 Test (org.junit.Test)6 ZipFile (java.util.zip.ZipFile)5 ModuleGraph (org.eclipse.ceylon.cmr.ceylon.loader.ModuleGraph)5 HashSet (java.util.HashSet)4 LinkedList (java.util.LinkedList)4 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)4 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)4 List (java.util.List)3 ZipEntry (java.util.zip.ZipEntry)3 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)3 Module (org.eclipse.ceylon.cmr.ceylon.loader.ModuleGraph.Module)3 Ignore (org.junit.Ignore)3 BufferedReader (java.io.BufferedReader)2 FileOutputStream (java.io.FileOutputStream)2