Search in sources :

Example 46 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.

the class RepoUsingTool method shouldRecompile.

protected boolean shouldRecompile(RepositoryManager repoMgr, String name, String version, ModuleQuery.Type type, boolean checkTime) throws IOException {
    ArtifactResult art = getModuleArtifact(repoMgr, name, version, type);
    if (art == null) {
        return true;
    }
    File artifile = art.artifact();
    // Check if it has META-INF/errors.txt
    Properties errors = getMetaInfErrors(artifile);
    if (errors != null && !errors.isEmpty()) {
        return true;
    }
    if (checkTime) {
        return isModuleArtifactOutOfDate(artifile, name, type);
    }
    return false;
}
Also used : Properties(java.util.Properties) File(java.io.File) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

Example 47 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.

the class LazyModuleSourceMapper method setupJavaModule.

private void setupJavaModule(ModuleImport moduleImport, LazyModule module, AbstractModelLoader modelLoader, ModuleManager moduleManager, ArtifactResult artifact) {
    // we didn't find module.class so it must be a java module if it's not the default module
    module.setJava(true);
    module.setNativeBackends(Backend.Java.asSet());
    modelLoader.loadJava9Module(module, artifact.artifact());
    List<ArtifactResult> deps = artifact.dependencies();
    boolean forceExport = ModuleUtil.isMavenModule(module.getNameAsString()) && modelLoader.isFullyExportMavenDependencies();
    for (ArtifactResult dep : deps) {
        // forget runtime, test and even provided
        if (dep.moduleScope() != ModuleScope.COMPILE)
            continue;
        // re-export them anyway
        if (dep.optional())
            continue;
        Module dependency = moduleManager.getOrCreateModule(ModuleManager.splitModuleName(dep.name()), dep.version());
        ModuleImport depImport = moduleManager.findImport(module, dependency);
        if (depImport == null) {
            moduleImport = new ModuleImport(dep.namespace(), dependency, dep.optional(), // allow forcing export but not for optional modules
            dep.exported() || forceExport && !dep.optional(), Backend.Java);
            module.addImport(moduleImport);
        }
    }
}
Also used : ModuleImport(org.eclipse.ceylon.model.typechecker.model.ModuleImport) LazyModule(org.eclipse.ceylon.model.loader.model.LazyModule) Module(org.eclipse.ceylon.model.typechecker.model.Module) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult)

Example 48 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult 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 49 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.

the class SmokeTestCase method testOverridesInterpolation.

@Test
public void testOverridesInterpolation() throws Exception {
    RepositoryManager manager = getRepositoryManager("testsuite/src/test/resources/overridesInterpolation.xml");
    ArtifactResult result = manager.getArtifactResult(null, "moduletest", "0.1");
    Assert.assertNotNull(result);
    Assert.assertEquals(2, result.dependencies().size());
}
Also used : RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Example 50 with ArtifactResult

use of org.eclipse.ceylon.model.cmr.ArtifactResult in project ceylon by eclipse.

the class SmokeTestCase method testOverridesReplaceImport.

@Test
public void testOverridesReplaceImport() throws Exception {
    RepositoryManager manager = getRepositoryManager("testsuite/src/test/resources/overridesReplaceImport.xml");
    ArtifactResult result = manager.getArtifactResult(null, "moduletest", "0.1");
    Assert.assertNotNull(result);
    Assert.assertEquals(2, result.dependencies().size());
    ArtifactResult dep = result.dependencies().get(1);
    Assert.assertEquals("com.acme.helloworld", dep.name());
    Assert.assertEquals("1.0.0", dep.version());
    Assert.assertEquals(1, dep.dependencies().size());
}
Also used : RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ArtifactResult(org.eclipse.ceylon.model.cmr.ArtifactResult) Test(org.junit.Test)

Aggregations

ArtifactResult (org.eclipse.ceylon.model.cmr.ArtifactResult)79 File (java.io.File)40 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)32 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)28 Test (org.junit.Test)28 ArtifactContext (org.eclipse.ceylon.cmr.api.ArtifactContext)25 IOException (java.io.IOException)17 ArrayList (java.util.ArrayList)17 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)15 ModuleSpec (org.eclipse.ceylon.common.ModuleSpec)13 FileOutputStream (java.io.FileOutputStream)6 InputStream (java.io.InputStream)5 ToolUsageError (org.eclipse.ceylon.common.tool.ToolUsageError)5 Module (org.eclipse.ceylon.model.typechecker.model.Module)5 LinkedList (java.util.LinkedList)4 List (java.util.List)4 ZipEntry (java.util.zip.ZipEntry)4 FileInputStream (java.io.FileInputStream)3 OutputStream (java.io.OutputStream)3 OutputStreamWriter (java.io.OutputStreamWriter)3