Login  Register

Re: copycss attribute causes exception in asciidoctor-java-integration

Posted by LightGuardjp on May 05, 2013; 2:59am
URL: https://discuss.asciidoctor.org/copycss-attribute-causes-exception-in-asciidoctor-java-integration-tp179p181.html

I would agree to doing this via #2. It will be easier to do this on the java side. 

Sent from Mailbox for iPhone


On Sat, May 4, 2013 at 3:06 PM, mojavelinux [via Asciidoctor :: Discussion] <[hidden email]> wrote:

I admit I failed to consider that scenario when writing the code to handle copying the default  stylesheet.

There are two ways to handle this, both which involve reading the stylesheet out of the zipped stream.

1. If Asciidoctor is running as a packed gem, and there is some way for Ruby to know that, Asciidoctor can open a reader on its own gem and pull out the file.

2. Java has a much better toolset to locate the compressed file and read files from it with extracting. The Java integration could intercept the copycss setting, not pass it to Asciidoctor, then perform the copy to the destination folder after returning from Asciidoctor.

Wdyt? Option #2 seems more viable.

-Dan

--
Sent from my CyanogenMod-powered
Android device, an open platform for
carriers, developers and consumers.

On May 4, 2013 2:01 PM, "asotobu [via Asciidoctor :: Discussion]" <[hidden email]> wrote:
Issue related with this topic is : https://github.com/asciidoctor/asciidoctor-java-integration/issues/21

I'm using the Gradle plugin for Asciidoctor and tried to use the copycss attribute as it seems the easiest way to get hold of the stylesheet. But the attribute results in the exception at the end of this report.

I don't think this is a problem with the Gradle plugin but the Java integration. Perhaps JRuby's stat() method can't handle files inside archives? If that's the case, perhaps the JARs need unpacking first?

Caused by: org.jruby.exceptions.RaiseException: (Errno::ENOENT) /Users/pledbrook/dev/tools/ratpack/ratpack-docs/jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.asciidoctor/asciidoctor-java-integration/0.1.2/jar/34e5c3a38e59337da992243afb25185c56462866/asciidoctor-java-integration-0.1.2.jar!/gems/asciidoctor-0.1.2/stylesheets/asciidoctor.css
at org.jruby.RubyFile.stat(org/jruby/RubyFile.java:810)
at RUBY.fu_each_src_dest(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.jruby/jruby-complete/1.7.3/jar/2273e4c2a2abdd4b25a21bc513bfc05cfba31f3b/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1524)
at RUBY.fu_each_src_dest0(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.jruby/jruby-complete/1.7.3/jar/2273e4c2a2abdd4b25a21bc513bfc05cfba31f3b/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1538)
at RUBY.fu_each_src_dest(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.jruby/jruby-complete/1.7.3/jar/2273e4c2a2abdd4b25a21bc513bfc05cfba31f3b/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:1522)
at RUBY.cp(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.jruby/jruby-complete/1.7.3/jar/2273e4c2a2abdd4b25a21bc513bfc05cfba31f3b/jruby-complete-1.7.3.jar!/META-INF/jruby.home/lib/ruby/1.9/fileutils.rb:395)
at RUBY.render(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.asciidoctor/asciidoctor-java-integration/0.1.2/jar/34e5c3a38e59337da992243afb25185c56462866/asciidoctor-java-integration-0.1.2.jar!/gems/asciidoctor-0.1.2/lib/asciidoctor.rb:851)
at RUBY.render_file(jar:file:/Users/pledbrook/.gradle/caches/artifacts-23/filestore/org.asciidoctor/asciidoctor-java-integration/0.1.2/jar/34e5c3a38e59337da992243afb25185c56462866/asciidoctor-java-integration-0.1.2.jar!/gems/asciidoctor-0.1.2/lib/asciidoctor.rb:870)
at RUBY.render_file(<script>:8)
at org.jruby.gen.InterfaceImpl1066952373.render_file(org/jruby/gen/InterfaceImpl1066952373.gen:13)
at org.asciidoctor.gradle.AsciidoctorTask$_gititdone_closure1.doCall(AsciidoctorTask.groovy:87)
at org.asciidoctor.gradle.AsciidoctorTask.gititdone(AsciidoctorTask.groovy:74)
at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)

And the reason is exactly the one the user pointed out.

So first of all we can try to find a way that Ruby gems can copy resources from bundled gem to an external directory, maybe there is an option in JRuby ( I will make some research about it), maybe modifying the Ruby part, maybe unpacking jar (so ugly I know).

Also keep in mind that for running asciidoctor-java-integration in OSGI, the jars should be uncompressed into a directory because of classloader issues, so unpacking jars could resolve two problems, but I think it creates anothers like startup time, version management, ...





If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/copycss-attribute-causes-exception-in-asciidoctor-java-integration-tp179.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/copycss-attribute-causes-exception-in-asciidoctor-java-integration-tp179p180.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML