use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class LayoutUtils method getFeaturePackDir.
public static Path getFeaturePackDir(Path fpLayoutDir, FPID fpid, boolean existing) throws ProvisioningDescriptionException {
final FeaturePackLocation fps = fpid.getLocation();
final UniverseSpec universe = fps.getUniverse();
Path fpPath = fpLayoutDir.resolve(universe.getFactory());
if (universe.getLocation() != null) {
fpPath = fpPath.resolve(ensureValidFileName(universe.getLocation()));
}
fpPath = fpPath.resolve(ensureValidFileName(fps.getProducerName()));
if (fps.getChannelName() != null) {
fpPath = fpPath.resolve(fps.getChannelName());
}
fpPath = fpPath.resolve(ensureValidFileName(fpid.getBuild()));
if (existing && !Files.exists(fpPath)) {
throw new ProvisioningDescriptionException(Errors.pathDoesNotExist(fpPath));
}
return fpPath;
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class LayoutUtils method getLayerSpecXml.
public static Path getLayerSpecXml(Path fpDir, String model, String name, boolean existing) throws ProvisioningDescriptionException {
Path p = fpDir.resolve(Constants.LAYERS);
if (model != null) {
p = p.resolve(model);
}
p = p.resolve(name).resolve(Constants.LAYER_SPEC_XML);
if (existing && !Files.exists(p)) {
throw new ProvisioningDescriptionException("Failed to locate XML file describing configuration layer " + name + " at " + p);
}
return p;
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class UnknownDefaultPackageTestCase method testMain.
@Test
public void testMain() throws Exception {
final FPID fp1Gav = LegacyGalleon1Universe.newFPID("org.pm.test:fp-install", "1", "1.0.0.Beta1");
try {
FeaturePackDescription.builder(FeaturePackSpec.builder(fp1Gav).addDefaultPackage("default")).addPackage(PackageSpec.forName("a")).build();
Assert.fail("Non-existing default package");
} catch (ProvisioningDescriptionException e) {
Assert.assertEquals(Errors.unknownPackage(fp1Gav, "default"), e.getMessage());
}
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class FeaturePackDepsConfigBuilder method addFeaturePackDepResolved.
@SuppressWarnings("unchecked")
private B addFeaturePackDepResolved(String origin, FeaturePackConfig dependency, boolean replaceExistingVersion) throws ProvisioningDescriptionException {
String existingOrigin = null;
final ProducerSpec producer = dependency.getLocation().getProducer();
if (dependency.isTransitive()) {
if (fpDeps.containsKey(producer)) {
throw new ProvisioningDescriptionException(producer + " has been already added as a direct dependency");
}
if (transitiveDeps.containsKey(producer)) {
if (!replaceExistingVersion) {
throw new ProvisioningDescriptionException(Errors.featurePackAlreadyConfigured(producer));
}
existingOrigin = producerOrigins.get(producer);
}
transitiveDeps = CollectionUtils.putLinked(transitiveDeps, producer, dependency);
} else {
if (transitiveDeps.containsKey(producer)) {
throw new ProvisioningDescriptionException(producer + " has been already added as a transitive dependency");
}
if (fpDeps.containsKey(producer)) {
if (!replaceExistingVersion) {
throw new ProvisioningDescriptionException(Errors.featurePackAlreadyConfigured(producer));
}
existingOrigin = producerOrigins.get(producer);
}
fpDeps = CollectionUtils.putLinked(fpDeps, producer, dependency);
}
if (origin != null) {
if (existingOrigin != null) {
if (!existingOrigin.equals(origin)) {
fpDepsByOrigin = CollectionUtils.remove(fpDepsByOrigin, existingOrigin);
producerOrigins = CollectionUtils.put(producerOrigins, producer, origin);
}
} else if (fpDepsByOrigin.containsKey(origin)) {
throw new ProvisioningDescriptionException(Errors.duplicateDependencyName(origin));
} else {
producerOrigins = CollectionUtils.put(producerOrigins, producer, origin);
}
fpDepsByOrigin = CollectionUtils.put(fpDepsByOrigin, origin, dependency);
}
return (B) this;
}
use of org.jboss.galleon.ProvisioningDescriptionException in project galleon by wildfly.
the class ProvisioningLayout method doBuild.
private void doBuild(boolean cleanupTransitive, boolean trackProgress) throws ProvisioningException {
buildTracker = getBuildTracker(trackProgress);
buildTracker.starting(-1);
final Map<ProducerSpec, FPID> depBranch = new HashMap<>();
layout(config, depBranch, FeaturePackLayout.DIRECT_DEP);
if (!conflicts.isEmpty()) {
throw new ProvisioningDescriptionException(Errors.fpVersionCheckFailed(conflicts.values()));
}
if (transitiveDeps != null) {
ProvisioningConfig.Builder newConfig = null;
List<ProducerSpec> notUsedTransitive = Collections.emptyList();
for (ProducerSpec producer : transitiveDeps) {
if (featurePacks.containsKey(producer)) {
continue;
}
if (cleanupTransitive && config.hasTransitiveDep(producer)) {
if (newConfig == null) {
newConfig = ProvisioningConfig.builder(config);
}
newConfig.removeTransitiveDep(producer.getLocation().getFPID());
continue;
}
notUsedTransitive = CollectionUtils.add(notUsedTransitive, producer);
}
if (!notUsedTransitive.isEmpty()) {
throw new ProvisioningDescriptionException(Errors.transitiveDependencyNotFound(notUsedTransitive.toArray(new ProducerSpec[notUsedTransitive.size()])));
}
if (newConfig != null) {
config = newConfig.build();
}
transitiveDeps = null;
}
if (resolvedVersions != null) {
final ProvisioningConfig.Builder builder = ProvisioningConfig.builder().addOptions(config.getOptions()).initUniverses(config).initConfigs(config);
addFpDeps(builder, config.getFeaturePackDeps());
if (config.hasTransitiveDeps()) {
addFpDeps(builder, config.getTransitiveDeps());
}
if (!resolvedVersions.isEmpty()) {
for (FeaturePackLocation fpl : resolvedVersions.values()) {
final FeaturePackConfig existing = builder.getTransitiveFeaturePackDep(fpl.getProducer());
if (existing == null) {
builder.addTransitiveDep(fpl);
} else if (!existing.getLocation().hasBuild()) {
builder.updateFeaturePackDep(FeaturePackConfig.builder(fpl).init(existing).build());
}
}
}
config = builder.build();
resolvedVersions = null;
}
// apply patches
if (!fpPatches.isEmpty()) {
for (F f : ordered) {
final List<F> patches = fpPatches.get(f.getFPID());
if (patches == null) {
if (f.getSpec().hasPlugins()) {
pluginLocations = CollectionUtils.putAll(pluginLocations, f.getSpec().getPlugins());
}
final Path fpResources = f.getDir().resolve(Constants.RESOURCES);
if (Files.exists(fpResources)) {
patchDir(getResources(), fpResources);
}
final Path fpPlugins = f.getDir().resolve(Constants.PLUGINS);
if (Files.exists(fpPlugins)) {
patchDir(getPluginsDir(), fpPlugins);
}
continue;
}
final Path fpDir = LayoutUtils.getFeaturePackDir(handle.getPatchedDir(), f.getFPID(), false);
try {
Files.createDirectories(fpDir);
IoUtils.copy(f.getDir(), fpDir);
} catch (IOException e) {
throw new ProvisioningException("Failed to patch feature-pack dir for " + f.getFPID(), e);
}
f.dir = fpDir;
for (F patch : patches) {
final Path patchDir = patch.getDir();
patchFpDir(fpDir, patchDir, Constants.PACKAGES);
patchFpDir(fpDir, patchDir, Constants.FEATURES);
patchFpDir(fpDir, patchDir, Constants.FEATURE_GROUPS);
patchFpDir(fpDir, patchDir, Constants.CONFIGS);
patchFpDir(fpDir, patchDir, Constants.LAYERS);
Path patchContent = patchDir.resolve(Constants.PLUGINS);
if (Files.exists(patchContent)) {
patchDir(fpDir.resolve(Constants.PLUGINS), patchContent);
patchDir(getPluginsDir(), patchContent);
}
patchContent = patchDir.resolve(Constants.RESOURCES);
if (Files.exists(patchContent)) {
patchDir(fpDir.resolve(Constants.RESOURCES), patchContent);
patchDir(getResources(), patchContent);
}
if (patch.getSpec().hasPlugins()) {
pluginLocations = CollectionUtils.putAll(pluginLocations, patch.getSpec().getPlugins());
}
}
}
}
if (!pluginLocations.isEmpty()) {
handle.addPlugins(pluginLocations.values());
}
buildTracker.complete();
}
Aggregations