Search in sources :

Example 56 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class ShaSigner method signArtifact.

public static void signArtifact(RepositoryManager repoman, ArtifactContext context, File jarFile, Logger log) {
    ArtifactContext sha1Context = context.getSha1Context();
    if (sha1Context != null) {
        sha1Context.setForceOperation(true);
        File shaFile = sign(jarFile, log, false);
        if (shaFile != null) {
            try {
                repoman.putArtifact(sha1Context, shaFile);
            } finally {
                shaFile.delete();
            }
        }
    }
}
Also used : ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) File(java.io.File)

Example 57 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class CeylonDocTool method makeDoc.

private void makeDoc() throws IOException {
    buildNodesMaps();
    if (includeSourceCode) {
        copySourceFiles();
    }
    collectSubclasses();
    collectAnnotationConstructors();
    // document every module
    boolean documentedOne = false;
    for (Module module : modules) {
        if (isEmpty(module)) {
            getLogger().warning(CeylondMessages.msg("warn.moduleHasNoDeclaration", module.getNameAsString()));
        } else {
            documentedOne = true;
        }
        documentModule(module);
        ArtifactContext artifactDocs = new ArtifactContext(null, module.getNameAsString(), module.getVersion(), ArtifactContext.DOCS);
        // find all doc folders to copy
        File outputDocFolder = getDocOutputFolder(module);
        for (File docFolder : docFolders) {
            File moduleDocFolder = new File(docFolder, join("/", module.getName()));
            if (moduleDocFolder.exists()) {
                FileUtil.copyAll(moduleDocFolder, outputDocFolder);
            }
        }
        repositoryRemoveArtifact(outputRepositoryManager, artifactDocs);
        repositoryPutArtifact(outputRepositoryManager, artifactDocs, getOutputFolder(module, null));
    }
    if (!documentedOne) {
        getLogger().warning(CeylondMessages.msg("warn.couldNotFindAnyDeclaration"));
    }
    if (browse) {
        for (Module module : modules) {
            if (isEmpty(module)) {
                continue;
            }
            ArtifactContext docArtifact = new ArtifactContext(null, module.getNameAsString(), module.getVersion(), ArtifactContext.DOCS);
            File docFolder = outputRepositoryManager.getArtifact(docArtifact);
            File docIndex = new File(docFolder, "api/index.html");
            if (docIndex.isFile()) {
                try {
                    Desktop.getDesktop().browse(docIndex.toURI());
                } catch (Exception e) {
                    getLogger().error(CeylondMessages.msg("error.unableBrowseModuleDoc", docIndex.toURI()));
                }
            }
        }
    }
}
Also used : ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) Module(org.eclipse.ceylon.model.typechecker.model.Module) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException)

Example 58 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class CeylonModuleLoader method findArtifact.

protected ArtifactResult findArtifact(ModuleIdentifier mi) {
    String namespace = ModuleUtil.getNamespaceFromUri(mi.getName());
    String name = ModuleUtil.getModuleNameFromUri(mi.getName());
    final ArtifactContext context = new ArtifactContext(namespace, name, mi.getSlot(), ArtifactContext.CAR, ArtifactContext.JAR);
    return repository.getArtifactResult(context);
}
Also used : MavenArtifactContext(org.eclipse.ceylon.cmr.api.MavenArtifactContext) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext)

Example 59 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class LegacyImporter method checkDependencies.

private void checkDependencies(TreeSet<ModuleDependencyInfo> sortedDeps, Set<String> visited, boolean exported) throws Exception {
    for (ModuleDependencyInfo dep : sortedDeps) {
        // only do exported, or non-exported
        if (exported != dep.isExport())
            continue;
        // skip test scope
        if (dep.getModuleScope() == ModuleScope.TEST)
            continue;
        // skip already-visited dependencies based on name/version key
        if (!visited.add(dep.getModuleName()))
            continue;
        feedback.beforeDependency(dep);
        String name = dep.getName();
        String version = dep.getVersion();
        // missing dep is OK, it can be fixed later, but invalid module/dependency is not OK
        if (name == null || name.isEmpty())
            feedback.dependencyError(DependencyErrors.DEPERR_INVALID_MODULE_NAME, dep);
        if (ModuleUtil.isDefaultModule(name))
            feedback.dependencyError(DependencyErrors.DEPERR_INVALID_MODULE_DEFAULT, dep);
        if (version == null || version.isEmpty())
            feedback.dependencyError(DependencyErrors.DEPERR_INVALID_MODULE_VERSION, dep);
        Usage usage = null;
        if (jdkProvider.isJDKModule(name)) {
            usage = scanner.removeMatchingJdkClasses(name);
        } else {
            ArtifactContext context = new ArtifactContext(dep.getNamespace(), name, version, ArtifactContext.CAR, ArtifactContext.JAR);
            ArtifactResult result = lookupRepoman.getArtifactResult(context);
            File artifact = result != null ? result.artifact() : null;
            if (artifact != null && artifact.exists()) {
                try {
                    Set<String> importedClasses = JarUtils.gatherClassnamesFromJar(artifact);
                    addTransitiveDependenciesClasses(result, importedClasses, visited, dep);
                    usage = scanner.removeMatchingClasses(importedClasses);
                } catch (IOException e) {
                    feedback.dependency(DependencyResults.DEP_CHECK_FAILED, dep);
                    hasErrors = true;
                }
            } else {
                if (dep.isOptional()) {
                    String key = ModuleUtil.makeModuleName(dep.getName(), dep.getVersion());
                    if (missingDependenciesPackages != null && missingDependenciesPackages.containsKey(key)) {
                        List<Pattern> packages = missingDependenciesPackages.get(key);
                        usage = scanner.removeMatchingPackages(packages);
                    }
                }
                if (usage == null) {
                    feedback.dependency(DependencyResults.DEP_NOT_FOUND, dep);
                    hasErrors = true;
                }
            }
        }
        if (usage != null) {
            switch(usage) {
                case Used:
                    if (!dep.isExport()) {
                        feedback.dependency(DependencyResults.DEP_OK, dep);
                    } else {
                        dep = new ModuleDependencyInfo(null, dep.getName(), dep.getVersion(), dep.isOptional(), false, dep.getNativeBackends(), dep.getModuleScope());
                        feedback.dependency(DependencyResults.DEP_MARK_UNSHARED, dep);
                    }
                    break;
                case UsedInPublicApi:
                    if (dep.isExport()) {
                        feedback.dependency(DependencyResults.DEP_OK, dep);
                    } else {
                        dep = new ModuleDependencyInfo(null, dep.getName(), dep.getVersion(), dep.isOptional(), true, dep.getNativeBackends(), dep.getModuleScope());
                        feedback.dependency(DependencyResults.DEP_MARK_SHARED, dep);
                        hasProblems = true;
                    }
                    break;
                default:
                    // not used at all
                    dep = new ModuleDependencyInfo(null, dep.getName(), dep.getVersion(), dep.isOptional(), false, dep.getNativeBackends(), dep.getModuleScope());
                    feedback.dependency(DependencyResults.DEP_OK_UNUSED, dep);
            }
        }
        feedback.afterDependency(dep);
        expectedDependencies.add(dep);
    }
}
Also used : Pattern(java.util.regex.Pattern) Usage(org.eclipse.ceylon.cmr.ceylon.ClassFileScanner.Usage) ModuleDependencyInfo(org.eclipse.ceylon.cmr.api.ModuleDependencyInfo) ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext) IOException(java.io.IOException) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

Example 60 with ArtifactContext

use of org.eclipse.ceylon.cmr.api.ArtifactContext in project ceylon by eclipse.

the class LazyArtifactResult method getDelegate.

private synchronized ArtifactResult getDelegate() {
    if (delegate == null) {
        final ArtifactContext context = new ArtifactContext(null, name(), version(), ArtifactContext.CAR, ArtifactContext.JAR);
        context.setThrowErrorIfMissing(!optional);
        delegate = manager.getArtifactResult(context);
    }
    return delegate;
}
Also used : ArtifactContext(org.eclipse.ceylon.cmr.api.ArtifactContext)

Aggregations

ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)62 File (java.io.File)33 ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)25 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)22 Test (org.junit.Test)20 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)17 IOException (java.io.IOException)13 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)9 MavenArtifactContext (org.eclipse.ceylon.cmr.api.MavenArtifactContext)7 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)6 ArrayList (java.util.ArrayList)5 RepositoryManagerBuilder (org.eclipse.ceylon.cmr.api.RepositoryManagerBuilder)5 Manifest (java.util.jar.Manifest)4 ModuleVersionDetails (org.eclipse.ceylon.cmr.api.ModuleVersionDetails)4 Module (org.eclipse.ceylon.model.typechecker.model.Module)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 FileWriter (java.io.FileWriter)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3