asciidoctor / asciidoctor-gradle-examples

A collection of example projects that demonstrates how to use the Asciidoctor Gradle plugin
http://asciidoctor.github.io/asciidoctor-gradle-examples
Other
146 stars 132 forks source link

Including gems in build.gradle #30

Open paulvickers opened 8 years ago

paulvickers commented 8 years ago

In the asciidoc-diagram-to-html-example/build.gradle we find a way to include a gem in the build:

...
dependencies {
    gems 'rubygems:asciidoctor-diagram:1.4.0'
}

asciidoctorj {
    version = '1.5.4'
}

asciidoctor {
    dependsOn jrubyPrepare
    requires = ['asciidoctor-diagram']
    gemPath = jrubyPrepare.outputDir
...

I would like to use asciidoctor-mathematical in the pdf task of my own build.gradle. So, as a test, I replaced the asciidoctor-diagram references with asciidoctor-mathematical:

 ...
dependencies {
    gems 'rubygems:asciidoctor-mathematical:0.0.5'
}

asciidoctorj {
    version = '1.5.4'
}

asciidoctor {
    dependsOn jrubyPrepare
    requires = ['asciidoctor-mathematical']
    gemPath = jrubyPrepare.outputDir
...

I get the error:

Execution failed for task ':pdf'.
> (LoadError) no such file to load -- asciidoctor-mathematical

Is this a problem with my gem environment (brew upgrade seemed to mess things up yesterday) or is it an issue with asciidoctor-gradle?

gem list reveals:

addressable (2.4.0)
afm (0.2.2)
Ascii85 (1.0.2)
asciidoctor (1.5.4)
asciidoctor-diagram (1.5.1)
asciidoctor-epub3 (1.5.0.alpha.6)
asciidoctor-mathematical (0.0.5)
asciidoctor-pdf (1.5.0.alpha.12)
asciimath (1.0.4)
bibtex-ruby (4.4.2)
bigdecimal (1.2.8)
citeproc (1.0.3)
...

gem env gives:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.6.2
  - RUBY VERSION: 2.3.1 (2016-04-26 patchlevel 112) [x86_64-darwin15]
  - INSTALLATION DIRECTORY: /usr/local/bin
  - USER INSTALLATION DIRECTORY: /Users/paulvickers/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/bin/bin
  - SPEC CACHE DIRECTORY: /Users/paulvickers/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.3.1/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-15
  - GEM PATHS:
     - /usr/local/bin
     - /Users/paulvickers/.gem/ruby/2.3.0
     - /usr/local/lib/ruby/gems/2.3.0
     - /usr/local/Cellar/ruby/2.3.1/lib/ruby/gems/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
     - "install" => "--no-rdoc --no-ri"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/X11/bin
     - /usr/local/git/bin
     - /Library/TeX/texbin

but which ruby gives /usr/local/bin/ruby

By the way, I should like to say thanks to Dan et al for this brilliant project. It has come on a long way in the last two years and it's exciting to see it develop so well.

paulvickers commented 8 years ago

Update:

I uninstalled and reinstalled asciidoctor-mathematical. Now I get a series of jruby failures, essentially failing to build the gem. Here's the output in a gist: https://gist.github.com/paulvickers/396d7ec9868e20e1d0dbaeef2a170e0b

mojavelinux commented 8 years ago

Indeed, you're not going to be able to use asciidoctor-mathematical from Gradle because mathematical uses a C extension (without a Java extension) and JRuby no longer supports C extensions. Creating a gem that uses a C extension without also providing a Java extension is considered to be bad practice. The only way to use asciidoctor-mathematical is to use the Asciidoctor via Ruby MRI (either via the asciidoctor command or the Ruby API).

mojavelinux commented 8 years ago

gem list reveals:

By default, the Gradle plugin (at least the latest snapshot) does not rely on the Ruby on your system. Instead, it uses JRuby in a self-contained environment within the build. The gems get downloaded and installed into the build directory and used from there.

mojavelinux commented 8 years ago

I should like to say thanks to Dan et al for this brilliant project. It has come on a long way in the last two years and it's exciting to see it develop so well.

Thanks! And thanks to the grassroots financial support, I'm able to continue working on it every single day (above and beyond contributions that come as part of working on contracts).

mojavelinux commented 8 years ago

To summarize, you did everything right to add a gem to the Ruby runtime. You just can't use gems that only have C extensions.

I recommend opening a ticket in mathematical to allow it to work in JRuby. I think it's very unfair to develop a gem that excludes the JRuby community.

paulvickers commented 8 years ago

Thanks. I've opened an issue over in mathematical.

SRechenberger commented 4 years ago

Is there any solution for this issue, yet?