Skip to content

Upgrade Asciidoctor Maven Plugin so that syntax highlighting can be enabled using an attribute #620

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

Closed
wants to merge 1 commit into from

Conversation

gavvvr
Copy link
Contributor

@gavvvr gavvvr commented Jun 10, 2019

Unlike Gradle, when building with Maven plugin the :source-highlighter: highlightjs attribute in *.adoc files does not work (it can be even removed). You should explicitly specify sourceHighlighter in Maven plugin configuration, see https://asciidoctor.org/docs/asciidoctor-maven-plugin/#configuration-2

@wilkinsona
Copy link
Member

Thanks for the suggestion. The loss of syntax highlighting is caused by a bug in the version of the Asciidoctor Maven Plugin that's being used. Rather than working around the bug by declaring the source highlighter in XML, I think it would be better to upgrade to the latest 1.5.x version of the Maven plugin. Would you like to update this pull request to do that instead? It'd be great if you could make the same update to the documentation as well.

@wilkinsona wilkinsona added status: waiting-for-feedback Feedback is required before progress can be made and removed status: waiting-for-triage Untriaged issue labels Jun 10, 2019
@gavvvr
Copy link
Contributor Author

gavvvr commented Jun 10, 2019

Hi @wilkinsona. Would be great to fix it with a plugin version update. But I tried to use 1.5.8 and there was still no highlighting without explicit <sourceHighlighter> in pom. The newest plugin version is 1.6.0 and it throws an exception in my project (with latest rest docs 2.0.3.RELEASE) on attempt to mvn prepare-package:

    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:184)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    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:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: java.lang.IncompatibleClassChangeError: Found interface org.asciidoctor.extension.JavaExtensionRegistry, but class was expected
    at org.springframework.restdocs.asciidoctor.RestDocsExtensionRegistry.register (RestDocsExtensionRegistry.java:32)
    at org.asciidoctor.extension.internal.ExtensionRegistryExecutor.registerAllExtensions (ExtensionRegistryExecutor.java:21)
    at org.asciidoctor.internal.JRubyAsciidoctor.registerExtensions (JRubyAsciidoctor.java:113)
    at org.asciidoctor.internal.JRubyAsciidoctor.processRegistrations (JRubyAsciidoctor.java:102)
    at org.asciidoctor.internal.JRubyAsciidoctor.create (JRubyAsciidoctor.java:82)
    at org.asciidoctor.Asciidoctor$Factory.create (Asciidoctor.java:726)
    at org.asciidoctor.maven.AsciidoctorMojo.getAsciidoctorInstance (AsciidoctorMojo.java:401)
    at org.asciidoctor.maven.AsciidoctorMojo.execute (AsciidoctorMojo.java:205)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    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:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback Feedback is required before progress can be made labels Jun 10, 2019
@wilkinsona
Copy link
Member

wilkinsona commented Jun 10, 2019

1.6 of the plugin doesn't work as it pulls in a version of AsciidoctorJ that contains breaking changes. See #581 for details.

I tried the Data REST sample with 1.5.8 of the Asciidoctor Maven Plugin and the syntax highlighting worked. How did you try it?

@wilkinsona wilkinsona added status: waiting-for-feedback Feedback is required before progress can be made and removed status: feedback-provided Feedback has been provided labels Jun 10, 2019
@gavvvr
Copy link
Contributor Author

gavvvr commented Jun 10, 2019

How did you try it?

In my own example, I had an empty line between top-line header and attributes. So, not a plugin issue. I updated pom.xml and docs, ready for merge

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback Feedback is required before progress can be made labels Jun 10, 2019
@wilkinsona wilkinsona changed the title Enable syntax highlighting using Maven plugin Upgrade Asciidoctor Maven Plugin so that syntax highlighting can be enabled using an attribute Jun 12, 2019
@wilkinsona wilkinsona added the type: documentation Changes to the documentation label Jun 12, 2019
@wilkinsona wilkinsona added this to the 1.2.7.RELEASE milestone Jun 12, 2019
@wilkinsona wilkinsona removed the status: feedback-provided Feedback has been provided label Jun 12, 2019
wilkinsona pushed a commit that referenced this pull request Jun 12, 2019
@wilkinsona
Copy link
Member

wilkinsona commented Jun 12, 2019

Thanks very much, @gavvvr. The proposed changes are now in 1.2.x and master.

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

Successfully merging this pull request may close these issues.

3 participants