use of org.jboss.galleon.spec.PackageSpec in project galleon by wildfly.
the class PackageXmlWriterTestCase method testAddMultiplePackageDepsWithSameName.
@Test
public void testAddMultiplePackageDepsWithSameName() throws Exception {
PackageSpec originalState = PackageSpec.builder().setName("test-package").addPackageDep("test-dep").addPackageDep("test-dep", true).build();
Path path = marshallToTempFile(originalState);
PackageSpec newState = validator.validateAndParse(path);
assertEquals(originalState, newState);
assertTrue(firstPackage(newState).isOptional());
}
use of org.jboss.galleon.spec.PackageSpec in project galleon by wildfly.
the class PackageXmlWriterTestCase method testMarshallUnmarshall.
@Test
public void testMarshallUnmarshall() throws Exception {
PackageSpec originalState = PackageSpec.builder().setName("test-package").addPackageDep("test-dep").addPackageDep("optional-dep", true).addPackageDep("external", "external-dep").addPackageDep("external", "external-optional-dep", true).addPackageDep(PackageDependencySpec.required("pkg-spec-dep")).addPackageDep(PackageDependencySpec.optional("pkg-spec-optional-dep")).addPackageDep("external", PackageDependencySpec.required("pkg-spec-external-dep")).build();
Path path = marshallToTempFile(originalState);
PackageSpec newState = validator.validateAndParse(path);
assertEquals(originalState, newState);
}
use of org.jboss.galleon.spec.PackageSpec in project galleon by wildfly.
the class PackageXmlParserTestCase method readOptionalDependencies.
@Test
public void readOptionalDependencies() throws Exception {
PackageSpec found = validator.validateAndParse("xml/package/package-1.0-optional-dependencies.xml", null, null);
PackageSpec expected = PackageSpec.builder("package1").addPackageDep("dep1").addPackageDep("dep2").addPackageDep("dep3", true).build();
Assert.assertEquals(expected, found);
}
use of org.jboss.galleon.spec.PackageSpec in project galleon by wildfly.
the class PackageXmlParserTestCase method readValid.
@Test
public void readValid() throws Exception {
PackageSpec found = validator.validateAndParse("xml/package/package-1.0.xml", null, null);
PackageSpec expected = PackageSpec.builder("package1").addPackageDep("dep1").addPackageDep("dep2").addPackageDep("fp-dep", "dep1").addPackageDep("fp-dep", "dep2").build();
Assert.assertEquals(expected, found);
}
use of org.jboss.galleon.spec.PackageSpec in project galleon by wildfly.
the class FeaturePackBuilder method build.
void build() throws ProvisioningException {
final FeaturePackLocation fps = fpBuilder.getFPID().getLocation();
if (fps == null) {
throw new ProvisioningDescriptionException("Feature-pack location has not been set");
}
if (fps.getProducerName() == null) {
throw new ProvisioningDescriptionException("Feature-pack producer has not been set");
}
/*
if(fps.getChannelName() == null) {
throw new ProvisioningDescriptionException("Feature-pack channel has not been set");
}
*/
if (fps.getBuild() == null) {
throw new ProvisioningDescriptionException("Feature-pack build number has not been set");
}
final Path fpWorkDir = LayoutUtils.getFeaturePackDir(creator.getWorkDir(), fps.getFPID(), false);
final FeaturePackSpec fpSpec;
try {
ensureDir(fpWorkDir);
for (PackageBuilder pkg : pkgs) {
final PackageSpec pkgDescr = pkg.build(fpWorkDir);
if (pkg.isDefault()) {
fpBuilder.addDefaultPackage(pkgDescr.getName());
}
}
if (!specs.isEmpty()) {
final Path featuresDir = fpWorkDir.resolve(Constants.FEATURES);
final FeatureSpecXmlWriter specWriter = FeatureSpecXmlWriter.getInstance();
for (FeatureSpec spec : specs.values()) {
final Path featureDir = featuresDir.resolve(spec.getName());
ensureDir(featureDir);
specWriter.write(spec, featureDir.resolve(Constants.SPEC_XML));
}
}
if (!featureGroups.isEmpty()) {
final Path fgsDir = fpWorkDir.resolve(Constants.FEATURE_GROUPS);
ensureDir(fgsDir);
final FeatureGroupXmlWriter fgWriter = FeatureGroupXmlWriter.getInstance();
for (FeatureGroup fg : featureGroups.values()) {
fgWriter.write(fg, fgsDir.resolve(fg.getName() + ".xml"));
}
}
if (!classes.isEmpty()) {
createPluginJar(classes, services, fpWorkDir.resolve(Constants.PLUGINS).resolve(pluginFileName));
}
if (!plugins.isEmpty()) {
final Path pluginsDir = fpWorkDir.resolve(Constants.PLUGINS);
ensureDir(pluginsDir);
for (Path plugin : plugins) {
Files.copy(plugin, pluginsDir.resolve(plugin.getFileName()));
}
}
if (!layers.isEmpty()) {
for (Map.Entry<ConfigId, ConfigLayerSpec> entry : layers.entrySet()) {
final ConfigId id = entry.getKey();
final Path xml = LayoutUtils.getLayerSpecXml(fpWorkDir, id.getModel(), id.getName(), false);
if (Files.exists(xml)) {
throw new ProvisioningException("Failed to create feature-pack: " + xml + " already exists");
}
ConfigLayerXmlWriter.getInstance().write(entry.getValue(), xml);
}
}
if (!configs.isEmpty()) {
for (ConfigModel config : configs.values()) {
final Path modelXml = LayoutUtils.getConfigXml(fpWorkDir, config.getId(), false);
if (Files.exists(modelXml)) {
throw new ProvisioningException("Failed to create feature-pack: " + modelXml + " already exists");
}
ConfigXmlWriter.getInstance().write(config, modelXml);
}
}
fpSpec = fpBuilder.build();
final FeaturePackXmlWriter writer = FeaturePackXmlWriter.getInstance();
writer.write(fpSpec, fpWorkDir.resolve(Constants.FEATURE_PACK_XML));
if (tasks != null && !tasks.isEmpty()) {
tasks.execute(FsTaskContext.builder().setTargetRoot(fpWorkDir.resolve(Constants.RESOURCES)).build());
}
creator.install(fps.getFPID(), fpWorkDir);
} catch (ProvisioningDescriptionException e) {
throw e;
} catch (Exception e) {
throw new IllegalStateException(e);
} finally {
IoUtils.recursiveDelete(fpWorkDir);
}
}
Aggregations