Skip to content

Commit

Permalink
Fix the Maven javadoc plugin configuration, and a couple of other thi…
Browse files Browse the repository at this point in the history
…ngs, to almost make it possible for asciidoclet to render its own javadoc.
  • Loading branch information
chrisvest committed Jul 16, 2019
1 parent 423e657 commit 2b91607
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 23 deletions.
21 changes: 14 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
</execution>
</executions>
</plugin>
<!-- tag::pom_include[] -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand All @@ -133,24 +132,32 @@
</executions>
<configuration>
<source>11</source>
<additionalJOption>-J--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED</additionalJOption>
<additionalJOptions>
<additionalJOption>--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=asciidoclet</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.parser=asciidoclet</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.tree=asciidoclet</additionalJOption>
<additionalJOption>--add-exports=jdk.compiler/com.sun.tools.javac.model=asciidoclet</additionalJOption>
<additionalJOption>-J--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED</additionalJOption>
<additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</additionalJOption>
<additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</additionalJOption>
<additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</additionalJOption>
</additionalJOptions>
<doclet>org.asciidoctor.asciidoclet.Asciidoclet</doclet>
<docletArtifact>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoclet</artifactId>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</docletArtifact>
<additionalOptions> <!--1-->
<additionalOptions>
--base-dir ${project.basedir}
--attribute "project_name=${project.name}"
--attribute "project_version=${project.version}"
--attribute "project_desc=${project.description}"
</additionalOptions>
<linksource>true</linksource>
<overview>src/main/java/overview.adoc</overview> <!--2-->
<overview>src/main/java/org/asciidoctor/asciidoclet/overview.adoc</overview>
</configuration>
</plugin>
<!-- end::pom_include[] -->
<plugin>
<groupId>com.mycila.maven-license-plugin</groupId>
<artifactId>maven-license-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public URI toUri()
@Override
public String getName()
{
return fileObject.getName();
return fileObject.getName() + ".html";
}

@Override
Expand Down
29 changes: 19 additions & 10 deletions src/main/java/org/asciidoctor/asciidoclet/DocletOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.asciidoctor.asciidoclet;

import jdk.javadoc.doclet.DocletEnvironment;
import jdk.javadoc.doclet.Reporter;

import java.io.File;
Expand Down Expand Up @@ -51,7 +52,7 @@ public DocletOptions( Reporter reporter ) {
attributes = new ArrayList<>();
}

public void collect( AsciidocletOptions option, List<String> list )
void collect( AsciidocletOptions option, List<String> list )
{
switch ( option )
{
Expand All @@ -76,7 +77,7 @@ private Stream<String> splitTrimStream( List<String> list )
.filter( s -> !s.isEmpty() );
}

public void validateOptions() {
void validateOptions() {
if ( baseDir().isEmpty() ) {
reporter.print( WARNING, AsciidocletOptions.BASEDIR + " must be present for includes or file reference features to work properly.");
}
Expand All @@ -87,27 +88,27 @@ public void validateOptions() {
}
}

public Optional<File> overview() {
Optional<File> overview() {
return Optional.ofNullable( overview );
}

public Optional<File> stylesheet() {
Optional<File> stylesheet() {
return Optional.ofNullable( stylesheet );
}

public Optional<File> baseDir() {
Optional<File> baseDir() {
return Optional.ofNullable( basedir );
}

public Optional<File> destDir() {
Optional<File> destDir() {
return Optional.ofNullable( destdir );
}

public Charset encoding() {
Charset encoding() {
return encoding;
}

public List<String> attributes() {
List<String> attributes() {
return attributes;
}

Expand All @@ -121,11 +122,19 @@ Optional<File> attributesFile() {
return Optional.of( attributesFile );
}

public String gemPath() {
String gemPath() {
return gemPath;
}

public List<String> requires() {
List<String> requires() {
return requires;
}

@Override
public String toString()
{
return "DocletOptions{" + "reporter=" + reporter + ", basedir=" + basedir + ", overview=" + overview + ", stylesheet=" + stylesheet + ", destdir=" +
destdir + ", attributesFile=" + attributesFile + ", gemPath='" + gemPath + '\'' + ", requires=" + requires + ", encoding=" + encoding +
", attributes=" + attributes + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package org.asciidoctor.asciidoclet;

import jdk.javadoc.doclet.Doclet;
import org.asciidoctor.asciidoclet.AsciidocletOptions;
import org.asciidoctor.asciidoclet.DocletOptions;

import java.util.List;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/asciidoctor/asciidoclet/Stylesheets.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Stylesheets(DocletOptions options, Reporter errorReporter) {
public boolean copy() {
if ( docletOptions.destDir().isEmpty() ) {
// standard doclet must have checked this by the time we are called
errorReporter.print( Diagnostic.Kind.ERROR, "Destination directory not specified, cannot copy stylesheet");
errorReporter.print( Diagnostic.Kind.ERROR, "Destination directory not specified, cannot copy stylesheet. Doclet options were " + docletOptions);
return false;
}
String stylesheet = selectStylesheet(System.getProperty("java.version"));
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ public void testJavadocIntegration() throws Exception
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=asciidoclet",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=asciidoclet",
"--module-path", classpath(),
"--limit-modules", "asciidoclet,java.base,jdk.javadoc,asciidoctorj",
"--class-path", classpath(),
"-doclet", "org.asciidoctor.asciidoclet.Asciidoclet",
"--source-path", "src/main/java",
"-d", outputDirectory,
Expand Down

0 comments on commit 2b91607

Please sign in to comment.