Add missing AddDependency for jakarta.servlet.jsp-api in JSP migration#1032
Merged
steve-aom-elliott merged 5 commits intomainfrom Mar 30, 2026
Merged
Add missing AddDependency for jakarta.servlet.jsp-api in JSP migration#1032steve-aom-elliott merged 5 commits intomainfrom
steve-aom-elliott merged 5 commits intomainfrom
Conversation
The JavaxJspToJakartaJsp recipe renames javax.servlet.jsp imports to jakarta.servlet.jsp via ChangePackage, and uses ChangeDependency to migrate explicit javax.servlet.jsp-api declarations. However, when the JSP API is only available as a transitive dependency (common in Gradle projects), ChangeDependency finds nothing to change while ChangePackage still renames the imports, leaving unresolvable jakarta.servlet.jsp references. This adds an AddDependency entry matching the pattern already used by JavaxServletToJakartaServlet and JavaxMailToJakartaMail, ensuring the jakarta.servlet.jsp-api dependency is added when JSP types are used even if the original dependency was transitive.
- Fix copyright year to 2026 - Simplify test assertions by collapsing redundant checks - Use testParserClasspath + classpathFromResources instead of testRuntimeOnly, consistent with other tests like JavaxServletToJakartaServletTest - Regenerate test type table to include javax.servlet.jsp-api-2.3.3 - Fix onlyIfUsing pattern from javax.servlet.jsp.* to javax.servlet.jsp..* to cover nested packages like javax.servlet.jsp.tagext
2 tasks
timtebeek
approved these changes
Mar 30, 2026
- Add upgradesJakartaJspApiDependencyIfAlreadyExistingAtLowerVersion test for the UpgradeDependencyVersion path - Add noChangeIfAlreadyOnJakartaJspApi test verifying no modifications when already on jakarta with target version - Tighten pom assertions to match groupId+artifactId+version together as a contiguous pattern, ensuring version numbers belong to the correct artifact
Verifies that AddDependency correctly adds jakarta.servlet.jsp-api when running against a Gradle project where the javax JSP dependency is only available transitively, matching the customer's actual build tool.
The tests verify that AddDependency fires when JSP types are used in source but no explicit javax.servlet.jsp-api dependency is declared, not necessarily that the dependency exists transitively. Rename to 'WhenNoExplicitJspDependencyDeclared' which accurately describes the customer scenario (JSP API provided by container jars in WEB-INF/lib).
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
JavaxJspToJakartaJsprecipe usesChangeDependencyto migrate explicitjavax.servlet.jsp-apideclarations andChangePackageto rename imports, but has noAddDependencyfallbackChangeDependencydoes nothing whileChangePackagestill renames imports tojakarta.servlet.jsp.*, leaving unresolvable referencesAddDependencyentry matching the pattern already used byJavaxServletToJakartaServletandJavaxMailToJakartaMailFixes compile errors like:
Test plan
addsJakartaJspApiDependencyIfJavaxJspApiOnlyExistsInTransitive— verifies the dependency is added when JSP types are used but no explicit javax JSP dependency existsswitchesJavaxJspApiDependencyToJakartaJspApiDependency— verifies existing explicit dependency migration still works