Skip to content
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

Rewrite using new Javadoc API #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vojtechhabarta
Copy link

In Java 13 old doclet API (com.sun.javadoc) is removed and only new doclet API (jdk.javadoc.doclet) should be used.

This PR is rewrite using new API. It is a prototype which contains both old and new doclets and can be built using Java 11. To support Java 13 old doclet needs to be removed. New doclet passes all 55 tests and I also tested it (and compared with old doclet) on real project.

I am interested in this doclet because I am using its XML format in https://github.com/vojtechhabarta/typescript-generator. Please let me know if you have any plans with this project so I can decide how to make typescript-generator work on Java 13.

Thanks

Java changed to version 11
Version changed to 2.0.0-SNAPSHOT
@red61wjt
Copy link

red61wjt commented Apr 6, 2020

[WARNING] Error injecting: org.codehaus.plexus.archiver.jar.JarArchiver
java.lang.ExceptionInInitializerError
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:86)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
at com.google.inject.internal.ConstructorInjector.access$000(ConstructorInjector.java:32)
at com.google.inject.internal.ConstructorInjector$1.call(ConstructorInjector.java:89)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:133)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:87)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
at org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:53)
at com.google.inject.internal.ProviderInternalFactory$1.call(ProviderInternalFactory.java:65)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:115)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:133)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
at org.eclipse.sisu.inject.Guice4$1.get(Guice4.java:162)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:243)
at org.codehaus.plexus.archiver.manager.DefaultArchiverManager.getArchiver(DefaultArchiverManager.java:63)
at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchiver(DefaultAssemblyArchiver.java:302)
at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:170)
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:484)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.(AbstractZipArchiver.java:122)
... 60 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.907 s
[INFO] Finished at: 2020-04-06T14:18:32+01:00
[INFO] Final Memory: 24M/100M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single (make-assembly) on project xml-doclet: Execution make-assembly of goal org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single failed: An API incompatibility was encountered while executing org.apache.maven.plugins:maven-assembly-plugin:2.5.5:single: java.lang.ExceptionInInitializerError: null
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.apache.maven.plugins:maven-assembly-plugin:2.5.5
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/will/.m2/repository/org/apache/maven/plugins/maven-assembly-plugin/2.5.5/maven-assembly-plugin-2.5.5.jar
[ERROR] urls[1] = file:/home/will/.m2/repository/org/slf4j/slf4j-jdk14/1.5.6/slf4j-jdk14-1.5.6.jar
[ERROR] urls[2] = file:/home/will/.m2/repository/org/slf4j/jcl-over-slf4j/1.5.6/jcl-over-slf4j-1.5.6.jar
[ERROR] urls[3] = file:/home/will/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
[ERROR] urls[4] = file:/home/will/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
[ERROR] urls[5] = file:/home/will/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[ERROR] urls[6] = file:/home/will/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[7] = file:/home/will/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar
[ERROR] urls[8] = file:/home/will/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
[ERROR] urls[9] = file:/home/will/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[10] = file:/home/will/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[11] = file:/home/will/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[12] = file:/home/will/.m2/repository/org/apache/maven/shared/maven-common-artifact-filters/1.4/maven-common-artifact-filters-1.4.jar
[ERROR] urls[13] = file:/home/will/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.22/plexus-interpolation-1.22.jar
[ERROR] urls[14] = file:/home/will/.m2/repository/org/codehaus/plexus/plexus-archiver/2.10.2/plexus-archiver-2.10.2.jar
[ERROR] urls[15] = file:/home/will/.m2/repository/org/apache/maven/shared/file-management/1.1/file-management-1.1.jar
[ERROR] urls[16] = file:/home/will/.m2/repository/org/apache/maven/shared/maven-shared-io/1.1/maven-shared-io-1.1.jar
[ERROR] urls[17] = file:/home/will/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.jar
[ERROR] urls[18] = file:/home/will/.m2/repository/org/apache/maven/shared/maven-filtering/1.3/maven-filtering-1.3.jar
[ERROR] urls[19] = file:/home/will/.m2/repository/org/apache/maven/shared/maven-shared-utils/0.6/maven-shared-utils-0.6.jar
[ERROR] urls[20] = file:/home/will/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[21] = file:/home/will/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.4/plexus-build-api-0.0.4.jar
[ERROR] urls[22] = file:/home/will/.m2/repository/org/codehaus/plexus/plexus-io/2.6/plexus-io-2.6.jar
[ERROR] urls[23] = file:/home/will/.m2/repository/org/apache/maven/maven-archiver/2.5/maven-archiver-2.5.jar
[ERROR] urls[24] = file:/home/will/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.21/plexus-utils-3.0.21.jar
[ERROR] urls[25] = file:/home/will/.m2/repository/org/apache/maven/shared/maven-repository-builder/1.0/maven-repository-builder-1.0.jar
[ERROR] urls[26] = file:/home/will/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : Index 1 out of bounds for length 1
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

@red61wjt
Copy link

red61wjt commented Apr 6, 2020

Upping the version of the asembly plugin appears to resolve that issue

@red61wjt
Copy link

red61wjt commented Apr 6, 2020

Also looks like it ignores

-d ${project.build.directory} -filename javadoc.xml

@red61wjt
Copy link

red61wjt commented Apr 6, 2020

<additionalparam>-d ${project.build.directory} -filename javadoc.xml</additionalparam>

@vojtechhabarta
Copy link
Author

@red61wjt thanks for trying this PR.
Parameters -d and -filename are implemented.
When I pass those parameters in the following way it works:
<additionalOptions>-d ${project.build.directory} -filename test-javadoc.xml</additionalOptions>

@red61wjt
Copy link

red61wjt commented Apr 7, 2020

Yup, that appears to fix it. Was that an intentional change to move from additionalparam to additionalOptions or was it undocumented feature that additionalparam worked before?

@vojtechhabarta
Copy link
Author

I think this was a change in javadoc itself.

@russo595
Copy link

russo595 commented Aug 12, 2020

When I used cyrillic in comments, these changes generated UTF-16 symbols, for example <comment>\u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440</comment>

I resolved it, added dependency org.apache.commons:commons-text, and wrapped "fullBody" with StringEscapeUtils.unescapeeEcmaScript(fullBody), and got the right format, for example <comment>идентификатор</comment>, and it works right for latin comments.

Maybe this change is ugly hack, but I didn't find another resolution.

@vojtechhabarta
Copy link
Author

@russo595 thanks for sharing your solution. I think proper way to output unicode characters would be to create subclass of com.sun.tools.javac.tree.DocPretty, override void print(Object s) method to not escape unicode characters and use it in JavadocTransformer.transformJavadoc() method. But unfortunately DocPretty class is not accessible so I cannot use it and I didn't want to copy&paste this big chunk of code.

@sgparry
Copy link

sgparry commented Mar 7, 2023

@vojtechhabarta Hi, any chance you would consider repackaging your version of the xmldoclet under your own Maven coordinates and posting to central please? I have a really tough job trying to get our students Javadocs reformatted into Word for their project write-ups. Having JavaDoc -> XML -> XSLT -> Lots would provide a workable solution for us and a lot of others. If not, would you object if I did?

manticore-projects added a commit to manticore-projects/xml-doclet that referenced this pull request May 8, 2023
Salvaged the project from https://github.com/MarkusBernhardt/xml-doclet with PR MarkusBernhardt#17 and sanitized the build script and sources.
Supports JavaDoc 11 up to JavaDoc 13.

- Gradle Build, drop Maven
- Format and Check sources
- Publish to GitHub packages
@manticore-projects
Copy link

manticore-projects commented May 8, 2023

any chance you would consider repackaging your version of the xmldoclet under your own Maven coordinates and posting to central please?

Greetings.
I have done exactly that: https://github.com/manticore-projects/xml-doclet

<docletArtifact>
    <groupId>com.manticore-projects.tools</groupId>
    <artifactId>xml-doclet</artifactId>
    <version>1.1.3</version>
</docletArtifact>

Copy link

@p4Austin p4Austin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clicked it by mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants