use of org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec in project galleon by wildfly.
the class FeaturePackDepsConfigBuilder method getFeaturePackDepIndex.
public int getFeaturePackDepIndex(FeaturePackLocation fpl) throws ProvisioningException {
fpl = resolveUniverseSpec(fpl);
final ProducerSpec producer = fpl.getProducer();
final FeaturePackConfig fpDep = fpDeps.get(producer);
if (fpDep == null) {
throw new ProvisioningException(Errors.unknownFeaturePack(fpl.getFPID()));
}
if (!fpDep.getLocation().equals(fpl)) {
throw new ProvisioningException(Errors.unknownFeaturePack(fpl.getFPID()));
}
int i = 0;
for (ProducerSpec depProducer : fpDeps.keySet()) {
if (depProducer.equals(producer)) {
break;
}
i += 1;
}
return i;
}
use of org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec 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.ProducerSpec in project galleon by wildfly.
the class ProvisioningLayout method dependsOn.
private boolean dependsOn(F f, ProducerSpec dep, Set<ProducerSpec> visitedFps) throws ProvisioningException {
final FeaturePackSpec spec = f.getSpec();
if (!spec.hasFeaturePackDeps()) {
return false;
}
if (spec.hasFeaturePackDep(dep) || spec.hasTransitiveDep(dep)) {
return true;
}
for (FeaturePackConfig fpConfig : spec.getFeaturePackDeps()) {
final ProducerSpec producer = fpConfig.getLocation().getProducer();
if (!visitedFps.add(producer)) {
continue;
}
if (dependsOn(featurePacks.get(producer), dep, visitedFps)) {
return true;
}
visitedFps.remove(producer);
}
return false;
}
use of org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec 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();
}
use of org.jboss.galleon.universe.FeaturePackLocation.ProducerSpec in project galleon by wildfly.
the class ProvisioningPlan method update.
public ProvisioningPlan update(FeaturePackUpdatePlan fpPlan) throws ProvisioningDescriptionException {
final ProducerSpec producer = fpPlan.getInstalledLocation().getProducer();
if (install.containsKey(producer) || uninstall.contains(producer)) {
throw new ProvisioningDescriptionException(producer + " has already been added to the plan");
}
updates = CollectionUtils.putLinked(updates, producer, fpPlan);
return this;
}
Aggregations