Skip to content

SPI extensions not loading #64

@adpr

Description

@adpr

I am using asciidoctorj 1.5.4, asciidoctorj-pdf 1.5.0-alpha.11 and asciidoclet 1.5.4 in a maven project. I have defined some custom BlockProcessors and registered them using the javaExtensionRegistry and created the proper files in my META-INF/services folder.

Generating the PDF works flawlessly, and my custom BlockProcessors are recognized and rendered as they should be. In the Javadoc however, the custom BlockProcessors are not rendered at all, and asciidoctor reports the many warnings about the BlockProcessors not being recognized:

asciidoctor: WARNING: <stdin>: line 7: invalid style for paragraph: eks

If I throw a RuntimeException in the register method of my class that implements ExtensionRegistry, I can see that generating a PDF will throw the exception, but generating the Javadoc does not. It would seem that that extensions are not being loaded by AsciidoctorJ when generating the Javadoc.

Here is one of my BlockProcessors:

public class EksBlock extends BlockProcessor {

  public EksBlock(String name, Map<String, Object> config) {
    super(name, config);
  }

  @Override
  public Object process(AbstractBlock parent, Reader reader, Map<String, Object> attributes) {
    // attributes that a normal admonition would accept
    attributes.put("name", "EKS");
    attributes.put("caption", "EKS.");

    // just pass along the text
    String admonitionText = reader.read();

    return createBlock(parent, "admonition", admonitionText, attributes, new HashMap<Object, Object>());
  }
}

My ExtensionRegistry implementation:

public class BlockExtensionRegistry implements ExtensionRegistry {

  public void register(Asciidoctor asciidoctor) {
    Map<String, Object> config = new HashMap<String, Object>();
    config.put("contexts", Arrays.asList(":paragraph"));
    config.put("content_model", ":compound");

    EksBlock eksBlock = new EksBlock("eks", config);
  }
}

I also have the following file:

src/main/resources/META-INF/services/org.asciidoctor.extension.spi.ExtensionRegistry

File content:

com.example.extension.asciidoctor.BlockExtensionRegistry

Snippet from pom.xml

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-javadoc-plugin</artifactId>
	<configuration>
	  <failOnError>false</failOnError>
	  <noqualifier>all</noqualifier>
	  <show>private</show>
	  <doclet>org.asciidoctor.Asciidoclet</doclet>
	  <docletArtifact>
		<groupId>org.asciidoctor</groupId>
		<artifactId>asciidoclet</artifactId>
		<version>1.5.4</version>
	  </docletArtifact>
	  <additionalparam>
		--base-dir ${project.basedir}
		--attribute "name=${project.name}"
		--attribute "version=${project.version}"
		--attribute
		"templateDir=${project.basedir}/src/docs/asciidoc/template"
	  </additionalparam>
	</configuration>
</plugin>

Am I missing some configuration in my pom.xml that will allow Asciidoclet to register the extensions, or is this an issue with Asciidoclet?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions