-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move to Java 17 and higher #173
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
135963f
Move to Java 17
jkosternl 4d735e3
Bump maven plugin dependencies
jkosternl 2ce1b21
Bump more deps
jkosternl 4d9c7bc
Upgrade Java for GitHub; upgrade setup-node, setup-java, bump version…
jkosternl 0300287
Merge branch 'master' into feature/171_moveToJDK17
jkosternl 8544aa5
Apply PR feedback; upgrade plugin
jkosternl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 39 additions & 72 deletions
111
frank-doc-doclet/src/test/java/org/frankframework/frankdoc/testdoclet/EasyDoclet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,54 @@ | ||
package org.frankframework.frankdoc.testdoclet; | ||
|
||
import com.sun.tools.javac.file.JavacFileManager; | ||
import com.sun.tools.javac.util.Context; | ||
import com.sun.source.util.DocTrees; | ||
import jdk.javadoc.doclet.Doclet; | ||
import jdk.javadoc.doclet.DocletEnvironment; | ||
import jdk.javadoc.internal.tool.AccessKind; | ||
import jdk.javadoc.internal.tool.JavadocTool; | ||
import jdk.javadoc.internal.tool.Messager; | ||
import jdk.javadoc.internal.tool.ToolOption; | ||
import jdk.javadoc.doclet.Reporter; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.extern.log4j.Log4j2; | ||
|
||
import javax.tools.StandardLocation; | ||
import java.io.File; | ||
import java.util.Collection; | ||
import java.util.EnumMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static java.nio.charset.StandardCharsets.UTF_8; | ||
import javax.lang.model.SourceVersion; | ||
import javax.lang.model.element.Element; | ||
import java.util.HashSet; | ||
import java.util.Locale; | ||
import java.util.Set; | ||
|
||
@Log4j2 | ||
@Getter | ||
public class EasyDoclet { | ||
final private File sourceDirectory; | ||
final private String[] packageNames; | ||
final private DocletEnvironment docletEnvironment; | ||
|
||
private static final AccessKind ACCESS_KIND = AccessKind.PUBLIC; | ||
|
||
public EasyDoclet(File sourceDirectory, String[] packageNames) { | ||
this.sourceDirectory = sourceDirectory; | ||
this.packageNames = packageNames; | ||
|
||
String sourcePath = getSourceDirectory().getAbsolutePath(); | ||
|
||
if (getSourceDirectory().exists()) { | ||
log.info("Using source path: [{}]", sourcePath); | ||
// compOpts.put("-sourcepath", getSourceDirectory().getAbsolutePath()); | ||
} else { | ||
log.error("Ignoring non-existing source path, check your source directory argument. Used: [{}]", sourcePath); | ||
} | ||
|
||
try { | ||
docletEnvironment = createDocletEnv(sourcePath, List.of(packageNames)); | ||
} catch (Exception e) { | ||
log.error(e); | ||
throw new RuntimeException(e); | ||
} | ||
public class EasyDoclet implements Doclet { | ||
@Getter | ||
private static DocTrees docTrees; | ||
@Getter | ||
private static Set<? extends Element> includedElements; | ||
@Getter @Setter | ||
private static String[] packages; | ||
|
||
@Override | ||
public void init(Locale locale, Reporter reporter) { | ||
log.debug("EasyDoclet.init start"); | ||
} | ||
|
||
private static DocletEnvironment createDocletEnv(String sourcePath, Collection<String> packageNames) throws Exception { | ||
|
||
// Create a context to hold settings for Javadoc. | ||
Context context = new Context(); | ||
|
||
// Pre-register a messager for the context. Not needed for Java 17! | ||
Messager.preRegister(context, EasyDoclet.class.getName()); | ||
|
||
// Set source path option for Javadoc. | ||
try (JavacFileManager fileManager = new JavacFileManager(context, true, UTF_8)) { | ||
|
||
fileManager.setLocation(StandardLocation.SOURCE_PATH, List.of(new File(sourcePath))); | ||
|
||
// JavadocLog.preRegister(context, "javadoc"); // Java 17 | ||
|
||
// Create an instance of Javadoc. | ||
JavadocTool javadocTool = JavadocTool.make0(context); | ||
@Override | ||
public String getName() { | ||
return "EasyDoclet"; | ||
} | ||
|
||
// Set up javadoc tool options. Not needed for Java 17! | ||
// ToolOption options = new ToolOption(context, log, null); // Java 17 ?? | ||
Map<ToolOption, Object> options = new EnumMap<>(ToolOption.class); | ||
options.put(ToolOption.SHOW_PACKAGES, ACCESS_KIND); | ||
options.put(ToolOption.SHOW_TYPES, ACCESS_KIND); | ||
options.put(ToolOption.SHOW_MEMBERS, ACCESS_KIND); | ||
options.put(ToolOption.SHOW_MODULE_CONTENTS, ACCESS_KIND); | ||
options.put(ToolOption.SUBPACKAGES, packageNames); | ||
@Override | ||
public Set<? extends Option> getSupportedOptions() { | ||
return new HashSet<>(); | ||
} | ||
|
||
// Invoke Javadoc and ask it for a DocletEnvironment containing the specified packages. | ||
return javadocTool.getEnvironment( | ||
options, // options | ||
List.of(), // java names | ||
List.of()); // java files | ||
} | ||
@Override | ||
public SourceVersion getSupportedSourceVersion() { | ||
return SourceVersion.RELEASE_11; | ||
jkosternl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
@Override | ||
public boolean run(DocletEnvironment environment) { | ||
log.debug("EasyDoclet.run start"); | ||
docTrees = environment.getDocTrees(); | ||
includedElements = environment.getIncludedElements(); | ||
log.debug("EasyDoclet.run: includedElements size = {}", includedElements.size()); | ||
jkosternl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I do that, I get the warning:
'org.apache.logging.log4j.util.Supplier' is deprecated
, so I'll leave it for now.