Search in sources :

Example 46 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class InstalledProducerCompleter method getItems.

@Override
protected List<String> getItems(PmCompleterInvocation completerInvocation) {
    CommandWithInstallationDirectory cmd = (CommandWithInstallationDirectory) completerInvocation.getCommand();
    Path installation = cmd.getInstallationDirectory(completerInvocation.getAeshContext());
    List<FeaturePackLocation> locations = getInstallationLocations(installation, completerInvocation.getPmSession(), true, false);
    List<String> items = new ArrayList<>();
    String trimed = completerInvocation.getGivenCompleteValue().trim();
    List<String> lst = trimed.isEmpty() ? Collections.emptyList() : Arrays.asList(completerInvocation.getGivenCompleteValue().split(",+"));
    boolean ended = trimed.endsWith(",");
    int lastIndex = ended ? lst.size() : Math.max(0, lst.size() - 1);
    List<FeaturePackLocation> specified = new ArrayList<>();
    try {
        // List of specified locations.
        for (String s : lst) {
            specified.add(completerInvocation.getPmSession().getResolvedLocation(installation, s));
        }
        for (FeaturePackLocation loc : locations) {
            boolean found = false;
            for (int i = 0; i < lastIndex; i++) {
                FeaturePackLocation s = specified.get(i);
                if (s.getProducer().equals(loc.getProducer())) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                items.add(completerInvocation.getPmSession().getExposedLocation(installation, loc).getProducer().toString());
            }
        }
    } catch (Exception ex) {
        CliLogging.completionException(ex);
        return Collections.emptyList();
    }
    return items;
}
Also used : Path(java.nio.file.Path) ArrayList(java.util.ArrayList) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 47 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class StateTestCase method installWithDependency.

public static void installWithDependency(String version) throws ProvisioningException {
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    FeaturePackLocation fp1 = new FeaturePackLocation(universeSpec, PRODUCER3, "1", null, version);
    creator.newFeaturePack(fp1.getFPID()).addFeatureSpec(FeatureSpec.builder("specA").addPackageDep("p1", true).addParam(FeatureParameterSpec.createId("p1")).build()).addConfig(ConfigModel.builder().setModel("model1").setName("name1").addFeature(new FeatureConfig("specA").setParam("p1", "1")).build(), true).newPackage("p1", false).writeContent("fp1/p1.txt", "fp1 p1").getFeaturePack().newPackage("p2", true).writeContent("fp2/p2.txt", "fp1 p2");
    FeaturePackLocation fp2 = new FeaturePackLocation(universeSpec, PRODUCER4, "1", null, version);
    FeaturePackConfig dep = FeaturePackConfig.builder(fp1).setInheritConfigs(false).setInheritPackages(false).build();
    creator.newFeaturePack(fp2.getFPID()).addDependency(dep).addFeatureSpec(FeatureSpec.builder("specB").addParam(FeatureParameterSpec.createId("p1")).build()).addConfig(ConfigModel.builder().setModel("model1").setName("name1").addFeature(new FeatureConfig("specB").setParam("p1", "1")).addFeature(new FeatureConfig("specA").setParam("p1", "1")).build(), true);
    creator.install();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeatureConfig(org.jboss.galleon.config.FeatureConfig) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Example 48 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class StateTestCase method installLayers.

public static void installLayers(String version) throws ProvisioningException {
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    FeaturePackLocation fp1 = new FeaturePackLocation(universeSpec, PRODUCER2, "1", null, version);
    creator.newFeaturePack(fp1.getFPID()).addFeatureSpec(FeatureSpec.builder(PRODUCER2 + "-FeatureA").addParam(FeatureParameterSpec.createId("id")).build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("base").addFeature(new FeatureConfig(PRODUCER2 + "-FeatureA").setParam("id", "base")).build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("layer1").addLayerDep("base").addFeature(new FeatureConfig(PRODUCER2 + "-FeatureA").setParam("id", "layer1")).build()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("layer2").addFeature(new FeatureConfig(PRODUCER2 + "-FeatureA").setParam("id", "layer2")).build()).newPackage("p1", true).writeContent("fp1/p1.txt", "fp1 p1").getFeaturePack().addConfig(ConfigModel.builder().setModel("testmodel").setName("testmodel1").includeLayer("layer1").build());
    creator.install();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeatureConfig(org.jboss.galleon.config.FeatureConfig) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 49 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class StateTestCase method installNoFeatures.

public static void installNoFeatures(String version) throws ProvisioningException {
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    FeaturePackLocation fp1 = new FeaturePackLocation(universeSpec, PRODUCER5, "1", null, version);
    creator.newFeaturePack(fp1.getFPID()).addConfigLayer(ConfigLayerSpec.builder().setModel("testmodel").setName("base-" + PRODUCER5).addPackageDep("p1").build()).newPackage("p1", true).writeContent("fp1/p1.txt", "fp1 p1").getFeaturePack().addConfig(ConfigModel.builder().setModel("testmodel").setName("name1").includeLayer("base-" + PRODUCER5).build());
    creator.install();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Example 50 with FeaturePackLocation

use of org.jboss.galleon.universe.FeaturePackLocation in project galleon by wildfly.

the class StateTestCase method install.

public static void install(String version) throws ProvisioningException {
    FeaturePackCreator creator = FeaturePackCreator.getInstance().addArtifactResolver(cli.getSession().getMavenRepoManager());
    FeaturePackLocation fp1 = new FeaturePackLocation(universeSpec, PRODUCER1, "1", null, version);
    creator.newFeaturePack(fp1.getFPID()).newPackage("p1", true).writeContent("fp1/p1.txt", "fp1 p1").getFeaturePack().addFeatureSpec(FeatureSpec.builder("specA").addParam(FeatureParameterSpec.createId("p1")).build()).addConfig(ConfigModel.builder().setModel("model1").setName("name1").addFeature(new FeatureConfig("specA").setParam("p1", "1")).build());
    creator.install();
}
Also used : FeaturePackCreator(org.jboss.galleon.creator.FeaturePackCreator) FeatureConfig(org.jboss.galleon.config.FeatureConfig) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation)

Aggregations

FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)111 Test (org.junit.Test)46 Path (java.nio.file.Path)23 ProvisioningException (org.jboss.galleon.ProvisioningException)18 UniverseSpec (org.jboss.galleon.universe.UniverseSpec)18 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)16 ArrayList (java.util.ArrayList)13 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)13 FeaturePackCreator (org.jboss.galleon.creator.FeaturePackCreator)12 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)9 XMLStreamException (javax.xml.stream.XMLStreamException)8 ProvisioningConfig (org.jboss.galleon.config.ProvisioningConfig)8 IOException (java.io.IOException)7 CommandExecutionException (org.jboss.galleon.cli.CommandExecutionException)7 HashMap (java.util.HashMap)6 CommandException (org.aesh.command.CommandException)6 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)6 FeatureConfig (org.jboss.galleon.config.FeatureConfig)6 FeaturePackLayout (org.jboss.galleon.layout.FeaturePackLayout)6 Set (java.util.Set)5