Skip to content

Commit

Permalink
Ensure AsciidoctorInstance (for minisite or other mojo) can create an…
Browse files Browse the repository at this point in the history
… asciidoctor instance using the mojo classloader and does not reuse the actions classloader which can have another asciidoctor version depending the classloader configuration
  • Loading branch information
rmannibucau committed Nov 24, 2022
1 parent 0f13013 commit f1e8055
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ public <T> T withAsciidoc(final AsciidoctorConfiguration base, final Function<As

private Asciidoctor newInstance(final AsciidoctorConfiguration log, final Path path, final String customGems,
final List<String> requires, final List<AsciidoctorExtension> extensions) {
final Asciidoctor asciidoctor = JRubyAsciidoctor.create(ofNullable(customGems).orElseGet(path::toString));
final var thread = Thread.currentThread();
final var oldLoader = thread.getContextClassLoader();
final Asciidoctor asciidoctor;
try {
thread.setContextClassLoader(AsciidoctorInstance.class.getClassLoader());
asciidoctor = JRubyAsciidoctor.create(ofNullable(customGems).orElseGet(path::toString));
} finally {
thread.setContextClassLoader(oldLoader);
}
Logger.getLogger("asciidoctor").setUseParentHandlers(false);

final var registry = asciidoctor.javaExtensionRegistry();
Expand Down

0 comments on commit f1e8055

Please sign in to comment.