Skip to content

Commit 84ef1fe

Browse files
author
R. Tyler Croy
committed
Make the gem installation directory configurable via jruby.gemInstallDir
Fixes #18
1 parent c464983 commit 84ef1fe

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## v2.1.0
44

5+
* [#18](https://github.com/rtyler/jruby-gradle-plugin/issues/18) allow
6+
changing the Gem installation directory by setting `jruby.gemInstallDir` in
7+
a gradle file
58
* [#16](https://github.com/rtyler/jruby-gradle-plugin/pull/16) add the
69
`JRubyExec` task type for executing Ruby code with the embedded JRuby
710
dependency.

src/main/groovy/com/lookout/jruby/GemUtils.groovy

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ import org.gradle.api.file.DuplicateFileCopyingException
1111
*/
1212
class GemUtils {
1313
static Boolean extractGem(Project p, File gem) {
14-
def gemname = gemFullNameFromFile(gem.getName())
15-
File extract_dir = new File("./vendor/gems/$gemname")
14+
String gemName = gemFullNameFromFile(gem.getName())
15+
String installDir = p.jruby.gemInstallDir
16+
File extractDir = new File("./${installDir}/gems/${gemName}")
1617

17-
if (extract_dir.exists()) {
18+
if (extractDir.exists()) {
1819
return
1920
}
2021

2122
p.exec {
2223
executable "gem"
23-
args 'install', gem, '--install-dir=./vendor', '--no-ri', '--no-rdoc'
24+
args 'install', gem, "--install-dir=./${installDir}", '--no-ri', '--no-rdoc'
2425
}
2526
}
2627

@@ -33,13 +34,17 @@ class GemUtils {
3334
* @param overwrite Allow overwrite of an existing gem folder
3435
* @return
3536
*/
36-
static void extractGem(Project project, def jRubyClasspath, File gem,File destDir,boolean overwrite) {
37-
def gemname = gemFullNameFromFile(gem.name)
38-
File extract_dir = new File(destDir,gemname)
37+
static void extractGem(Project project,
38+
def jRubyClasspath,
39+
File gem,
40+
File destDir,
41+
boolean overwrite) {
42+
String gemName = gemFullNameFromFile(gem.name)
43+
File extractDir = new File(destDir, gemName)
3944

40-
if (extract_dir.exists()) {
45+
if (extractDir.exists()) {
4146
if(overwrite) {
42-
project.delete extract_dir
47+
project.delete extractDir
4348
} else {
4449
throw new DuplicateFileCopyingException("Gem ${gem.name} already exists")
4550
}

src/main/groovy/com/lookout/jruby/JRubyPlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class JRubyPlugin implements Plugin<Project> {
9999
from "$project.buildDir/classes/main"
100100
// Bring our vendored gems into the created war file
101101
webInf {
102-
from 'vendor'
102+
from project.jruby.gemInstallDir
103103
into 'gems'
104104
}
105105

src/main/groovy/com/lookout/jruby/JRubyPluginExtension.groovy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ package com.lookout.jruby
33
import org.gradle.api.Project
44

55
class JRubyPluginExtension {
6-
76
// More details here: <http://rubygems-proxy.torquebox.org/>
8-
def String gemrepo_url = "http://rubygems-proxy.torquebox.org/releases"
9-
7+
String gemrepo_url = "http://rubygems-proxy.torquebox.org/releases"
8+
String gemInstallDir = 'vendor'
109
String defaultVersion = '1.7.13'
1110
String execVersion = defaultVersion
1211

0 commit comments

Comments
 (0)