Skip to content

Commit 789315b

Browse files
committed
[MPLUGIN-521] Nested types not properly extracted cause exception while generating Javadoc URLs
This closes #281
1 parent 1fa1805 commit 789315b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

maven-plugin-tools-generators/src/main/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGenerator.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ protected void writeParameterType(
625625
}
626626
}
627627

628-
static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, String type) {
628+
private static String extractBinaryNameForJavadoc(String type) {
629629
final String binaryName;
630630
int startOfParameterType = type.indexOf("<");
631631
if (startOfParameterType != -1) {
@@ -637,10 +637,10 @@ static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, Strin
637637
.split(",\\s*");
638638
switch (parameterTypes.length) {
639639
case 1: // if only one parameter type, assume collection, first parameter type is most interesting
640-
binaryName = parameterTypes[0];
640+
binaryName = extractBinaryNameForJavadoc(parameterTypes[0]);
641641
break;
642642
case 2: // if two parameter types assume map, second parameter type is most interesting
643-
binaryName = parameterTypes[1];
643+
binaryName = extractBinaryNameForJavadoc(parameterTypes[1]);
644644
break;
645645
default:
646646
// all other cases link to main type
@@ -649,7 +649,11 @@ static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, Strin
649649
} else {
650650
binaryName = type;
651651
}
652-
return javadocLinkGenerator.createLink(binaryName);
652+
return binaryName;
653+
}
654+
655+
static URI getJavadocUrlForType(JavadocLinkGenerator javadocLinkGenerator, String type) {
656+
return javadocLinkGenerator.createLink(extractBinaryNameForJavadoc(type));
653657
}
654658

655659
/**

maven-plugin-tools-generators/src/test/java/org/apache/maven/tools/plugin/generator/PluginDescriptorFilesGeneratorTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ void testGetJavadocUrlForType() throws URISyntaxException {
164164
javadocBaseUri.resolve("java/lang/Integer.html"),
165165
PluginDescriptorFilesGenerator.getJavadocUrlForType(
166166
linkGenerator, "java.lang.Map<java.lang.String,java.lang.Integer>"));
167+
assertEquals(
168+
javadocBaseUri.resolve("java/lang/Integer.html"),
169+
PluginDescriptorFilesGenerator.getJavadocUrlForType(
170+
linkGenerator, "java.lang.Map<java.lang.String,java.util.List<java.lang.Integer>>"));
167171
assertEquals(
168172
javadocBaseUri.resolve("java/util/function/BiFunction.html"),
169173
PluginDescriptorFilesGenerator.getJavadocUrlForType(

0 commit comments

Comments
 (0)