Search in sources :

Example 1 with GraalEdition

use of org.graalvm.component.installer.model.GraalEdition in project graal by oracle.

the class GraalEditionList method createComponentCatalog.

@Override
public ComponentCatalog createComponentCatalog(CommandInput in) {
    ComponentRegistry targetGraalVM = in.getLocalRegistry();
    if (targetGraalVM != this.targetGraal) {
        GraalEditionList gl = listGraalEditions(in, targetGraalVM);
        return gl.createComponentCatalog(in);
    }
    if (catalog != null) {
        return catalog;
    }
    String edId = in.optValue(Commands.OPTION_USE_EDITION, "");
    GraalEdition ge = getEdition(edId);
    RemoteCatalogDownloader downloader = createEditionDownloader(ge);
    CatalogContents col = new CatalogContents(feedback, downloader.getStorage(), targetGraalVM);
    return catalog = col;
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) ComponentRegistry(org.graalvm.component.installer.model.ComponentRegistry) CatalogContents(org.graalvm.component.installer.model.CatalogContents)

Example 2 with GraalEdition

use of org.graalvm.component.installer.model.GraalEdition in project graal by oracle.

the class GraalEditionList method parseSimpleSpecification.

void parseSimpleSpecification(String defId, String spec) {
    if (spec == null) {
        return;
    }
    String[] eds = spec.split("\\{");
    for (String part : eds) {
        if ("".equals(part)) {
            continue;
        }
        String edName;
        String edId;
        String src = part;
        int endBracket = part.indexOf('}');
        if (endBracket != -1) {
            int eqSign = part.indexOf('=');
            if (eqSign == -1 || eqSign >= endBracket) {
                edId = edName = part.substring(0, endBracket);
            } else {
                edId = part.substring(0, eqSign);
                edName = part.substring(eqSign + 1, endBracket);
            }
            src = part.substring(endBracket + 1).trim();
            if (src.endsWith("|")) {
                src = src.substring(0, src.length() - 1);
            }
        } else {
            edId = defId != null ? defId : "ce";
            edName = getEditionLabel(edId);
            if (edName == null) {
                edName = getEditionLabel(null);
            }
        }
        GraalEdition ge = new GraalEdition(edId, edName);
        boolean def = false;
        ge.setSoftwareSources(parseChannelSources(edId, src));
        if (defaultEdition == null && endBracket == -1) {
            def = true;
        } else if (edId.equals(defId)) {
            def = true;
        }
        registerEdition(ge, def);
    }
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition)

Example 3 with GraalEdition

use of org.graalvm.component.installer.model.GraalEdition in project graal by oracle.

the class GraalEditionList method createEditionDownloader.

RemoteCatalogDownloader createEditionDownloader(GraalEdition edition) {
    GraalEdition ed = edition;
    if (ed == null) {
        ed = defaultEdition;
    }
    RemoteCatalogDownloader dn = new RemoteCatalogDownloader(input, feedback, overrideCatalogSpec);
    Stream.concat(ed.getSoftwareSources().stream(), localSources.stream()).forEach(dn::addLocalChannelSource);
    // FIXME: temporary hack, remember to cleanup RemoteCatalogDownloader from debris, most of
    // functionality
    // has moved here.
    dn.setRemoteSourcesAllowed(false);
    return dn;
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition)

Example 4 with GraalEdition

use of org.graalvm.component.installer.model.GraalEdition in project graal by oracle.

the class GraalEditionList method ensureDefaultDefined.

private void ensureDefaultDefined(String defEditionId) {
    GraalEdition ge;
    if (editions.isEmpty()) {
        String label = getEditionLabel(defEditionId);
        ge = new GraalEdition(defEditionId == null ? "" : defEditionId, label);
    } else if (defaultEdition == null) {
        ge = editions.get(0);
    } else {
        ge = defaultEdition;
    }
    registerEdition(ge, true);
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition)

Example 5 with GraalEdition

use of org.graalvm.component.installer.model.GraalEdition in project graal by oracle.

the class GraalEditionListTest method testParseRelease20MultiCatalogDefs.

/**
 * Checks multi-property definition parsing from the release file. The default property may be
 * present, but will be ignored.
 *
 * @throws Exception
 */
@Test
public void testParseRelease20MultiCatalogDefs() throws Exception {
    // this one contains multiple
    loadReleaseFile("release20ceWithEE.properties");
    storage.graalInfo.put(CommonConstants.CAP_EDITION, "ce");
    GraalEditionList list = new GraalEditionList(this, this, getLocalRegistry());
    list.setDefaultCatalogSpec(storage.graalInfo.get(CommonConstants.RELEASE_CATALOG_KEY));
    List<GraalEdition> eds = list.editions();
    assertFalse(eds.isEmpty());
    assertEquals(2, eds.size());
    GraalEdition ge = eds.get(0);
    assertSame(list.getDefaultEdition(), ge);
    assertEquals("Expected ce edition to be the default/installed", "ce", ge.getId());
    assertEquals("Label from graal caps should be capitalized", "CE", ge.getDisplayName());
    List<SoftwareChannelSource> sources = ge.getSoftwareSources();
    assertEquals("CE edition has single source", 1, sources.size());
    ge = eds.get(1);
    assertEquals("Enterprise Edition must be present", "ee", ge.getId());
    assertEquals("Enterprise label should be parsed out", "Enterprise Edition", ge.getDisplayName());
    sources = ge.getSoftwareSources();
    assertEquals("EE has more sources", 2, sources.size());
    assertEquals("Expected decreasing priority", 2, sources.get(1).getPriority());
    assertSame(ge, list.getEdition("ee"));
}
Also used : GraalEdition(org.graalvm.component.installer.model.GraalEdition) SoftwareChannelSource(org.graalvm.component.installer.SoftwareChannelSource) Test(org.junit.Test)

Aggregations

GraalEdition (org.graalvm.component.installer.model.GraalEdition)15 SoftwareChannelSource (org.graalvm.component.installer.SoftwareChannelSource)7 Test (org.junit.Test)7 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 List (java.util.List)1 Properties (java.util.Properties)1 CommandTestBase (org.graalvm.component.installer.CommandTestBase)1 CommonConstants (org.graalvm.component.installer.CommonConstants)1 FailedOperationException (org.graalvm.component.installer.FailedOperationException)1 CatalogContents (org.graalvm.component.installer.model.CatalogContents)1 ComponentRegistry (org.graalvm.component.installer.model.ComponentRegistry)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertNull (org.junit.Assert.assertNull)1 Assert.assertSame (org.junit.Assert.assertSame)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assert.fail (org.junit.Assert.fail)1