Upgrade to Asciidoctor 1.5.6 and Asciidoctor-Diagram 1.5.5
MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/internal/JRubyAsciidoctor.java
asciidoctorj-core/src/main/java/org/asciidoctor/internal/JRubyAsciidoctor.java
@@ -299,13 +299,16 @@ public class JRubyAsciidoctor implements Asciidoctor {
RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);
+ ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
try {
+ Thread.currentThread().setContextClassLoader(rubyRuntime.getJRubyClassLoader());
Object object = this.asciidoctorModule.convert(content, rubyHash);
return returnExpectedValue(object);
} catch(RaiseException e) {
logger.severe(e.getException().getClass().getCanonicalName());
throw new AsciidoctorCoreException(e);
} finally {
+ Thread.currentThread().setContextClassLoader(oldTCCL);
// we restore current directory to its original value.
rubyRuntime.setCurrentDirectory(currentDirectory);
}
@@ -329,14 +332,16 @@ public class JRubyAsciidoctor implements Asciidoctor {
RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);
+ ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader();
try {
+ Thread.currentThread().setContextClassLoader(rubyRuntime.getJRubyClassLoader());
Object object = this.asciidoctorModule.convertFile(filename.getAbsolutePath(), rubyHash);
return returnExpectedValue(object);
} catch(RaiseException e) {
logger.severe(e.getMessage());
-
throw new AsciidoctorCoreException(e);
} finally {
+ Thread.currentThread().setContextClassLoader(oldTCCL);
// we restore current directory to its original value.
rubyRuntime.setCurrentDirectory(currentDirectory);
}

MODIFY
asciidoctorj-diagram/gradle.properties
asciidoctorj-diagram/gradle.properties
properName=AsciidoctorJ Diagram
description=AsciidoctorJ Diagram bundles the Asciidoctor Diagram RubyGem (asciidoctor-diagram) so it can be loaded into the JVM using JRuby.
-version=1.5.4
+version=1.5.5
gem_name=asciidoctor-diagram

MODIFY
asciidoctorj-diagram/src/test/java/org/asciidoctor/WhenDocumentContainsDitaaDiagram.java
asciidoctorj-diagram/src/test/java/org/asciidoctor/WhenDocumentContainsDitaaDiagram.java
@@ -6,6 +6,7 @@ import org.asciidoctor.util.ClasspathResources;
import org.junit.Rule;
import org.junit.Test;
+import static org.asciidoctor.AttributesBuilder.attributes;
import static org.asciidoctor.OptionsBuilder.options;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

MODIFY
asciidoctorj-distribution/build.gradle
asciidoctorj-distribution/build.gradle
@@ -12,7 +12,7 @@ dependencies {
compile("org.asciidoctor:asciidoctorj-pdf:$asciidoctorjPdfVersion") {
transitive = false
}
- compile 'org.jruby:jruby-complete:9.1.8.0'
+ compile 'org.jruby:jruby-complete:9.1.12.0'
}
jar.enabled = false

MODIFY
asciidoctorj-distribution/src/test/java/org/asciidoctor/WhenDitaaDiagramIsRendered.java
asciidoctorj-distribution/src/test/java/org/asciidoctor/WhenDitaaDiagramIsRendered.java
@@ -5,9 +5,9 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
-import java.util.Collections;
import java.util.UUID;
+import static org.asciidoctor.AttributesBuilder.attributes;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.core.Is.is;
@@ -32,7 +32,7 @@ public class WhenDitaaDiagramIsRendered {
document,
OptionsBuilder.options()
.toFile(false)
- .attributes(AttributesBuilder.attributes()
+ .attributes(attributes()
.attribute("imagesoutdir", "build")));
// then:
@@ -48,7 +48,8 @@ public class WhenDitaaDiagramIsRendered {
// given:
final String imageFileName = UUID.randomUUID().toString();
- final File destinationFile = new File("build/ditaa.pdf");
+ final File destinationDir = new File( "build");
+ final File destinationFile = new File( "ditaa.pdf");
final String document = getTestDocument(imageFileName);
@@ -60,15 +61,22 @@ public class WhenDitaaDiagramIsRendered {
document,
OptionsBuilder.options()
.backend("pdf")
+ .toDir(destinationDir)
.toFile(destinationFile)
- .attributes(AttributesBuilder.attributes()
- .attribute("imagesoutdir", "build")));
+ .attributes(
+ attributes()
+ .attribute("imagesdir", destinationDir.getPath())
+ .attribute("imagesoutdir", destinationDir.getPath()))
+ );
// then:
- assertThat(destinationFile.exists(), is(true));
- assertThat(destinationFile.length(), greaterThan(0L));
- assertThat("PNG file not created!", new File("build/" + imageFileName + ".png").exists(), is(true));
- assertThat("PNG cache file not created!", new File("build/.asciidoctor/diagram/" + imageFileName + ".png.cache").exists(), is(true));
+ final File expectedPdfFile = new File(destinationDir, "ditaa.pdf");
+ assertThat(expectedPdfFile + " does not exist", expectedPdfFile.exists(), is(true));
+ assertThat(expectedPdfFile.length(), greaterThan(0L));
+ final File imageFile = new File("build/" + imageFileName + ".png");
+ final File cacheFile = new File(destinationDir, ".asciidoctor/diagram/" + imageFileName + ".png.cache");
+ assertThat("PNG file " + imageFile + " not created!", imageFile.exists(), is(true));
+ assertThat("PNG cache file " + cacheFile + " not created!", cacheFile.exists(), is(true));
}
private String getTestDocument(String imageFileName) {

MODIFY
asciidoctorj-distribution/src/test/java/org/asciidoctor/WhenPlantumlDiagramIsRendered.java
asciidoctorj-distribution/src/test/java/org/asciidoctor/WhenPlantumlDiagramIsRendered.java
@@ -7,6 +7,7 @@ import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.util.UUID;
+import static org.asciidoctor.AttributesBuilder.attributes;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.core.Is.is;
@@ -46,7 +47,8 @@ public class WhenPlantumlDiagramIsRendered {
// given:
final String imageFileName = UUID.randomUUID().toString();
- final File destinationFile = new File("build/plantuml.pdf");
+ final File destinationDir = new File( "build");
+ final File destinationFile = new File( "plantuml.pdf");
final String document = getTestDocument(imageFileName);
@@ -58,15 +60,21 @@ public class WhenPlantumlDiagramIsRendered {
document,
OptionsBuilder.options()
.backend("pdf")
+ .toDir(destinationDir)
.toFile(destinationFile)
- .attributes(AttributesBuilder.attributes()
- .attribute("imagesoutdir", "build")));
+ .attributes(
+ attributes()
+ .attribute("imagesdir", destinationDir.getPath())
+ .attribute("imagesoutdir", destinationDir.getPath())));
// then:
- assertThat(destinationFile.exists(), is(true));
- assertThat(destinationFile.length(), greaterThan(0L));
- assertThat("PNG file not created!", new File("build/" + imageFileName + ".png").exists(), is(true));
- assertThat("PNG cache file not created!", new File("build/.asciidoctor/diagram/" + imageFileName + ".png.cache").exists(), is(true));
+ final File expectedPdfFile = new File(destinationDir, "plantuml.pdf");
+ assertThat(expectedPdfFile + " does not exist", expectedPdfFile.exists(), is(true));
+ assertThat(expectedPdfFile.length(), greaterThan(0L));
+ final File imageFile = new File("build/" + imageFileName + ".png");
+ final File cacheFile = new File(destinationDir, ".asciidoctor/diagram/" + imageFileName + ".png.cache");
+ assertThat("PNG file " + imageFile + " not created!", imageFile.exists(), is(true));
+ assertThat("PNG cache file " + cacheFile + " not created!", cacheFile.exists(), is(true));
}
private String getTestDocument(String imageFileName) {

MODIFY
build.gradle
build.gradle
@@ -45,7 +45,7 @@ ext {
xmlMatchersVersion = '1.0-RC1'
// gem versions
- asciidoctorGemVersion = project.hasProperty('asciidoctorGemVersion') ? project.asciidoctorGemVersion : '1.5.5'
+ asciidoctorGemVersion = project.hasProperty('asciidoctorGemVersion') ? project.asciidoctorGemVersion : '1.5.6'
asciidoctorEpub3GemVersion = project(':asciidoctorj-epub3').version.replace('-', '.')
asciidoctorDiagramGemVersion = project(':asciidoctorj-diagram').version.replace('-', '.')

MODIFY
gradle.properties
gradle.properties
-version=1.5.5-SNAPSHOT
+version=1.5.6-SNAPSHOT
sourceCompatibility=1.6
targetCompatibility=1.6

Upgrade to Asciidoctor 1.5.6 and Asciidoctor-Diagram 1.5.5