Closed rockyallen closed 8 years ago
thx for the detail, i have reproduced the problem ...
and in fact the problem is in AsciidoctorJ, there is a problem with loading java class without a package such as com.*
if you add a package com.binout to the Prepropcessor, it works !!
package com.binout;
import java.util.Map;
import org.asciidoctor.ast.Document;
import org.asciidoctor.extension.Preprocessor;
import org.asciidoctor.extension.PreprocessorReader;
public class ChangeAttributeValuePreprocessor extends Preprocessor {
public ChangeAttributeValuePreprocessor(Map<String, Object> config) {
super(config);
}
@Override
public PreprocessorReader process(Document document, PreprocessorReader reader) {
document.getAttributes().put("content", "Alex");
return reader;
}
}
<target name="test2" depends="clean">
<mkdir dir="build/classes"/>
<mkdir dir="dist"/>
<javac srcdir="src" destdir="build/classes" classpath="${aa.jar}" includeantruntime="false"/>
<taskdef uri="antlib:org.asciidoctor.ant" resource="org/asciidoctor/ant/antlib.xml" classpath="${aa.jar};build/classes"/>
<asciidoctor:convert sourceDirectory="doc" outputDirectory="dist">
<preprocessor className="com.binout.ChangeAttributeValuePreprocessor"/>
</asciidoctor:convert>
</target>
Fix works, thanks. Where should this be documented?
It's an issue of asciidoctorj https://github.com/asciidoctor/asciidoctorj/issues/250 and it seems to be fixed in 1.5.2.1. It will be included in next release of asciidoctor-ant ;-)
Trying the "ChangeAttributeValuePreprocessor" example from the AsciidoctorJ project, and my own Ant build script. test1 works as expected, and produces dist/test.xml. When I run test2, I get:
org.jruby.exceptions.RaiseException: (Errno::ENOENT) /home/rocky/doc/test.ad at org.jruby.RubyFile.initialize(org/jruby/RubyFile.java:361) at org.jruby.RubyIO.new(org/jruby/RubyIO.java:851) at RUBY.convert_file(/home/rocky/Documents/asciidoc-demo/lib/asciidoctor-ant-1.5.2-SNAPSHOT.jar!/gems/asciidoctor-1.5.2/lib/asciidoctor.rb:1562) at RUBY.convertFile(script:68) at org.jruby.gen.InterfaceImpl2006909763.convertFile(org/jruby/gen/InterfaceImpl2006909763.gen:13) BUILD FAILED (total time: 11 seconds)
ChangeAttributeValuePreprocessor .java:
build.xml:
Using Ubuntu 14.04, Java 1.8.0_66, Apache Ant 1.9.3, Asciidoctor-ant 1.52 SNAPSHOT @ 2015-12-01.
Am I missing something?