gnodet commented on code in PR #12430:
URL: https://github.com/apache/maven/pull/12430#discussion_r3541644175
##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/goals/CompatibilityFixStrategy.java:
##########
@@ -816,4 +848,193 @@ private Path findParentPomInMap(
.map(Map.Entry::getKey)
.orElse(null);
}
+
+ // ---- Warning-only checks for Maven 4 compatibility issues that cannot
be auto-fixed ----
+
+ /**
+ * Warns about plugins known to be incompatible with Maven 4 even at their
latest version.
+ * These plugins call methods on immutable API objects or use removed
internal APIs
+ * and require upstream fixes before they can work with Maven 4.
+ *
+ * @see <a href="https://github.com/apache/maven/issues/12432">#12432</a>
+ */
+ private void warnAboutIncompatiblePlugins(Document pomDocument,
UpgradeContext context) {
+ Element root = pomDocument.root();
+
+ Stream<Element> pluginContainers = Stream.concat(
+ // Root level build
+ root.childElement(BUILD).stream()
+ .flatMap(build -> Stream.concat(
+ build.childElement(PLUGINS).stream(),
+ build.childElement(PLUGIN_MANAGEMENT).stream()
+ .flatMap(pm ->
pm.childElement(PLUGINS).stream()))),
+ // Profile builds
+ root.childElement(PROFILES).stream()
+ .flatMap(profiles -> profiles.childElements(PROFILE))
+ .flatMap(profile ->
profile.childElement(BUILD).stream())
+ .flatMap(build -> Stream.concat(
+ build.childElement(PLUGINS).stream(),
+ build.childElement(PLUGIN_MANAGEMENT).stream()
+ .flatMap(pm ->
pm.childElement(PLUGINS).stream()))));
+
+ pluginContainers.forEach(pluginsElement -> pluginsElement
+ .childElements(PLUGIN)
+ .forEach(pluginElement -> {
+ String groupId =
pluginElement.childText(MavenPomElements.Elements.GROUP_ID);
+ String artifactId =
pluginElement.childText(MavenPomElements.Elements.ARTIFACT_ID);
+
+ if (groupId == null && artifactId != null &&
artifactId.startsWith(MAVEN_PLUGIN_PREFIX)) {
+ groupId = DEFAULT_MAVEN_PLUGIN_GROUP_ID;
+ }
+
+ if (groupId != null && artifactId != null) {
+ String pluginKey = groupId + ":" + artifactId;
+ String warning =
KNOWN_INCOMPATIBLE_PLUGINS.get(pluginKey);
+ if (warning != null) {
+ context.warning("Known Maven 4 incompatibility: "
+ pluginKey + " — " + warning);
+ }
+ }
+ }));
+ }
+
+ /**
+ * Warns about third-party repositories (non-Maven-Central) that may be
affected by
+ * Maven 4's prefix-based artifact filtering. When a repository does not
publish a
+ * {@code prefixes.txt} file, Maven 4 may auto-generate an incomplete
prefix list
+ * that blocks legitimate artifact resolution.
+ *
+ * @see <a href="https://github.com/apache/maven/issues/12433">#12433</a>
+ */
+ private void warnAboutThirdPartyRepositoryPrefixFiltering(Document
pomDocument, UpgradeContext context) {
+ Element root = pomDocument.root();
+
+ Stream<Element> repositoryContainers = Stream.concat(
+ Stream.of(
+ root.childElement(REPOSITORIES).orElse(null),
+
root.childElement(PLUGIN_REPOSITORIES).orElse(null))
+ .filter(Objects::nonNull),
+ root.childElement(PROFILES).stream()
+ .flatMap(profiles -> profiles.childElements(PROFILE))
+ .flatMap(profile -> Stream.of(
+
profile.childElement(REPOSITORIES).orElse(null),
+
profile.childElement(PLUGIN_REPOSITORIES)
+ .orElse(null))
+ .filter(Objects::nonNull)));
+
+ repositoryContainers.forEach(container -> {
+ String elementType = container.name().equals(REPOSITORIES) ?
REPOSITORY : PLUGIN_REPOSITORY;
+ container.childElements(elementType).forEach(repository -> {
+ String url = repository.childText("url");
+ String id = repository.childText("id");
+
+ if (url != null && !url.contains("${")) {
+ String normalizedUrl = url.trim().replaceAll("/+$", "");
+ if (!WELL_KNOWN_REPO_URLS.contains(normalizedUrl)) {
+ context.warning("Repository '" + (id != null ? id :
normalizedUrl)
+ + "' is a third-party repository. Maven 4's
prefix-based artifact"
+ + " filtering may block resolution if the
repository does not"
+ + " publish a prefixes.txt file. If builds
fail with"
+ + " 'ArtifactFilteredOutException', check
repository"
+ + " prefix configuration.");
+ }
+ }
Review Comment:
Agreed — this warning was too aggressive. After investigating the actual
Maven 4 behavior, the prefix filter defaults to **permissive** when no
`prefixes.txt` exists (`noInputOutcome=true`). Repositories without a prefix
index are not blocked at all.
The entire #12433 warning has been reverted in e1642cf. The real issue is
narrower (auto-discovered prefix files with incomplete content), and Maven
already provides per-repo disable options and helpful hints in
`ArtifactFilteredOutException` messages.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]