Skip to content

Commit

Permalink
Merge pull request #280 from aloubyansky/GAL-303
Browse files Browse the repository at this point in the history
[GAL-303] Overriding FPL of a transitive dep with Maven coords may fail
  • Loading branch information
aloubyansky authored Jan 6, 2020
2 parents ab2f1ff + cd8ed44 commit 1cc39d4
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
* Copyright 2016-2020 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -1056,8 +1056,10 @@ private void layout(FeaturePackDepsConfig config, Map<ProducerSpec, FPID> branch
continue;
}
if(fpl.isMavenCoordinates()) {
fpl = resolveFeaturePack(fpl, FeaturePackLayout.TRANSITIVE_DEP).getSpec().getFPID().getLocation();
final F f = resolveFeaturePack(fpl, FeaturePackLayout.TRANSITIVE_DEP);
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());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* Copyright 2016-2020 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.galleon.maven.noloc.test;

import org.jboss.galleon.ProvisioningDescriptionException;
import org.jboss.galleon.ProvisioningException;
import org.jboss.galleon.config.FeaturePackConfig;
import org.jboss.galleon.config.ProvisioningConfig;
import org.jboss.galleon.creator.FeaturePackCreator;
import org.jboss.galleon.state.ProvisionedFeaturePack;
import org.jboss.galleon.state.ProvisionedState;
import org.jboss.galleon.universe.FeaturePackLocation;
import org.jboss.galleon.universe.MvnUniverse;
import org.jboss.galleon.universe.ProvisionFromUniverseTestBase;

/**
*
* @author Alexey Loubyansky
*/
public class OverrideFplVersionOfTransitiveDepWithGavVariation2TestCase extends ProvisionFromUniverseTestBase {

private FeaturePackLocation template;
private FeaturePackLocation wfly;
private FeaturePackLocation servlet;
private FeaturePackLocation core;

@Override
protected void createProducers(MvnUniverse universe) throws ProvisioningException {
universe.createProducer("template");
universe.createProducer("wfly");
universe.createProducer("servlet");
universe.createProducer("core");
}

@Override
protected void createFeaturePacks(FeaturePackCreator creator) throws ProvisioningException {

template = newFpl("template", "1", "1.0.0.Final");

wfly = newFpl("wfly", "1", "1.0.0.Final");
servlet = newFpl("servlet", "1", "1.0.0.Final");
core = newFpl("core", "1", "1.0.0.Final");

creator.newFeaturePack()
.setFPID(template.getFPID())
.addDependency(toMavenCoordsFpl(wfly))
.addTransitiveDependency(toMavenCoordsFpl(servlet))
.addTransitiveDependency(toMavenCoordsFpl(core))
.newPackage("p1", true);

creator.newFeaturePack()
.setFPID(wfly.getFPID())
.addDependency(servlet)
.addTransitiveDependency(core)
.newPackage("p1", true);

creator.newFeaturePack()
.setFPID(servlet.getFPID())
.addDependency(core)
.newPackage("p1", true);

creator.newFeaturePack()
.setFPID(core.getFPID())
.newPackage("p1", true);
}

@Override
protected ProvisioningConfig provisioningConfig() throws ProvisioningDescriptionException {
return ProvisioningConfig.builder()
.addFeaturePackDep(FeaturePackConfig.forLocation(toMavenCoordsFpl(template)))
.build();
}

@Override
protected ProvisioningConfig provisionedConfig() throws ProvisioningDescriptionException {
return ProvisioningConfig.builder()
.addFeaturePackDep(FeaturePackConfig.forTransitiveDep(servlet))
.addFeaturePackDep(FeaturePackConfig.forTransitiveDep(core))
.addFeaturePackDep(FeaturePackConfig.forTransitiveDep(wfly))
.addFeaturePackDep(FeaturePackConfig.forLocation(template))
.build();
}

@Override
protected ProvisionedState provisionedState() throws ProvisioningException {
return ProvisionedState.builder()
.addFeaturePack(ProvisionedFeaturePack.builder(core.getFPID())
.addPackage("p1")
.build())
.addFeaturePack(ProvisionedFeaturePack.builder(servlet.getFPID())
.addPackage("p1")
.build())
.addFeaturePack(ProvisionedFeaturePack.builder(wfly.getFPID())
.addPackage("p1")
.build())
.addFeaturePack(ProvisionedFeaturePack.builder(template.getFPID())
.addPackage("p1")
.build())
.build();
}
}

0 comments on commit 1cc39d4

Please sign in to comment.