Skip to content

Commit

Permalink
Merge pull request #20 from mnlipp/wip/copy-and-adapt
Browse files Browse the repository at this point in the history
Simplify invocation
  • Loading branch information
mnlipp committed Sep 25, 2023
2 parents 299a89c + af9cb4a commit 11d7ba3
Show file tree
Hide file tree
Showing 29 changed files with 69 additions and 6,762 deletions.
6 changes: 3 additions & 3 deletions mdoclet/MDoclet-Test (Java 21).launch
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/mdoclet/src/org/jdrupes/mdoclet/internal/tool/Main.java"/>
<listEntry value="/mdoclet"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
<listEntry value="4"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21/"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.jdrupes.mdoclet.internal.tool.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="jdk.javadoc.internal.tool.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="mdoclet"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="--add-exports=jdk.javadoc/org.jdrupes.mdoclet.internal.tool=ALL-UNNAMED&#10;--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED&#10;-doclet org.jdrupes.mdoclet.MDoclet --disable-auto-highlight -Xdoclint:-html&#10;-overview testfiles/overview.md -d build/testfiles testfiles/test/Test.java testfiles/test/MDocletExample.java"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="mdoclet"/>
Expand Down
43 changes: 40 additions & 3 deletions mdoclet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ task apidocs(type: JavaExec) {
'--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.doclint=ALL-UNNAMED']
classpath jar
'--add-exports=jdk.compiler/com.sun.tools.doclint=ALL-UNNAMED',
'--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED']
classpath sourceSets.main.compileClasspath

main = 'org.jdrupes.mdoclet.internal.tool.Main'
main = 'jdk.javadoc.internal.tool.Main'
args = ['-doctitle', 'JDrupes MDoclet',
'-use',
'-linksource',
Expand Down Expand Up @@ -137,6 +137,43 @@ task apidocs(type: JavaExec) {
ignoreExitValue true
}

configurations {
markdownDoclet {
extendsFrom sourceSets.main.compileClasspath
}
}

dependencies {
markdownDoclet files(tasks.jar)
}

task testJavadoc(type: Javadoc) {
dependsOn jar

source = fileTree(dir: 'testfiles', include: '**/*.java')
destinationDir = project.file("build/testfiles-gradle")
options.docletpath = configurations.markdownDoclet.files.asType(List)
options.doclet = 'org.jdrupes.mdoclet.MDoclet'
options.overview = 'testfiles/overview.md'
options.addStringOption('Xdoclint:-html', '-quiet')

options.setJFlags([
'--add-exports=jdk.internal.opt/jdk.internal.opt=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.doclint=ALL-UNNAMED',
'--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED'])
}

check.dependsOn testJavadoc

task sourcesJar(type: Jar) {
from sourceSets.main.allJava
archiveClassifier = "sources"
Expand Down
41 changes: 12 additions & 29 deletions mdoclet/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Specify the Doclet on JavaDoc's command line:
-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
-J--add-exports=jdk.compiler/com.sun.tools.doclint=ALL-UNNAMED \
-J--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED \
-doclet org.jdrupes.mdoclet.MDoclet -docletpath /path/to/org.jdrupes.mdoclet.jar:another.jar</code></pre>
</div>

Expand Down Expand Up @@ -165,13 +166,18 @@ dependencies {
markdownDoclet "org.jdrupes.mdoclet:doclet:4.0.0"
}

task apidocs(type: JavaExec) {
task testJavadoc(type: Javadoc) {
enabled = JavaVersion.current() == JavaVersion.VERSION_21

dependsOn classes
inputs.file "overview.md"
source = fileTree(dir: 'testfiles', include: '**/*.java')
destinationDir = project.file("build/testfiles-gradle")
options.docletpath = configurations.markdownDoclet.files.asType(List)
options.doclet = 'org.jdrupes.mdoclet.MDoclet'
options.overview = 'testfiles/overview.md'
options.addStringOption('Xdoclint:-html', '-quiet')

jvmArgs = ['--add-exports=jdk.internal.opt/jdk.internal.opt=ALL-UNNAMED',
options.setJFlags([
'--add-exports=jdk.internal.opt/jdk.internal.opt=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
Expand All @@ -181,31 +187,8 @@ task apidocs(type: JavaExec) {
'--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.doclint=ALL-UNNAMED']
classpath sourceSets.main.compileClasspath
main = 'jdk.javadoc.internal.tool.Main'
args = ['-doctitle', "My Code",
'-overview', "overview.md",
'-use',
'-linksource',
'-link', 'https://docs.oracle.com/en/java/javase/21/docs/api/',
'--add-exports', 'jdk.internal.opt/jdk.internal.opt=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.doclint=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-exports', 'jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
'--add-exports', 'jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED',
'-doclet', 'org.jdrupes.mdoclet.MDoclet',
'-docletpath', configurations.markdownDoclet.files.asType(List).join(":"),
'-d', file("${project.buildDir}/javadoc"),
// Specify sources to be processed
]
'--add-exports=jdk.compiler/com.sun.tools.doclint=ALL-UNNAMED',
'--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED'])
}
</code></pre>

Expand Down
2 changes: 1 addition & 1 deletion mdoclet/src/org/jdrupes/mdoclet/MDocletEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject.Kind;

import org.jdrupes.mdoclet.internal.tool.DocEnvImpl;
import jdk.javadoc.internal.tool.DocEnvImpl;

import com.sun.source.util.DocTrees;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import javax.tools.DocumentationTool.DocumentationTask;

import org.jdrupes.mdoclet.internal.tool.Start;
import jdk.javadoc.internal.tool.Start;

import javax.tools.JavaFileObject;

Expand All @@ -57,17 +57,16 @@ public class JavadocTaskImpl implements DocumentationTask {
private final List<String> addModules = new ArrayList<>();

public JavadocTaskImpl(Context context,
Class<?> docletClass,
Iterable<String> options,
Iterable<? extends JavaFileObject> fileObjects)
{
Class<?> docletClass,
Iterable<String> options,
Iterable<? extends JavaFileObject> fileObjects) {
this.context = context;
this.docletClass = docletClass;

this.options = (options == null) ? Set.of()
: nullCheck(options);
: nullCheck(options);
this.fileObjects = (fileObjects == null) ? Set.of()
: nullCheck(fileObjects);
: nullCheck(fileObjects);
setLocale(Locale.getDefault());
}

Expand Down Expand Up @@ -105,13 +104,14 @@ public Boolean call() {
}

private void initContext() {
//initialize compiler's default locale
// initialize compiler's default locale
context.put(Locale.class, locale);
if (!addModules.isEmpty()) {
String names = String.join(",", addModules);
Options opts = Options.instance(context);
String prev = opts.get(Option.ADD_MODULES);
opts.put(Option.ADD_MODULES, (prev == null) ? names : prev + "," + names);
opts.put(Option.ADD_MODULES,
(prev == null) ? names : prev + "," + names);
}
}

Expand Down
4 changes: 2 additions & 2 deletions mdoclet/src/org/jdrupes/mdoclet/internal/api/JavadocTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;

import org.jdrupes.mdoclet.internal.tool.ToolOptions;
import jdk.javadoc.internal.tool.ToolOptions;

import com.sun.tools.javac.api.ClientCodeWrapper;
import com.sun.tools.javac.file.JavacFileManager;
Expand Down Expand Up @@ -161,7 +161,7 @@ public int run(InputStream in, OutputStream out, OutputStream err,
= new PrintWriter(err == null ? System.err : err, true);
PrintWriter out_pw = new PrintWriter(out == null ? System.out : out);
try {
return org.jdrupes.mdoclet.internal.tool.Main.execute(arguments,
return jdk.javadoc.internal.tool.Main.execute(arguments,
err_pw);
} finally {
err_pw.flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
import javax.tools.JavaFileManager.Location;

import org.jdrupes.mdoclet.internal.doclets.toolkit.util.Utils;
import org.jdrupes.mdoclet.internal.tool.DocEnvImpl;
import org.jdrupes.mdoclet.internal.tool.ToolEnvironment;
import jdk.javadoc.internal.tool.DocEnvImpl;
import jdk.javadoc.internal.tool.ToolEnvironment;

import com.sun.source.util.TreePath;
import com.sun.tools.javac.code.Flags;
Expand Down
40 changes: 0 additions & 40 deletions mdoclet/src/org/jdrupes/mdoclet/internal/tool/AccessKind.java

This file was deleted.

119 changes: 0 additions & 119 deletions mdoclet/src/org/jdrupes/mdoclet/internal/tool/DocEnvImpl.java

This file was deleted.

0 comments on commit 11d7ba3

Please sign in to comment.