Add apply-ifix goal for WebSphere Liberty iFix application - #2069
Open
takakiyo wants to merge 5 commits into
Open
Add apply-ifix goal for WebSphere Liberty iFix application#2069takakiyo wants to merge 5 commits into
takakiyo wants to merge 5 commits into
Conversation
Adds a new Maven goal 'apply-ifix' that applies IBM WebSphere Liberty
iFix JAR files to the Liberty runtime installation.
Key features:
- Enabled only when <applyLibertyiFix>true</applyLibertyiFix> is set
- Reads iFix JARs from <libertyifixDir> (default:
${project.basedir}/src/main/liberty/ifixes)
- Validates the iFix target version against the installed Liberty version
by reading the 'Applies-To' attribute in META-INF/MANIFEST.MF
- Only supports WebSphere Liberty (runtimeArtifact groupId must be
com.ibm.websphere.appserver.runtime); direct installDirectory
configuration is not supported
- <stopOniFixApplyError> (default: true) controls whether errors fail
the build or are reported as warnings
- Registered in the liberty-assembly lifecycle prepare-package phase
after install-feature
Signed-off-by: IBM Developer
In dev mode (liberty:dev), call runLibertyMojoApplyIfix() immediately after runLibertyMojoInstallFeature() in two places: 1. Server startup path: when features are installed before the server is first started (!container && (!skipInstallFeature || isNewInstallation)) 2. pom.xml change-detection path: when installFeature flag is set during a live reload cycle The call is always issued; ApplyIfixMojo.execute() exits immediately when applyLibertyiFix=false (the default), so there is no overhead unless the feature is explicitly enabled.
When dev goal invokes apply-ifix via mojo-executor, getPluginGoalConfig() passes the merged plugin <configuration> to validateConfiguration(). Without a case for 'liberty-maven-plugin:apply-ifix' the switch fell through to default, leaving the raw <runtimeArtifact> alias element in the config DOM. Maven then fails with 'Cannot find runtimeArtifact in ApplyIfixMojo' because the field is named assemblyArtifact (runtimeArtifact is only an @parameter alias). Fix: add APPLY_IFIX_PARAMS list and a dedicated switch case that calls convertLibertyAlias() (to rename runtimeArtifact -> assemblyArtifact) and stripConfigElements() to retain only the parameters relevant to apply-ifix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request adds a new Maven goal
apply-ifixto the Liberty Maven Plugin thatautomates the application of IBM WebSphere Liberty iFix JAR files to the Liberty runtime
installation during the build lifecycle.
Motivation
WebSphere Liberty iFix JARs (e.g.
250012-wlp-archive-IFPH69485.jar) are security andbug-fix patches distributed by IBM. Previously, users had to apply them manually by running
java -jar <ifix>.jar --installLocation <wlp-dir>outside the Maven build. This changeintegrates that step into the standard Liberty Maven Plugin lifecycle so that iFix application
becomes a reproducible, automated part of the build.
Changes
New file:
liberty-maven-plugin/.../server/ApplyIfixMojo.javaImplements the
apply-ifixgoal as a subclass ofPluginConfigSupport.Key behaviour:
applyLibertyiFix=false). No work is done unless the user explicitly opts in.runtimeArtifactgroupIdmust becom.ibm.websphere.appserver.runtime. Open Liberty and pre-installed (installDirectory) configurations are not supported; both cases are handled according tostopOniFixApplyError.productVersionfield from theApplies-Toattribute inMETA-INF/MANIFEST.MFis compared against the installed Liberty version read fromlib/versions/*.properties(com.ibm.websphere.productVersion). A mismatch is treated as an error.libertyifixDir(default:${project.basedir}/src/main/liberty/ifixes) by invokingjava -jar <ifix>.jar --installLocation <installDirectory>via the AntJavatask, consistent with the existinginstallLicense()pattern inBasicSupport.stopOniFixApplyError(defaulttrue):true→MojoExecutionException(build fails);false→ WARNING (build continues).New
@Parameterannotations:applyLibertyiFixfalselibertyifixDir${project.basedir}/src/main/liberty/ifixesstopOniFixApplyErrortrueModified:
StartDebugMojoSupport.javaAdded
runLibertyMojoApplyIfix()helper method following the same pattern as the existingrunLibertyMojoInstallFeature()andrunLibertyMojoDeploy()helpers.Modified:
DevMojo.javarunLibertyMojoApplyIfix()is called immediately afterrunLibertyMojoInstallFeature()in two places:installFeatureflag is raised during a live reload cycleThe call is unconditional;
ApplyIfixMojo.execute()exits immediately whenapplyLibertyiFix=false(the default), so there is no overhead for users who do not enable the feature.Modified:
ExecuteMojoUtil.javaAdded
APPLY_IFIX_PARAMSlist and aliberty-maven-plugin:apply-ifixcase invalidateConfiguration(). Without this, the mojo-executor path used bydevmode passed the raw<runtimeArtifact>alias element through toApplyIfixMojo, causing Maven to fail with "Cannot find 'runtimeArtifact' in class ApplyIfixMojo" (the field is namedassemblyArtifact;runtimeArtifactis only a@Parameteralias). The new case callsconvertLibertyAlias()andstripConfigElements()consistently with the other Liberty goals.Modified:
META-INF/plexus/components.xmlAdded
liberty:apply-ifixto theprepare-packagephase of theliberty-assemblylifecycle, afterliberty:install-feature.New file:
docs/apply-ifix.mdUser-facing reference documentation in the same format as existing goal docs. Covers all parameters, the iFix JAR naming convention, version validation behaviour, and three usage examples.
Modified:
README.mdapply-ifixto the goals table (alphabetical order).liberty-assemblylifecycle phase table to includeliberty:apply-ifixin theprepare-packagerow.Testing
Verified with a
liberty-assemblyproject usingcom.ibm.websphere.appserver.runtime:wlp-kernel:25.0.0.12and two test iFix JARs (250012-wlp-archive-IFPH69485.jar,250012-wlp-archive-IFPH70327.jar):./mvnw clean installpasses with both iFix JARs applied successfully duringprepare-package.ci.maven(./mvnw install) pass with 0 failures.Example Configuration
Place iFix JAR files under
src/main/liberty/ifixes/. They will be applied automatically duringprepare-packageafter features are installed.