Skip to content

Commit

Permalink
Fix for Issue wildfly-extras#216, Evolve artifact upgrade to narrow u…
Browse files Browse the repository at this point in the history
…pgrade inside a feature-pack
  • Loading branch information
jfdenise committed Mar 17, 2021
1 parent 808141c commit ead3342
Show file tree
Hide file tree
Showing 10 changed files with 658 additions and 80 deletions.
23 changes: 19 additions & 4 deletions docs/guide/intro/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,16 @@ Each artifact version is the one that would get installed when building the Boot

The Maven artifacts to upgrade must be added to the `<dependencies>` of your Maven project (with a `provided` scope
to avoid the dependency to be added to your application). In addition, the plugin configuration element
`<overridden-server-artifacts>` must contain the artifacts. For example, the version 3.0.0 of `io.undertow:undertow-core` will
`<overridden-server-artifacts>` must contain the artifacts.

In order to narrow artifact upgrade inside a Galleon feature-pack, the `<FeaturePack>` configuration element is evolved
with an `<overridden-artifacts>` set that contains the artifacts (JBoss Modules module
artifacts only) that are in use for the upgrade. These artifacts are upgraded only in the feature-pack that define them.
A `<Feature-Pack>` element can be added to the pom.xml as a dependency only. A dependency feature-pack
is used to override artifacts present in a dependency feature-pack.
Use the `<dependency>true</dependency>` element to create a dependency feature-pack .

For example, the version 3.0.0 of `io.undertow:undertow-core` will
replace the version referenced in the WildFly Galleon feature-pack used to build the bootable JAR:

[source,xml]
Expand Down Expand Up @@ -541,15 +550,21 @@ Some notes:
** The JBoss module runtime jar (jboss-modules.jar file).
** All jar artifacts referenced from JBoss Modules modules.
* If an overridden artifact is no present in the dependencies, then a failure occurs during build.
* If an overridden artifact is not present in the dependencies, then a failure occurs during build.
* An artifact upgraded to the same version as the one referenced in the Galleon feature-pack is not upgraded. In this case a warning is displayed during build.
* It is possible to downgrade an artifact to an older version. In this case a warning is displayed during build.
* An artifact is referenced in the `overridden-artifacts` by GroupId, Artifactid and optionally Classifier. Version is being retrieved from the Maven dependencies.
* An artifact is referenced in the `overridden-server-artifacts` by GroupId, Artifactid and optionally Classifier. Version is being retrieved from the Maven dependencies.
* An artifact presents in the `overridden-server-artifacts` list must be unique. Any duplicate will make the packaging to fail.
* An artifact is referenced in the `<FeaturePack>` `overridden-artifacts` by GroupId, ArtifactId, optionally Classifier and optionally Version.
Version is being retrieved from the Maven dependencies if not set. Being able to set the version allows to have
multiple artifacts with the same GA to be upgraded to different versions according to the feature-pack that contain them.
* An artifact presents in the `overridden-artifacts` list must be unique. Any duplicate will make the packaging to fail.
* An overridden artifact presents in the `<FeaturePack>` `overridden-artifacts` must be unique. Any duplicate will make the packaging to fail.
* Adding an overridden artifact that is not part of the provisioned server artifacts will lead to a failure during build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,23 @@ public class FeaturePack implements DependableCoordinate, ArtifactCoordinate {

private String includedDefaultConfig;

private boolean dependency;

private Boolean inheritPackages = false;
private List<String> excludedPackages = Collections.emptyList();
private List<String> includedPackages = Collections.emptyList();
private List<OverriddenArtifact> overriddenArtifacts = Collections.emptyList();

private Path path;

public boolean isDependency() {
return dependency;
}

public void setDependency(boolean dependency) {
this.dependency = dependency;
}

@Override
public String getGroupId() {
return groupId;
Expand Down Expand Up @@ -151,6 +162,14 @@ public void setIncludedPackages(List<String> includedPackages) {
this.includedPackages = includedPackages;
}

public List<OverriddenArtifact> getOverridenArtifacts() {
return overriddenArtifacts;
}

public void setOverridenArtifacts(List<OverriddenArtifact> overriddenArtifacts) {
this.overriddenArtifacts = overriddenArtifacts;
}

public void setPath(File path) {
assertPathLocation();
this.path = path.toPath().normalize();
Expand Down Expand Up @@ -204,6 +223,10 @@ public String toString() {
buf.append(" included-default-config=");
buf.append(includedDefaultConfig);
}
if (dependency) {
buf.append(" dependency=");
buf.append(dependency);
}
return buf.append('}').toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -389,6 +390,9 @@ public class AbstractBuildBootableJarMojo extends AbstractMojo {

private boolean forkCli;

// Exposed to MavenUpgrade
Map<FeaturePack, FeaturePackLocation> resolvedLocations = new IdentityHashMap<>();

// EE-9 specific
private Path provisioningMavenRepo;
private String jakartaTransformSuffix;
Expand Down Expand Up @@ -854,7 +858,15 @@ private GalleonConfig buildFeaturePacksConfig(ProvisioningManager pm, boolean ha
} else {
fpl = FeaturePackLocation.fromString(fp.getLocation());
}

// They will be used when computing the overridden artifacts per feature-pack.
if (!fp.getOverridenArtifacts().isEmpty()) {
resolvedLocations.put(fp, fpl);
}
// We are using dependencies only to convey overriden artifacts.
// Dependencies are upgraded as overridden artifacts not as dependency.
if (fp.isDependency()) {
continue;
}
final FeaturePackConfig.Builder fpConfig = FeaturePackConfig.builder(fpl);
fpConfig.setInheritConfigs(false);
if (fp.isInheritPackages() != null) {
Expand Down
Loading

0 comments on commit ead3342

Please sign in to comment.