use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class State method pushState.
private ProvisioningConfig pushState(Action action, PmSession pmSession) throws IOException, ProvisioningException {
action.doAction(config, builder);
try {
ProvisioningConfig newConfig = buildNewConfig(pmSession);
stack.push(action);
return newConfig;
} catch (Exception ex) {
// ex.printStackTrace();
try {
action.undoAction(builder);
} catch (Exception ex2) {
ex.addSuppressed(ex2);
}
throw ex;
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FeaturePackLocationResolverTestCase method testResolutionLocalPathInstalled.
@Test
public void testResolutionLocalPathInstalled() throws Exception {
FeaturePackLocation fpl = FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.0.0.Final");
MavenArtifact artifact = new MavenArtifact().setGroupId(FP_GROUP_ID).setArtifactId(PRODUCER1_FP_ARTIFACT_ID).setExtension("zip").setVersion("5.0.0.Final");
FeaturePackCreator.getInstance().addArtifactResolver(repo).newFeaturePack().setFPID(fpl.getFPID()).getCreator().install();
Path path = resolver.resolve(fpl);
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
Path externalPath = repoHome.resolve("external").resolve(path.getFileName().toString());
IoUtils.copy(path, externalPath);
IoUtils.recursiveDelete(path);
try {
resolver.resolve(fpl);
Assert.fail(String.format("The %s artifact is still installed in the local repository", artifact.getCoordsAsString()));
} catch (ProvisioningException e) {
// Expected exception
}
UniverseResolver resolver = UniverseResolver.builder().addArtifactResolver(repo).addLocalFeaturePack(externalPath).build();
try {
path = resolver.resolve(fpl);
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
} catch (ProvisioningException e) {
Assert.fail(String.format("Cannot resolve %s artifact using a resolved with a local feature pack location", artifact.getCoordsAsString()));
}
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class FeaturePackLocationResolverTestCase method testMain.
@Test
public void testMain() throws Exception {
try {
resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
Assert.fail("Artifact does not exist");
} catch (ProvisioningException e) {
final MavenArtifact artifact = new MavenArtifact();
artifact.setGroupId(FP_GROUP_ID);
artifact.setArtifactId(PRODUCER1_FP_ARTIFACT_ID);
artifact.setExtension("zip");
artifact.setVersionRange("[5.0-alpha,6.0-alpha)");
Assert.assertEquals(MavenErrors.artifactNotFound(artifact, repoHome).getLocalizedMessage(), e.getLocalizedMessage());
}
installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.1.0.Alpha1"));
try {
resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
Assert.fail("No final releases yet");
} catch (ProvisioningException e) {
// ignore
}
MavenArtifact artifact = new MavenArtifact().setGroupId(FP_GROUP_ID).setArtifactId(PRODUCER1_FP_ARTIFACT_ID).setExtension("zip").setVersion("5.1.0.Alpha1");
Path path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):4#4.1.0.Beta2"));
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.2.0.Final"));
artifact.setVersion("5.2.0.Final");
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.2.1.Beta1"));
artifact.setVersion("5.2.1.Beta1");
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/beta"));
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
artifact.setVersion("5.2.0.Final");
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):6#6.0.0.Alpha1"));
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5/alpha"));
artifact.setVersion("5.2.1.Beta1");
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
installFp(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):6#6.0.0.Final"));
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5"));
artifact.setVersion("5.2.0.Final");
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
artifact.setVersion("5.1.0.Alpha1");
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#5.1.0.Alpha1"));
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
artifact.setVersion("4.1.0.Beta2");
path = resolver.resolve(FeaturePackLocation.fromString("producer1@" + MavenUniverseFactory.ID + '(' + universeArt.getCoordsAsString() + "):5#4.1.0.Beta2"));
Assert.assertEquals(artifact.getArtifactFileName(), path.getFileName().toString());
}
use of org.jboss.galleon.ProvisioningException in project galleon by wildfly.
the class ProvisioningLayout method install.
private ProvisioningConfig.Builder install(FeaturePackConfig fpConfig, ProvisioningConfig.Builder configBuilder) throws ProvisioningException {
FeaturePackLocation fpl = fpConfig.getLocation();
if (!fpl.hasBuild()) {
fpl = layoutFactory.getUniverseResolver().resolveLatestBuild(fpl);
}
final FeaturePackSpec fpSpec = layoutFactory.resolveFeaturePack(fpl, FeaturePackLayout.DIRECT_DEP, fpFactory).getSpec();
final FPID fpid = fpSpec.getFPID();
if (fpSpec.isPatch()) {
if (allPatches.containsKey(fpid)) {
throw new ProvisioningException(Errors.patchAlreadyApplied(fpid));
}
F patchTarget = featurePacks.get(fpSpec.getPatchFor().getProducer());
if (patchTarget == null || !patchTarget.getFPID().equals(fpSpec.getPatchFor())) {
throw new ProvisioningException(Errors.patchNotApplicable(fpid, fpSpec.getPatchFor()));
}
FeaturePackConfig installedFpConfig = config.getFeaturePackDep(fpSpec.getPatchFor().getProducer());
if (installedFpConfig == null) {
installedFpConfig = config.getTransitiveDep(fpSpec.getPatchFor().getProducer());
}
if (installedFpConfig == null) {
return configBuilder.addFeaturePackDep(FeaturePackConfig.transitiveBuilder(patchTarget.getFPID().getLocation()).addPatch(fpid).build());
}
return configBuilder.updateFeaturePackDep(FeaturePackConfig.builder(installedFpConfig.getLocation()).init(installedFpConfig).addPatch(fpid).build());
}
if (fpl.isMavenCoordinates()) {
fpl = new FeaturePackLocation(fpid.getUniverse(), fpid.getProducer().getName(), fpid.getChannel().getName(), fpl.getFrequency(), fpid.getBuild());
fpConfig = FeaturePackConfig.builder(fpl).init(fpConfig).build();
}
final F installedFp = featurePacks.get(fpid.getProducer());
if (installedFp != null) {
if (installedFp.isTransitiveDep() == fpConfig.isTransitive()) {
return configBuilder.updateFeaturePackDep(fpConfig);
}
if (installedFp.isTransitiveDep()) {
// transitive becomes direct
if (config.hasTransitiveDep(fpid.getProducer())) {
configBuilder.removeTransitiveDep(fpid);
}
return configBuilder.addFeaturePackDep(getIndexForDepToInstall(configBuilder, fpid.getProducer()), fpConfig);
}
// direct becomes transitive
configBuilder.removeFeaturePackDep(fpid.getLocation());
}
return configBuilder.addFeaturePackDep(fpConfig);
}
use of org.jboss.galleon.ProvisioningException 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