Skip to content

Commit ac50e07

Browse files
feat: restore JDK11 compatibility
Signed-off-by: Andreas Reichel <andreas@manticore-projects.com>
1 parent dea654d commit ac50e07

19 files changed

+228
-169
lines changed

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gradle" # Specify Gradle as the package manager
4+
directory: "/" # Root directory of your project
5+
schedule:
6+
interval: "weekly" # Define how often Dependabot should check for updates
7+
ignore:
8+
- dependency-name: "se.bjurr.gitchangelog.git-changelog-gradle-plugin"
9+
versions: ["*"] # This will ignore all versions for this specific plugin

build.gradle

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ plugins {
1919
id "org.owasp.dependencycheck" version "latest.release"
2020
id 'org.sonatype.gradle.plugins.scan' version "latest.release"
2121

22-
id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "latest.release"
22+
id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "2.0.0"
2323
id "org.hidetake.ssh" version "latest.release"
2424
}
2525

@@ -168,7 +168,7 @@ publishing {
168168
}
169169
developer {
170170
id = 'maca'
171-
name = 'Manoel Campos '
171+
name = 'Manoel Campos'
172172
email = ''
173173
}
174174
}
@@ -206,12 +206,9 @@ java {
206206
withSourcesJar()
207207
withJavadocJar()
208208

209-
sourceCompatibility = JavaVersion.VERSION_21
210-
targetCompatibility = JavaVersion.VERSION_21
209+
sourceCompatibility = JavaVersion.VERSION_11
210+
targetCompatibility = JavaVersion.VERSION_11
211211

212-
toolchain {
213-
languageVersion.set(JavaLanguageVersion.of(21))
214-
}
215212
modularity.inferModulePath = true
216213
}
217214

src/main/java/com/manticoreprojects/tools/xmldoclet/AnnotationParser.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,18 @@ protected AnnotationInstance parse(final Name programElement, final AnnotationM
7979
* @param argValue the value for an annotation argument
8080
*/
8181
private void parseAnnotationArgValue(final Name programElement, final AnnotationArgument arg, final Object argValue) {
82-
switch (argValue) {
83-
case AnnotationValue annotationValue -> {
84-
if (annotationValue.getValue() instanceof List<?> valueList) {
85-
parseAnnotationArgListValue(programElement, arg, valueList);
86-
} else arg.getValue().add(annotationValue.getValue().toString());
82+
if (argValue instanceof AnnotationValue) {
83+
AnnotationValue annotationValue = (AnnotationValue) argValue;
84+
if (annotationValue.getValue() instanceof List<?>) {
85+
List<?> valueList = (List<?>) annotationValue.getValue();
86+
parseAnnotationArgListValue(programElement, arg, valueList);
87+
} else {
88+
arg.getValue().add(annotationValue.getValue().toString());
8789
}
88-
case null -> {}
89-
default -> arg.getValue().add(argValue.toString());
90+
} else if (argValue != null) {
91+
arg.getValue().add(argValue.toString());
9092
}
93+
9194
}
9295

9396
/**
@@ -98,18 +101,21 @@ private void parseAnnotationArgValue(final Name programElement, final Annotation
98101
*/
99102
private void parseAnnotationArgListValue(final Name programElement, final AnnotationArgument arg, final List<?> valueList) {
100103
for (final Object value : valueList) {
101-
if (value instanceof AnnotationMirror annoDesc) {
104+
if (value instanceof AnnotationMirror) {
105+
AnnotationMirror annoDesc = (AnnotationMirror) value;
102106
arg.getAnnotation().add(parse(programElement, annoDesc));
103107
} else {
104108
/*
105-
Consider the annotation @Annotation1("A") or @Annotation1({"A", "B"}}).
109+
Consider the annotation @Annotation1("A") or @Annotation1({"A", "B"}).
106110
The annotation value is an AnnotationValue object with value attribute.
107111
This attribute is a List (even if there is a single value).
108112
But each value is not the actual value, but another AnnotationValue object with a value attribute.
109-
*/
110-
arg.getValue().add(((AnnotationValue) value).getValue().toString());
113+
*/
114+
AnnotationValue annotationValue = (AnnotationValue) value;
115+
arg.getValue().add(annotationValue.getValue().toString());
111116
}
112117
}
118+
113119
}
114120

115121
/**

src/main/java/com/manticoreprojects/tools/xmldoclet/CustomOption.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ public class CustomOption implements Doclet.Option {
2424
* If the option expectes a file name as parameter, the description may include the word "file"
2525
* to indicate that.
2626
*
27-
* <p>If the option has multiple parameters, this attribute should provide
28-
* a string representation of all of them, such as: file1 file2</p>
27+
* <p>
28+
* If the option has multiple parameters, this attribute should provide
29+
* a string representation of all of them, such as: file1 file2
30+
* </p>
2931
*/
3032
private final String parameters;
3133

@@ -34,6 +36,7 @@ public class CustomOption implements Doclet.Option {
3436
* The function can check the number of required arguments, try to convert them to the expected type
3537
* and perform any validation operation required.
3638
* If the arguments are valid, the Predicate must return true.
39+
*
3740
* @see #process(String, List)
3841
*/
3942
private final BiPredicate<String, List<String>> argumentsProcessor;
@@ -46,6 +49,7 @@ public class CustomOption implements Doclet.Option {
4649

4750
/**
4851
* Creates an Option with a single argument value and a given specification.
52+
*
4953
* @param argName the name of the single argument to be passed to the option, used in the help message
5054
*/
5155
public static CustomOption newOneArg(
@@ -58,12 +62,14 @@ public static CustomOption newOneArg(
5862
/**
5963
* Creates an Option with no arguments and a given specification
6064
*/
61-
public static CustomOption newNoArgs(final String name, final String description, final BiPredicate<String, List<String>> argumentsProcessor) {
65+
public static CustomOption newNoArgs(final String name, final String description,
66+
final BiPredicate<String, List<String>> argumentsProcessor) {
6267
return new CustomOption(name, description, "", 0, argumentsProcessor);
6368
}
6469

6570
/**
6671
* Creates an Option with a given specification and a default arguments processor.
72+
*
6773
* @param argName the name of the single argument to be passed to the option, used in the help message
6874
*/
6975
private CustomOption(final String name, final String description, final String argName, final int argumentCount) {
@@ -106,6 +112,7 @@ public Kind getKind() {
106112
/**
107113
* {@inheritDoc}
108114
* In the case of this class, the list has only one element, the single option name.
115+
*
109116
* @return a list with a single element containing the name of the option
110117
* @see #getName()
111118
*/
@@ -115,18 +122,19 @@ public List<String> getNames() {
115122
}
116123

117124
/**
118-
* {@return the name of the option}
119125
* This class provides a single name for the option.
120126
* Therefore, no alternative names are supported.
127+
*
128+
* @return the name of the option
121129
*/
122130
public String getName() {
123131
return name;
124132
}
125133

126134
/**
127-
* {@return a String with the name of the single parameter expected by the option (if any)}
128-
* The number of parameter for this option class can be 0 or 1, according to {@link #argumentCount}.
129-
* That is why this attribute is a single parameter name as a String.
135+
* @return a String with the name of the single parameter expected by the option (if any)
136+
* The number of parameter for this option class can be 0 or 1, according to {@link #argumentCount}.
137+
* That is why this attribute is a single parameter name as a String.
130138
*/
131139
@Override
132140
public String getParameters() {
@@ -136,6 +144,7 @@ public String getParameters() {
136144
/**
137145
* {@inheritDoc}
138146
* It must check if the given option arguments are valid.
147+
*
139148
* @param option {@inheritDoc}
140149
* @param arguments {@inheritDoc} received during the doclet execution
141150
* @return if the option has the expected number of arguments and they are valid

src/main/java/com/manticoreprojects/tools/xmldoclet/Parser.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private String getJavaDoc(final Element element) {
6464
}
6565

6666
/**
67-
* {@return the tags inside a JavaDoc comment}
67+
* @return the tags inside a JavaDoc comment
6868
*
6969
* @param element the Java element to get its JavaDoc tags
7070
*/
@@ -85,18 +85,27 @@ public Root parseRootDoc() {
8585
final Package packageNode = getPackage(rootNode, classDoc);
8686

8787
switch (classDoc.getKind()) {
88-
case ANNOTATION_TYPE -> packageNode.getAnnotation().add(parseAnnotationTypeDoc(classDoc));
89-
case ENUM -> packageNode.getEnum().add(parseEnum(classDoc));
90-
case INTERFACE -> packageNode.getInterface().add(parseInterface(classDoc));
91-
default -> packageNode.getClazz().add(parseClass(classDoc));
88+
case ANNOTATION_TYPE:
89+
packageNode.getAnnotation().add(parseAnnotationTypeDoc(classDoc));
90+
break;
91+
case ENUM:
92+
packageNode.getEnum().add(parseEnum(classDoc));
93+
break;
94+
case INTERFACE:
95+
packageNode.getInterface().add(parseInterface(classDoc));
96+
break;
97+
default:
98+
packageNode.getClazz().add(parseClass(classDoc));
99+
break;
92100
}
93101
}
94102

103+
95104
return rootNode;
96105
}
97106

98107
/**
99-
* {@return the package node for the given class element}
108+
* @return the package node for the given class element
100109
*
101110
* @param rootNode
102111
* @param classElement class to get its package
@@ -546,7 +555,7 @@ protected TagInfo parseTag(final DocTree tagDoc) {
546555
}
547556

548557
/**
549-
* {@return string representation of the element scope}
558+
* @return string representation of the element scope
550559
*
551560
* @param doc the element to get its scope
552561
*/

src/main/java/com/manticoreprojects/tools/xmldoclet/SupportedOptions.java

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,19 @@ final class SupportedOptions {
2727

2828
public SupportedOptions() {
2929
this.supportedOptionsSet = Set.of(
30-
newArgOption("d", "directory", "Destination directory for output file.\nDefault: ."),
31-
newArgOption("docencoding", "encoding", "Encoding of the output file.\nDefault: UTF8"),
32-
newNoArgOption("dryrun", "Parse javadoc, but don't write output file.\nDefault: false"),
33-
newNoArgOption("rst", "Transform the XML into a Restructured Text file (*.rst).\nDefault: false"),
34-
newNoArgOption("md", "Transform the XML into a Markdown file (*.md).\nDefault: false"),
35-
newNoArgOption("docbook", "Transform the XML into a DocBook file (*.db.xml).\nDefault: false"),
36-
newNoArgOption("adoc", "Transform the XML into an Ascii Doctor file (*.adoc).\nDefault: false"),
37-
newOneArgOption("filename", "Name of the output file.\nDefault: javadoc.xml"),
38-
newOneArgOption("basePackage", "Name of the base package.\n"),
39-
newOneArgOption("doctitle", "Document Title\n"),
40-
newOneArgOption("windowtitle", "Window Title\n"),
41-
newNoArgOption("noTimestamp", "No Timestamp.\n"),
42-
newNoArgOption("withFloatingToc", "Renders a Floating TOC on the right side.\n")
43-
);
30+
newArgOption("d", "directory", "Destination directory for output file.\nDefault: ."),
31+
newArgOption("docencoding", "encoding", "Encoding of the output file.\nDefault: UTF8"),
32+
newNoArgOption("dryrun", "Parse javadoc, but don't write output file.\nDefault: false"),
33+
newNoArgOption("rst", "Transform the XML into a Restructured Text file (*.rst).\nDefault: false"),
34+
newNoArgOption("md", "Transform the XML into a Markdown file (*.md).\nDefault: false"),
35+
newNoArgOption("docbook", "Transform the XML into a DocBook file (*.db.xml).\nDefault: false"),
36+
newNoArgOption("adoc", "Transform the XML into an Ascii Doctor file (*.adoc).\nDefault: false"),
37+
newOneArgOption("filename", "Name of the output file.\nDefault: javadoc.xml"),
38+
newOneArgOption("basePackage", "Name of the base package.\n"),
39+
newOneArgOption("doctitle", "Document Title\n"),
40+
newOneArgOption("windowtitle", "Window Title\n"),
41+
newNoArgOption("noTimestamp", "No Timestamp.\n"),
42+
newNoArgOption("withFloatingToc", "Renders a Floating TOC on the right side.\n"));
4443
}
4544

4645
public Set<CustomOption> get() {
@@ -49,6 +48,7 @@ public Set<CustomOption> get() {
4948

5049
/**
5150
* Creates an option with one argument that has the same name of the option itself.
51+
*
5252
* @param optionName name of the option and its own single argument
5353
* @param description option description
5454
*/
@@ -58,6 +58,7 @@ private CustomOption newOneArgOption(final String optionName, final String descr
5858

5959
/**
6060
* Creates an option with one argument.
61+
*
6162
* @param optionName name of the option
6263
* @param argName name of the argument to be passed to the option, used in the help message
6364
* @param description option description
@@ -67,55 +68,55 @@ private CustomOption newArgOption(final String optionName, final String argName,
6768
}
6869

6970
private CustomOption newNoArgOption(final String optionName, final String description) {
70-
return CustomOption.newNoArgs(optionName, description, this::processNoArgValue);
71+
return CustomOption.newNoArgs(optionName, description, (optionName1, argValues) -> processNoArgValue(optionName1));
7172
}
7273

7374
/**
7475
* Process and stores name of the option in the {@link #givenCliOptionsMap} to indicate it was sucessfully
7576
* processed (since it has no arguments and no validation is required).
77+
*
7678
* @param optionName name of the option to store the argument value
77-
* @param argValues list of arguments values for the option, which will be empty and ignored,
78-
* since the option doesn't expect any argument.
7979
* @return true to indicate the option was successfully processed.
8080
*/
81-
private boolean processNoArgValue(final String optionName, final List<String> argValues){
81+
private boolean processNoArgValue(final String optionName) {
8282
givenCliOptionsMap.put(addHyphenPrefix(optionName), null);
8383
return true;
8484
}
8585

8686
/**
8787
* Process and stores the first argument value passed in the command line for a given option
8888
* when that option is being processed by {@link CustomOption#process(String, List)}.
89+
*
8990
* @param optionName name of the option to store the argument value
9091
* @param argValues list of arguments to get the first value to store
9192
* @return true if there was one argument value in the argument list, false otherwise, indicating no value was stored
9293
*/
93-
private boolean processFirstArgValue(final String optionName, final List<String> argValues){
94-
if (argValues.isEmpty()){
94+
private boolean processFirstArgValue(final String optionName, final List<String> argValues) {
95+
if (argValues.isEmpty()) {
9596
return false;
9697
}
9798

98-
givenCliOptionsMap.put(addHyphenPrefix(optionName), argValues.getFirst());
99+
givenCliOptionsMap.put(addHyphenPrefix(optionName), argValues.get(0));
99100
return true;
100101
}
101102

102-
public boolean hasOption(final String optionName){
103+
public boolean hasOption(final String optionName) {
103104
return givenCliOptionsMap.containsKey(addHyphenPrefix(optionName));
104105
}
105106

106-
public String getOptionValue(final CustomOption option){
107+
public String getOptionValue(final CustomOption option) {
107108
return getOptionValue(option.getName());
108109
}
109110

110-
public String getOptionValue(final String optionName){
111+
public String getOptionValue(final String optionName) {
111112
return getOptionValue(optionName, "");
112113
}
113114

114-
public String getOptionValue(final CustomOption option, final String defaultValue){
115+
public String getOptionValue(final CustomOption option, final String defaultValue) {
115116
return getOptionValue(option.getName(), defaultValue);
116117
}
117118

118-
public String getOptionValue(final String optionName, final String defaultValue){
119+
public String getOptionValue(final String optionName, final String defaultValue) {
119120
return givenCliOptionsMap.getOrDefault(addHyphenPrefix(optionName), defaultValue);
120121
}
121122

0 commit comments

Comments
 (0)