Skip to content

Commit

Permalink
Merge pull request #379 from jfdenise/9.x-remove-upgrade
Browse files Browse the repository at this point in the history
[9.x] remove upgrade
  • Loading branch information
jfdenise authored Dec 13, 2023
2 parents ccddc98 + 398484c commit 68538a0
Show file tree
Hide file tree
Showing 25 changed files with 4 additions and 1,891 deletions.
74 changes: 0 additions & 74 deletions docs/guide/intro/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -563,80 +563,6 @@ It is possible to configure the plugin to use https://github.com/wildfly-extras/
</channels>
----

[[wildfly_jar_advanced_upgrade]]
### Upgrading a bootable JAR

This Feature is deprecated. It is going to be replaced by the usage of WildFly Channels.

NB: This feature can't be used when WildFly Channels are configured.

The artifacts referenced from JBoss Modules modules and Galleon feature-packs dependencies can be overridden when building a bootable JAR. This mechanism is based on Maven
dependencies resolution.

The set of artifacts that can be upgraded can be retrieved by setting the parameter `<dump-original-artifacts>true</dump-original-artifacts>` or
the system property `bootable.jar.dump.original.artifacts` to true when building a bootable JAR.
The file `target/bootable-jar-build-artifacts/bootable-jar-server-original-artifacts.xml` is generated.
It contains XML elements for the Galleon feature-packs dependencies, JBoss Modules runtime and artifacts.
JBoss Modules modules artifacts are grouped by JBoss Modules name.
The generated file contains only the artifacts that are provisioned by Galleon.
Each artifact version is the one that would get installed when building the Bootable JAR without upgrade.

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
replace the version referenced in the WildFly Galleon feature-pack used to build the bootable JAR:

[source,xml]
----
<dependencies>
...
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
<scope>provided</scope>
<version>3.0.0</version>
</dependency>
...
</dependencies>
...
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-jar-maven-plugin</artifactId>
<configuration>
<overridden-server-artifacts>
<artifact>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
</artifact>
</overridden-server-artifacts>
...
----

Some notes:

* The server jar components that can be upgraded are:
** 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.
* 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-server-artifacts` by GroupId, Artifactid and optionally Classifier. Version is being retrieved from the Maven dependencies if not set
in the overridden artifact.
* An artifact presents in the `overridden-server-artifacts` list 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.
* Adding an overridden Galleon feature-pack artifact that is not a dependency of the WildFly server being
provisioned will lead to an error during packaging.
* Third party galleon feature-packs (eg: keycloak Galleon feature-pack) benefit from this upgrade capability
for JBoss Modules modules artifacts they are bringing to the provisioned server.
[[wildfly_jar_troubleshooting]]
## Troubleshooting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
import org.wildfly.plugins.bootablejar.maven.cli.RemoteCLIExecutor;
import org.wildfly.plugins.bootablejar.maven.common.FeaturePack;
import org.wildfly.plugins.bootablejar.maven.common.MavenRepositoriesEnricher;
import org.wildfly.plugins.bootablejar.maven.common.OverriddenArtifact;
import org.wildfly.plugins.bootablejar.maven.common.Utils;
import org.wildfly.plugins.bootablejar.maven.common.Utils.ProvisioningSpecifics;
import org.wildfly.security.manager.WildFlySecurityManager;
Expand Down Expand Up @@ -316,49 +315,6 @@ public abstract class AbstractBuildBootableJarMojo extends AbstractMojo {
@Parameter(alias = "bootable-jar-build-artifacts", property = "wildfly.bootable.jar.build.artifacts", defaultValue = "bootable-jar-build-artifacts")
private String bootableJarBuildArtifacts;

/**
* Deprecated. A list of artifacts that override the one referenced in the WildFly
* Galleon feature-pack used to build the Bootable JAR. The artifacts
* present in this list must exist in the project dependencies (with a
* {@code provided} scope). GroupId and ArtifactId are mandatory.
* Classifier is required if non null. Version and Type are optional and are
* retrieved from the project dependencies. Dependencies on Galleon
* feature-pack can also be referenced from this list. {@code zip} type must be used for Galleon feature-packs.
* NB: This configuration item can't be used when Channels are in use.<br/>
* Example of an override of the {@code io.undertow:undertow-core}
* artifact:<br/>
* &lt;overridden-server-artifacts&gt;<br/>
* &lt;artifact&gt;<br/>
* &lt;groupId&gt;io.undertow&lt;/groupId&gt;<br/>
* &lt;artifactId&gt;undertow-core&lt;/artifactId&gt;<br/>
* &lt;/artifact&gt;<br/>
* &lt;/overridden-server-artifacts&gt;<br/>
*/
@Deprecated
@Parameter(alias = "overridden-server-artifacts")
List<OverriddenArtifact> overriddenServerArtifacts = Collections.emptyList();

/**
* Deprecated. Set this parameter to true in order to retrieve the set of artifacts that can be upgraded.
* The file `target/bootable-jar-build-artifacts/bootable-jar-server-original-artifacts.xml` is generated.
* It contains XML elements for the Galleon feature-packs dependencies, JBoss Modules runtime and artifacts.
* JBoss Modules modules artifacts are grouped by JBoss Modules name.
* The generated file contains only the artifacts that are provisioned by Galleon.
* Each artifact version is the one that would get installed when building the Bootable JAR without upgrade.
*/
@Deprecated
@Parameter(alias = "dump-original-artifacts", property = "bootable.jar.dump.original.artifacts" , defaultValue = "false")
boolean dumpOriginalArtifacts;

/**
* Deprecated. The plugin prints a warning when an overridden artifact is downgraded (updated to an older version).
* The version comparison is done based on Maven versioning. This warning can be disabled by setting this parameter to
* true.
*/
@Deprecated
@Parameter(alias = "disable-warn-for-artifact-downgrade", property = "bootable.jar.disable.warn.for.artifact.downgrade", defaultValue = "false")
boolean disableWarnForArtifactDowngrade;

/**
* When calling mvn 'install', the bootable JAR artifact is attached to the project with the classifier 'bootable'. Use this parameter to
* configure the classifier.
Expand Down Expand Up @@ -1021,8 +977,6 @@ private void normalizeFeaturePackList() throws MojoExecutionException {
if (featurePackLocation != null) {
if (isChannelsProvisioning()) {
featurePackLocation = formatLocation(featurePackLocation);
} else {
featurePackLocation = MavenUpgrade.locationWithVersion(featurePackLocation, artifactVersions);
}
featurePacks = new ArrayList<>();
FeaturePack fp = new FeaturePack();
Expand All @@ -1033,8 +987,6 @@ private void normalizeFeaturePackList() throws MojoExecutionException {
if (fp.getLocation() != null) {
if (isChannelsProvisioning()) {
fp.setLocation(formatLocation(fp.getLocation()));
} else {
fp.setLocation(MavenUpgrade.locationWithVersion(fp.getLocation(), artifactVersions));
}
} else {
if (fp.getGroupId() == null || fp.getArtifactId() == null) {
Expand Down Expand Up @@ -1122,21 +1074,6 @@ private Artifact provisionServer(Path home, Path outputProvisioningFile, Path wo
ProvisioningConfig config = buildGalleonConfig(pm, defaultConfig).buildConfig();
IoUtils.recursiveDelete(home);
getLog().info("Building server based on " + config.getFeaturePackDeps() + " galleon feature-packs");
MavenUpgrade mavenUpgrade = null;
if (isChannelsProvisioning()) {
if (!overriddenServerArtifacts.isEmpty()) {
throw new MojoExecutionException("overridden-server-artifacts can't be configured when channels are configured.");
}
} else {
mavenUpgrade = new MavenUpgrade(this, config, pm);
// Dump artifacts
if (dumpOriginalArtifacts) {
Path file = workDir.resolve("bootable-jar-server-original-artifacts.xml");
getLog().info("Dumping original Maven artifacts in " + file);
mavenUpgrade.dumpArtifacts(file);
}
config = mavenUpgrade.upgrade();
}
// store provisioning.xml
try(FileWriter writer = new FileWriter(outputProvisioningFile.toFile())) {
ProvisioningXmlWriter.getInstance().write(config, writer);
Expand All @@ -1159,7 +1096,7 @@ private Artifact provisionServer(Path home, Path outputProvisioningFile, Path wo
Artifact a = getArtifact(value);
if ( BOOT_ARTIFACT_ID.equals(a.getArtifactId())) {
// We got it.
getLog().info("Found boot artifact " + a + " in " + (mavenUpgrade == null ? fprt.getFPID() : mavenUpgrade.getMavenFeaturePack(fprt.getFPID())));
getLog().info("Found boot artifact " + a + " in " + fprt.getFPID() );
bootArtifact = a;
break;
}
Expand All @@ -1179,7 +1116,7 @@ private Artifact provisionServer(Path home, Path outputProvisioningFile, Path wo
if ("wildfly-cli".equals(a.getArtifactId())
&& "org.wildfly.core".equals(a.getGroupId())) {
// We got it.
debug("Found cli artifact %s in %s", a, (mavenUpgrade == null ? fprt.getFPID() : mavenUpgrade.getMavenFeaturePack(fprt.getFPID())));
debug("Found cli artifact %s in %s", a, fprt.getFPID());
cliArtifacts.add(new DefaultArtifact(a.getGroupId(), a.getArtifactId(), a.getVersion(), "provided", JAR,
"client", new DefaultArtifactHandler(JAR)));
continue;
Expand Down Expand Up @@ -1262,38 +1199,15 @@ private static void zipServer(Path home, Path contentDir) throws IOException {
zip(home, target);
}

private OverriddenArtifact getOverriddenArtifact(String grpId, String artifactId) {
OverriddenArtifact ret = null;
for (OverriddenArtifact art : overriddenServerArtifacts) {
if(art.getGroupId().equals(grpId) && art.getArtifactId().equals(artifactId)) {
ret = art;
break;
}
}
return ret;
}

private void buildJar(Path contentDir, Path jarFile, Artifact artifact) throws MojoExecutionException, IOException {
Path rtJarFile = resolveArtifact(artifact);
// Check if that is an older server for which we can't upgrade the jboss-modules dependency.
Path contentRoot = Paths.get(project.getBuild().getDirectory()).resolve(bootableJarBuildArtifacts);
Path tmpDir = contentRoot.resolve("tmp_runtime");
Files.createDirectories(tmpDir);
ZipUtils.unzip(rtJarFile, tmpDir);
OverriddenArtifact modules = getOverriddenArtifact(JBOSS_MODULES_GROUP_ID, JBOSS_MODULES_ARTIFACT_ID);
Path jbossModulesDependency = tmpDir.resolve("META-INF").resolve("maven").resolve(JBOSS_MODULES_GROUP_ID).
resolve(JBOSS_MODULES_ARTIFACT_ID).resolve("pom.xml");
if (Files.exists(jbossModulesDependency)) {
if (modules != null) {
getLog().warn("Bootable JAR dependency on jboss-modules can't be upgraded, you must use a more recent version of the server.");
}
} else {
if (modules != null) {
jbossModules.setVersion(modules.getVersion());
}
Path jbossModulesFile = resolveArtifact(jbossModules);
ZipUtils.unzip(jbossModulesFile, contentDir);
}
Path jbossModulesFile = resolveArtifact(jbossModules);
ZipUtils.unzip(jbossModulesFile, contentDir);
ZipUtils.unzip(rtJarFile, contentDir);
updateManifest(contentDir);
zip(contentDir, jarFile);
Expand Down
Loading

0 comments on commit 68538a0

Please sign in to comment.