Search in sources :

Example 6 with PackageSpec

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

the class PackageBuilder method build.

public PackageSpec build(Path fpDir) {
    final PackageSpec pkgSpec = pkg.build();
    final Path pkgDir;
    try {
        pkgDir = LayoutUtils.getPackageDir(fpDir, pkgSpec.getName(), false);
    } catch (ProvisioningDescriptionException e) {
        throw new IllegalStateException(e);
    }
    try {
        Files.createDirectories(pkgDir);
        if (tasks != null && !tasks.isEmpty()) {
            tasks.execute(FsTaskContext.builder().setTargetRoot(pkgDir).build());
        }
        PackageXmlWriter.getInstance().write(pkgSpec, pkgDir.resolve(Constants.PACKAGE_XML));
    } catch (XMLStreamException | IOException e) {
        throw new IllegalStateException(e);
    }
    return pkgSpec;
}
Also used : Path(java.nio.file.Path) XMLStreamException(javax.xml.stream.XMLStreamException) PackageSpec(org.jboss.galleon.spec.PackageSpec) IOException(java.io.IOException) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Example 7 with PackageSpec

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

the class PackageXmlWriterTestCase method before.

@BeforeClass
public static void before() throws Exception {
    URL xsd = PackageXmlWriterTestCase.class.getClassLoader().getResource(SCHEMA);
    validator = new XmlParserValidator<PackageSpec>(Paths.get(xsd.toURI()), PackageXmlParser.getInstance());
    tmpDir = IoUtils.createRandomTmpDir();
}
Also used : PackageSpec(org.jboss.galleon.spec.PackageSpec) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 8 with PackageSpec

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

the class PackageXmlWriterTestCase method testAddMultipleOrigins.

@Test
public void testAddMultipleOrigins() throws Exception {
    PackageSpec originalState = PackageSpec.builder().setName("test-package").addPackageDep("external1", "test-dep").addPackageDep("external2", "test-dep").addPackageDep("external2", "test-dep", true).build();
    Path path = marshallToTempFile(originalState);
    PackageSpec newState = validator.validateAndParse(path);
    assertEquals(originalState, newState);
}
Also used : Path(java.nio.file.Path) PackageSpec(org.jboss.galleon.spec.PackageSpec) Test(org.junit.Test)

Example 9 with PackageSpec

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

the class PackageXmlWriterTestCase method testAddMultiplePackageDepsInSameOriginWithSameName.

@Test
public void testAddMultiplePackageDepsInSameOriginWithSameName() throws Exception {
    PackageSpec originalState = PackageSpec.builder().setName("test-package").addPackageDep("external", "test-dep").addPackageDep("external", "test-dep", true).build();
    Path path = marshallToTempFile(originalState);
    PackageSpec newState = validator.validateAndParse(path);
    assertEquals(originalState, newState);
    assertTrue(firstPackage(newState, "external").isOptional());
}
Also used : Path(java.nio.file.Path) PackageSpec(org.jboss.galleon.spec.PackageSpec) Test(org.junit.Test)

Example 10 with PackageSpec

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

the class PackageXmlWriterTestCase method testOrderOfPackageDeps.

@Test
public void testOrderOfPackageDeps() throws Exception {
    PackageSpec originalState = PackageSpec.builder().setName("test-package").addPackageDep("test-dep").addPackageDep("test-dep2").addPackageDep("test-dep3").build();
    Path path = marshallToTempFile(originalState);
    PackageSpec newState = validator.validateAndParse(path);
    assertEquals(originalState, newState);
    Iterator<PackageDependencySpec> depsIterator = newState.getLocalPackageDeps().iterator();
    assertEquals("test-dep", depsIterator.next().getName());
    assertEquals("test-dep2", depsIterator.next().getName());
    assertEquals("test-dep3", depsIterator.next().getName());
}
Also used : Path(java.nio.file.Path) PackageSpec(org.jboss.galleon.spec.PackageSpec) PackageDependencySpec(org.jboss.galleon.spec.PackageDependencySpec) Test(org.junit.Test)

Aggregations

PackageSpec (org.jboss.galleon.spec.PackageSpec)12 Test (org.junit.Test)9 Path (java.nio.file.Path)7 IOException (java.io.IOException)2 ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)2 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 ProvisioningException (org.jboss.galleon.ProvisioningException)1 ConfigId (org.jboss.galleon.config.ConfigId)1 ConfigModel (org.jboss.galleon.config.ConfigModel)1 FeatureGroup (org.jboss.galleon.config.FeatureGroup)1 ConfigLayerSpec (org.jboss.galleon.spec.ConfigLayerSpec)1 FeaturePackSpec (org.jboss.galleon.spec.FeaturePackSpec)1 FeatureSpec (org.jboss.galleon.spec.FeatureSpec)1 PackageDependencySpec (org.jboss.galleon.spec.PackageDependencySpec)1 FeaturePackLocation (org.jboss.galleon.universe.FeaturePackLocation)1 FeatureGroupXmlWriter (org.jboss.galleon.xml.FeatureGroupXmlWriter)1 FeaturePackXmlWriter (org.jboss.galleon.xml.FeaturePackXmlWriter)1