Skip to content

Commit 9c672de

Browse files
Add javadoc links in Maven plugin parameter docs
This commit modifies the documentation generated for the Maven plugin to include links to javadoc when Spring Boot types are mentioned. Some javadoc was also polished to improve the generated docs. Fixes gh-21555
1 parent 6beb0c9 commit 9c672de

File tree

7 files changed

+92
-37
lines changed

7 files changed

+92
-37
lines changed

buildSrc/src/main/java/org/springframework/boot/build/mavenplugin/DocumentPluginGoals.java

+30-6
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,7 @@ private void writeParametersTable(PrintWriter writer, String detailsSectionId, L
136136
for (Parameter parameter : parameters) {
137137
String name = parameter.getName();
138138
writer.printf("| <<%s-%s,%s>>%n", detailsSectionId, name, name);
139-
String type = parameter.getType();
140-
if (type.lastIndexOf('.') >= 0) {
141-
type = type.substring(type.lastIndexOf('.') + 1);
142-
}
143-
writer.printf("| `%s`%n", type);
139+
writer.printf("| `%s`%n", typeNameToJavadocLink(shortTypeName(parameter.getType()), parameter.getType()));
144140
String defaultValue = parameter.getDefaultValue();
145141
if (defaultValue != null) {
146142
writer.printf("| `%s`%n", defaultValue);
@@ -166,7 +162,7 @@ private void writeParameterDetails(PrintWriter writer, List<Parameter> parameter
166162
writer.println("|===");
167163
writer.println();
168164
writeDetail(writer, "Name", name);
169-
writeDetail(writer, "Type", parameter.getType());
165+
writeDetail(writer, "Type", typeNameToJavadocLink(parameter.getType()));
170166
writeOptionalDetail(writer, "Default value", parameter.getDefaultValue());
171167
writeOptionalDetail(writer, "User property", parameter.getUserProperty());
172168
writeOptionalDetail(writer, "Since", parameter.getSince());
@@ -191,4 +187,32 @@ private void writeOptionalDetail(PrintWriter writer, String name, String value)
191187
writer.println();
192188
}
193189

190+
private String shortTypeName(String name) {
191+
if (name.lastIndexOf('.') >= 0) {
192+
name = name.substring(name.lastIndexOf('.') + 1);
193+
}
194+
if (name.lastIndexOf('$') >= 0) {
195+
name = name.substring(name.lastIndexOf('$') + 1);
196+
}
197+
return name;
198+
}
199+
200+
private String typeNameToJavadocLink(String name) {
201+
return typeNameToJavadocLink(name, name);
202+
}
203+
204+
private String typeNameToJavadocLink(String shortName, String name) {
205+
if (name.startsWith("org.springframework.boot.maven")) {
206+
return "{spring-boot-docs}/maven-plugin/api/" + typeNameToJavadocPath(name) + ".html[" + shortName + "]";
207+
}
208+
if (name.startsWith("org.springframework.boot")) {
209+
return "{spring-boot-docs}/api/" + typeNameToJavadocPath(name) + ".html[" + shortName + "]";
210+
}
211+
return shortName;
212+
}
213+
214+
private String typeNameToJavadocPath(String name) {
215+
return name.replace(".", "/").replace("$", ".");
216+
}
217+
194218
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractDependencyFilterMojo.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractMojo {
4040

4141
/**
4242
* Collection of artifact definitions to include. The {@link Include} element defines
43-
* a {@code groupId} and {@code artifactId} mandatory properties and an optional
43+
* mandatory {@code groupId} and {@code artifactId} properties and an optional
4444
* {@code classifier} property.
4545
* @since 1.2.0
4646
*/
@@ -49,7 +49,7 @@ public abstract class AbstractDependencyFilterMojo extends AbstractMojo {
4949

5050
/**
5151
* Collection of artifact definitions to exclude. The {@link Exclude} element defines
52-
* a {@code groupId} and {@code artifactId} mandatory properties and an optional
52+
* mandatory {@code groupId} and {@code artifactId} properties and an optional
5353
* {@code classifier} property.
5454
* @since 1.1.0
5555
*/

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractPackagerMojo.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
7575

7676
/**
7777
* The name of the main class. If not specified the first compiled class found that
78-
* contains a 'main' method will be used.
78+
* contains a {@code main} method will be used.
7979
* @since 1.0.0
8080
*/
8181
@Parameter
8282
private String mainClass;
8383

8484
/**
8585
* The type of archive (which corresponds to how the dependencies are laid out inside
86-
* it). Possible values are JAR, WAR, ZIP, DIR, NONE. Defaults to a guess based on the
87-
* archive type.
86+
* it). Possible values are {@code JAR}, {@code WAR}, {@code ZIP}, {@code DIR},
87+
* {@code NONE}. Defaults to a guess based on the archive type.
8888
* @since 1.0.0
8989
*/
9090
@Parameter(property = "spring-boot.repackage.layout")
@@ -114,7 +114,8 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo
114114
public boolean includeSystemScope;
115115

116116
/**
117-
* Layer configuration with the option to exclude layer tools jar.
117+
* Layer configuration with options to disable layer creation, exclude layer tools
118+
* jar, and provide a custom layers configuration file.
118119
* @since 2.3.0
119120
*/
120121
@Parameter
@@ -208,7 +209,7 @@ public enum LayoutType {
208209
ZIP(new Expanded()),
209210

210211
/**
211-
* Dir Layout.
212+
* Directory Layout.
212213
*/
213214
DIR(new Expanded()),
214215

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ public class BuildImageMojo extends AbstractPackagerMojo {
9898
private String classifier;
9999

100100
/**
101-
* Image configuration, with `builder`, `runImage`, `name`, `env`, `cleanCache` and
102-
* `verboseLogging` options.
101+
* Image configuration, with {@code builder}, {@code runImage}, {@code name},
102+
* {@code env}, {@code cleanCache} and {@code verboseLogging} options.
103103
* @since 2.3.0
104104
*/
105105
@Parameter

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class BuildInfoMojo extends AbstractMojo {
6262
private MavenProject project;
6363

6464
/**
65-
* The location of the generated build-info.properties.
65+
* The location of the generated {@code build-info.properties} file.
6666
*/
6767
@Parameter(defaultValue = "${project.build.outputDirectory}/META-INF/build-info.properties")
6868
private File outputFile;
@@ -77,8 +77,8 @@ public class BuildInfoMojo extends AbstractMojo {
7777
private String time;
7878

7979
/**
80-
* Additional properties to store in the build-info.properties. Each entry is prefixed
81-
* by {@code build.} in the generated build-info.properties.
80+
* Additional properties to store in the {@code build-info.properties} file. Each
81+
* entry is prefixed by {@code build.} in the generated {@code build-info.properties}.
8282
*/
8383
@Parameter
8484
private Map<String, String> additionalProperties;

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java

+47-17
Original file line numberDiff line numberDiff line change
@@ -37,48 +37,78 @@
3737
*/
3838
public class Image {
3939

40-
/**
41-
* The name of the created image.
42-
*/
4340
String name;
4441

45-
/**
46-
* The builder used to create the image.
47-
*/
4842
String builder;
4943

50-
/**
51-
* The run image used to launch the built image.
52-
*/
5344
String runImage;
5445

55-
/**
56-
* Environment properties that should be passed to the builder.
57-
*/
5846
Map<String, String> env;
5947

60-
/**
61-
* If the cache should be cleaned before building.
62-
*/
6348
boolean cleanCache;
6449

50+
boolean verboseLogging;
51+
6552
/**
66-
* If verbose logging is required.
53+
* The name of the created image.
54+
* @return the image name
6755
*/
68-
boolean verboseLogging;
56+
public String getName() {
57+
return this.name;
58+
}
6959

7060
void setName(String name) {
7161
this.name = name;
7262
}
7363

64+
/**
65+
* The name of the builder image to use to create the image.
66+
* @return the builder image name
67+
*/
68+
public String getBuilder() {
69+
return this.builder;
70+
}
71+
7472
void setBuilder(String builder) {
7573
this.builder = builder;
7674
}
7775

76+
/**
77+
* The name of the run image to use to create the image.
78+
* @return the builder image name
79+
*/
80+
public String getRunImage() {
81+
return this.runImage;
82+
}
83+
7884
void setRunImage(String runImage) {
7985
this.runImage = runImage;
8086
}
8187

88+
/**
89+
* Environment properties that should be passed to the builder.
90+
* @return the environment properties
91+
*/
92+
public Map<String, String> getEnv() {
93+
return this.env;
94+
}
95+
96+
/**
97+
* If the cache should be cleaned before building.
98+
* @return {@code true} if the cache should be cleaned
99+
*/
100+
public boolean isCleanCache() {
101+
return this.cleanCache;
102+
}
103+
104+
/**
105+
* If verbose logging is required.
106+
* @return {@code true} for verbose logging
107+
*/
108+
public boolean isVerboseLogging() {
109+
return this.verboseLogging;
110+
}
111+
82112
BuildRequest getBuildRequest(Artifact artifact, Function<Owner, TarArchive> applicationContent) {
83113
return customize(BuildRequest.of(getOrDeduceName(artifact), applicationContent));
84114
}

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Layers.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public class Layers {
3333
private File configuration;
3434

3535
/**
36-
* Whether a layers.idx file should be added to the jar.
37-
* @return true if a layers.idx file should be added.
36+
* Whether a {@code layers.idx} file should be added to the jar.
37+
* @return true if a {@code layers.idx} file should be added.
3838
*/
3939
public boolean isEnabled() {
4040
return this.enabled;

0 commit comments

Comments
 (0)