jruby-gradle/jruby-gradle-plugin

gem dependency is not resolved properly

amimas opened this issue · 0 comments

Hello,

I'm relatively new to this plugin and I see a lot of potential. Unfortunately I am seeing a big issue and not sure if it's a bug or intended to be this way. The documentation site didn't help much either.

Here's the full gradle script:

buildscript {
  repositories {
    jcenter()
  }

  dependencies {
      classpath "com.github.jruby-gradle:jruby-gradle-plugin:2.0.0"
  }
}

apply plugin: 'com.github.jruby-gradle.base'

import com.github.jrubygradle.JRubyExec

repositories {
  ruby.gems()
  jcenter()
}

dependencies {
    /* Using the built-in `gems` configuration to describe the
     * dependencies our JRubyExec-based tasks will need
     */
    gems "rubygems:colorize:0.7.7+"
    //gems "rubygems:zendesk_apps_tools:3.7.1"
}

task printSomePrettyOutputPlease(type: JRubyExec) {
    description "Execute our nice local print-script.rb"
    script "${projectDir}/print-script.rb"
}

task runZat (type: JRubyExec) {
  script "zat"
  scriptArgs "theme", "preview"
}

Run ./gradlew printSomePrettyOutputPlease and the colorize gem gets downloaded/installed and a few colourful lines are printed (it's from the sample/example in this plugin's docs).

The gems are downloaded to Gradle cache (i.e. ~/.gradle/caches/modules-2/files-2.1/rubygems/). It seems the gems are also downloaded and setup in build/.gems/ directory.

Why is the build/ directory being used for the gems? The required gems will be "installed" everytime the build directory is removed. If you add the "java" plugin, the clean task will automatically remove that directory.

Next, uncomment the second dependency gems "rubygems:zendesk_apps_tools:3.7.1" and run ./gradlew runZat task. I now get the following error message:

> Task :runZat FAILED
SyntaxError: /Users/amimas/.rbenv/shims/zat:3: syntax error, unexpected tSTRING_BEG
[ -n "$RBENV_DEBUG" ] && set -x
     ^

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':runZat'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

Looks like it's trying to load the zendesk_apps_tools gem from my local installation (without using jruby-gradle). Now, if I remove the build directory (rm -rf build), and then run ./gradlew runZat, this time it will setup both dependencies (colorize, zendesk_apps_tools) under the build directory.

Adding new dependencies should be setup automatically without needing to cleanup or remove the build directory.

The runZat task doesn't seem to work because some transitive dependency can't seem to install successfully. Maybe that's a separate issue.