use of org.jboss.galleon.universe.FeaturePackLocation.FPID 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.universe.FeaturePackLocation.FPID in project galleon by wildfly.
the class PersistChangesTestBase method provisionedState.
@Override
protected ProvisionedState provisionedState() throws ProvisioningException {
final ProvisionedState.Builder builder = ProvisionedState.builder();
final FPID[] fpids = provisionedFpids();
if (fpids != null && fpids.length > 0) {
for (FPID fpid : fpids) {
builder.addFeaturePack(ProvisionedFeaturePack.forFPID(fpid));
}
final ProvisionedConfig[] configs = provisionedConfigModels();
if (configs != null && configs.length > 0) {
for (ProvisionedConfig config : configs) {
builder.addConfig(config);
}
}
}
return builder.build();
}
use of org.jboss.galleon.universe.FeaturePackLocation.FPID 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);
}
}
}
use of org.jboss.galleon.universe.FeaturePackLocation.FPID 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.universe.FeaturePackLocation.FPID 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