Search in sources :

Example 1 with FeaturePackSpec

use of org.jboss.galleon.spec.FeaturePackSpec in project galleon by wildfly.

the class FeaturePackXmlParserTestCase method readEmpty.

@Test
public void readEmpty() throws Exception {
    FeaturePackSpec found = validator.validateAndParse("xml/feature-pack/feature-pack-2.0-empty.xml", null, null);
    FeaturePackSpec expected = FeaturePackSpec.builder().setFPID(LegacyGalleon1Universe.newFPID("org.jboss.fp.group1:fp1", "1", "1.0.0")).build();
    Assert.assertEquals(expected, found);
}
Also used : FeaturePackSpec(org.jboss.galleon.spec.FeaturePackSpec) Test(org.junit.Test)

Example 2 with FeaturePackSpec

use of org.jboss.galleon.spec.FeaturePackSpec in project galleon by wildfly.

the class FeaturePackXmlParserTestCase method readValid.

@Test
public void readValid() throws Exception {
    FeaturePackSpec found = validator.validateAndParse("xml/feature-pack/feature-pack-2.0.xml", null, null);
    FeaturePackSpec expected = FeaturePackSpec.builder().setFPID(LegacyGalleon1Universe.newFPID("org.jboss.fp.group1:fp1", "1", "1.0.0")).addFeaturePackDep(FeaturePackConfig.forLocation(LegacyGalleon1Universe.newFPID("org.jboss.dep.group1:dep1", "0", "0.0.1").getLocation())).addFeaturePackDep(FeaturePackConfig.builder(LegacyGalleon1Universe.newFPID("org.jboss.dep.group2:dep2", "0", "0.0.2").getLocation()).excludePackage("excluded-package1").excludePackage("excluded-package2").includePackage("included-package1").includePackage("included-package2").build()).addFeaturePackDep(FeaturePackConfig.builder(LegacyGalleon1Universe.newFPID("org.jboss.dep.group2:dep3", "0", "0.0.2").getLocation(), false).excludePackage("excluded-package1").includePackage("included-package1").build()).addDefaultPackage("package1").addDefaultPackage("package2").build();
    Assert.assertEquals(expected, found);
}
Also used : FeaturePackSpec(org.jboss.galleon.spec.FeaturePackSpec) Test(org.junit.Test)

Example 3 with FeaturePackSpec

use of org.jboss.galleon.spec.FeaturePackSpec in project galleon by wildfly.

the class FeaturePackXmlParserTestCase method readDependencyWithOrigin.

@Test
public void readDependencyWithOrigin() throws Exception {
    FeaturePackSpec found = validator.validateAndParse("xml/feature-pack/feature-pack-deps-with-origin.xml", null, null);
    FeaturePackSpec expected = FeaturePackSpec.builder().setFPID(LegacyGalleon1Universe.newFPID("org.jboss.fp.group1:fp1", "1", "1.0.0")).addFeaturePackDep("dep1", FeaturePackConfig.forLocation(LegacyGalleon1Universe.newFPID("org.jboss.dep.group1:dep1", "0", "0.0.1").getLocation())).addFeaturePackDep("deptwo", FeaturePackConfig.builder(LegacyGalleon1Universe.newFPID("org.jboss.dep.group2:dep2", "0", "0.0.2").getLocation()).excludePackage("excluded-package1").excludePackage("excluded-package2").includePackage("included-package1").includePackage("included-package2").build()).addDefaultPackage("package1").addDefaultPackage("package2").build();
    Assert.assertEquals(expected, found);
}
Also used : FeaturePackSpec(org.jboss.galleon.spec.FeaturePackSpec) Test(org.junit.Test)

Example 4 with FeaturePackSpec

use of org.jboss.galleon.spec.FeaturePackSpec in project galleon by wildfly.

the class FeaturePackXmlParserTestCase method readDefaultConfigs.

@Test
public void readDefaultConfigs() throws Exception {
    FeaturePackSpec found = validator.validateAndParse("xml/feature-pack/feature-pack-default-configs.xml", null, null);
    FeaturePackSpec expected = FeaturePackSpec.builder().setFPID(LegacyGalleon1Universe.newFPID("org.jboss.fp.group1:fp1", "1", "1.0.0")).addConfig(ConfigModel.builder().setName("config1").setModel("model1").setProperty("prop1", "value1").setProperty("prop2", "value2").addFeatureGroup(FeatureGroup.builder("fg1").build()).addFeatureGroup(FeatureGroup.builder("fg2").excludeFeature(FeatureId.create("spec1", "p1", "v1")).build()).addFeature(new FeatureConfig("spec1").addFeatureDep(FeatureId.fromString("spec2:p1=v1,p2=v2")).addFeatureDep(FeatureId.create("spec3", "p3", "v3")).setParam("p1", "v1").setParam("p2", "v2")).build()).addConfig(ConfigModel.builder().setModel("model2").setProperty("prop3", "value3").setProperty("prop4", "value4").addFeatureGroup(FeatureGroup.builder("fg3").build()).addFeatureGroup(FeatureGroup.builder("fg4").excludeFeature(FeatureId.create("spec4", "p1", "v1")).build()).addFeature(new FeatureConfig("spec5").addFeatureDep(FeatureId.fromString("spec6:p1=v1,p2=v2")).addFeatureDep(FeatureId.create("spec7", "p3", "v3")).setParam("p1", "v1").setParam("p2", "v2")).build()).addDefaultPackage("package1").addDefaultPackage("package2").build();
    Assert.assertEquals(expected, found);
}
Also used : FeatureConfig(org.jboss.galleon.config.FeatureConfig) FeaturePackSpec(org.jboss.galleon.spec.FeaturePackSpec) Test(org.junit.Test)

Example 5 with FeaturePackSpec

use of org.jboss.galleon.spec.FeaturePackSpec in project galleon by wildfly.

the class ProvisioningLayout method layout.

private void layout(FeaturePackDepsConfig config, Map<ProducerSpec, FPID> branch, int type) throws ProvisioningException {
    if (!config.hasFeaturePackDeps()) {
        return;
    }
    List<ProducerSpec> added = Collections.emptyList();
    if (config.hasTransitiveDeps()) {
        if (transitiveDeps == null) {
            transitiveDeps = new HashSet<>();
        }
        for (FeaturePackConfig transitiveConfig : config.getTransitiveDeps()) {
            FeaturePackLocation fpl = transitiveConfig.getLocation();
            if (transitiveConfig.hasPatches()) {
                addPatches(transitiveConfig);
            }
            final FPID branchId = branch.get(fpl.getProducer());
            if (branchId != null) {
                if (!branchId.getChannel().getName().equals(fpl.getChannel().getName())) {
                    addConflict(fpl.getFPID(), branchId);
                }
                continue;
            }
            if (fpl.isMavenCoordinates()) {
                final F f = resolveFeaturePack(fpl, FeaturePackLayout.TRANSITIVE_DEP, true);
                fpl = f.getSpec().getFPID().getLocation();
                registerResolvedVersion(transitiveConfig.getLocation().getProducer(), fpl);
                registerMavenProducer(transitiveConfig.getLocation().getProducer(), f);
            }
            transitiveDeps.add(fpl.getProducer());
            branch.put(fpl.getProducer(), fpl.getFPID());
            added = CollectionUtils.add(added, fpl.getProducer());
        }
    }
    final Collection<FeaturePackConfig> fpDeps = config.getFeaturePackDeps();
    List<F> queue = new ArrayList<>(fpDeps.size());
    for (FeaturePackConfig fpConfig : fpDeps) {
        FeaturePackLocation fpl = fpConfig.getLocation();
        if (fpConfig.hasPatches()) {
            addPatches(fpConfig);
        }
        FPID branchId = branch.get(fpl.getProducer());
        fpl = resolveVersion(fpl, branchId);
        F fp = null;
        if (!fpl.isMavenCoordinates()) {
            fp = featurePacks.get(fpl.getProducer());
            if (fp != null) {
                converge(branchId, fpl.getFPID(), fp.getFPID());
                continue;
            }
        }
        fp = resolveFeaturePack(fpl, type, true);
        if (fpl.isMavenCoordinates()) {
            if (branchId == null) {
                branchId = branch.get(fp.getFPID().getProducer());
            }
            final FeaturePackLocation resolvedFpl = resolveVersion(fp.getFPID().getLocation(), branchId);
            F resolvedFp = featurePacks.get(resolvedFpl.getProducer());
            if (resolvedFp != null) {
                converge(branchId, resolvedFpl.getFPID(), resolvedFp.getFPID());
                if (!fpl.equals(resolvedFpl)) {
                    registerMavenProducer(fpl.getProducer(), resolvedFp);
                }
                continue;
            }
            if (!fpl.equals(resolvedFpl)) {
                if (branchId != null) {
                    fp = resolveFeaturePack(resolvedFpl, type, true);
                } else {
                    registerResolvedVersion(fpl.getProducer(), resolvedFpl);
                }
                registerMavenProducer(fpl.getProducer(), fp);
                fpl = resolvedFpl;
            }
        }
        registerFeaturePack(fpl.getProducer(), fp);
        queue.add(fp);
        if (branchId == null || branchId.getBuild() == null) {
            branch.put(fpl.getProducer(), fpl.getFPID());
            added = CollectionUtils.add(added, fpl.getProducer());
        }
    }
    if (!queue.isEmpty()) {
        for (F p : queue) {
            final FeaturePackSpec spec = p.getSpec();
            layout(spec, branch, FeaturePackLayout.TRANSITIVE_DEP);
            if (spec.hasPlugins()) {
                pluginLocations = CollectionUtils.putAll(pluginLocations, spec.getPlugins());
            }
            handle.copyResources(p.getDir());
            ordered.add(p);
        }
    }
    if (!added.isEmpty()) {
        for (ProducerSpec producer : added) {
            branch.remove(producer);
        }
    }
}
Also used : FPID(org.jboss.galleon.universe.FeaturePackLocation.FPID) ProducerSpec(org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec) ArrayList(java.util.ArrayList) FeaturePackSpec(org.jboss.galleon.spec.FeaturePackSpec) FeaturePackLocation(org.jboss.galleon.universe.FeaturePackLocation) FeaturePackConfig(org.jboss.galleon.config.FeaturePackConfig)

Aggregations

FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)12 FeaturePackConfig (org.jboss.galleon.config.FeaturePackConfig)6 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)4 FPID (org.jboss.galleon.universe.FeaturePackLocation.FPID)4 Test (org.junit.Test)4 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)3 ProvisioningException (org.jboss.galleon.ProvisioningException)3 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 ConfigId (org.jboss.galleon.config.ConfigId)2 ConfigModel (org.jboss.galleon.config.ConfigModel)2 ProducerSpec (org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec)2 BufferedReader (java.io.BufferedReader)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 FeatureConfig (org.jboss.galleon.config.FeatureConfig)1 FeatureGroup (org.jboss.galleon.config.FeatureGroup)1