You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2024/05/01 14:21:10 UTC
(maven-plugin-tools) 01/01: [MPLUGIN-521] Nested types not properly extracted cause exception while generating Javadoc URLs
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch MPLUGIN-521
in repository https://gitbox.apache.org/repos/asf/maven-plugin-tools.git
commit f177ab782ecf81e77b5d076a361efc8d3d04c34b
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Wed May 1 16:20:16 2024 +0200
[MPLUGIN-521] Nested types not properly extracted cause exception while generating Javadoc URLs
This closes #281
---
.../plugin/generator/PluginDescriptorFilesGenerator.java | 12 ++++++++----
.../plugin/generator/PluginDescriptorFilesGeneratorTest.java | 4 ++++
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java
index 3f44f034..29718ebd 100644
--- a/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java
+++ b/maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java
@@ -625,7 +625,7 @@ public class PluginDescriptorFilesGenerator implements Generator {
}
}
- static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, String type) {
+ private static String extractbinaryNameForJavadoc(String type) {
final String binaryName;
int startOfParameterType = type.indexOf("<");
if (startOfParameterType != -1) {
@@ -637,10 +637,10 @@ public class PluginDescriptorFilesGenerator implements Generator {
.split(",\\s*");
switch (parameterTypes.length) {
case 1: // if only one parameter type, assume collection, first parameter type is most interesting
- binaryName = parameterTypes[0];
+ binaryName = extractbinaryNameForJavadoc(parameterTypes[0]);
break;
case 2: // if two parameter types assume map, second parameter type is most interesting
- binaryName = parameterTypes[1];
+ binaryName = extractbinaryNameForJavadoc(parameterTypes[1]);
break;
default:
// all other cases link to main type
@@ -649,7 +649,11 @@ public class PluginDescriptorFilesGenerator implements Generator {
} else {
binaryName = type;
}
- return javadocLinkGenerator.createLink(binaryName);
+ return binaryName;
+ }
+
+ static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, String type) {
+ return javadocLinkGenerator.createLink(extractbinaryNameForJavadoc(type));
}
/**
diff --git a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGeneratorTest.java b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGeneratorTest.java
index c58e9d20..eb35539e 100644
--- a/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGeneratorTest.java
+++ b/maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGeneratorTest.java
@@ -164,6 +164,10 @@ public class PluginDescriptorFilesGeneratorTest extends AbstractGeneratorTestCas
javadocBaseUri.resolve("java/lang/Integer.html"),
PluginDescriptorFilesGenerator.getJavadocUrlForType(
linkGenerator, "java.lang.Map<java.lang.String,java.lang.Integer>"));
+ assertEquals(
+ javadocBaseUri.resolve("java/lang/Integer.html"),
+ PluginDescriptorFilesGenerator.getJavadocUrlForType(
+ linkGenerator, "java.lang.Map<java.lang.String,java.util.List<java.lang.Integer>>"));
assertEquals(
javadocBaseUri.resolve("java/util/function/BiFunction.html"),
PluginDescriptorFilesGenerator.getJavadocUrlForType(