@@ -8,67 +8,68 @@ import org.gradle.api.tasks.Delete
8
8
import org.gradle.api.tasks.bundling.War
9
9
10
10
class JRubyPlugin implements Plugin<Project > {
11
+ static final String TASK_GROUP_NAME = ' JRuby'
12
+
13
+ static final String RUBYGEMS_RELEASE_URL = ' http://rubygems-proxy.torquebox.org/releases'
14
+
11
15
void apply (Project project ) {
12
16
project. apply plugin : ' java'
13
17
project. apply plugin : ' war'
14
18
project. extensions. create(' jruby' , JRubyPluginExtension , project)
15
19
16
- if (! project. repositories. metaClass. respondsTo(project. repositories,' rubygemsRelease' )) {
20
+ if (! project. repositories. metaClass. respondsTo(project. repositories, ' rubygemsRelease' )) {
17
21
project. repositories. metaClass. rubygemsRelease << { ->
18
- maven { url ' http://rubygems-proxy.torquebox.org/releases ' }
22
+ maven { url RUBYGEMS_RELEASE_URL }
19
23
}
20
24
}
21
25
22
26
// Set up a special configuration group for our embedding jars
23
27
project. configurations {
24
28
jrubyEmbeds
25
- jrubyWar
26
29
gems
27
30
}
28
31
29
32
project. configurations. create(JRubyExec . JRUBYEXEC_CONFIG )
33
+ project. configurations. create(JRubyWar . JRUBYWAR_CONFIG )
30
34
JRubyExecDelegate . addToProject(project)
31
35
32
36
// In order for jrubyWar to work we'll need to pull in the warbler
33
37
// bootstrap code from this artifact
34
38
project. afterEvaluate {
35
- if (project. jruby. defaultRepositories) {
39
+ if (project. jruby. defaultRepositories) {
36
40
project. repositories {
37
41
jcenter()
38
42
rubygemsRelease()
39
43
40
44
// Required to pull in our warbler-bootstrap dependency
41
45
maven { url ' http://dl.bintray.com/rtyler/jruby' }
42
-
43
46
}
44
47
}
48
+
45
49
project. dependencies {
46
50
jrubyEmbeds group : ' com.lookout' , name : ' warbler-bootstrap' , version : ' 1.+'
47
- jrubyWar group : ' org.jruby' , name : ' jruby-complete' , version : project. jruby. defaultVersion
48
- jrubyWar (group : ' org.jruby.rack' , name : ' jruby-rack' , version : ' 1.1.+' ) {
49
- exclude module : ' jruby-complete'
50
- }
51
51
}
52
52
53
53
JRubyExec . updateJRubyDependencies(project)
54
+ JRubyWar . updateJRubyDependencies(project)
54
55
}
55
56
56
57
project. task(' jrubyClean' , type : Delete ) {
57
- group ' JRuby '
58
+ group TASK_GROUP_NAME
58
59
description ' Clean up the temporary dirs used by the JRuby plugin'
59
60
mustRunAfter ' clean'
60
61
delete ' .jarcache/'
61
62
}
62
63
63
64
project. task(' jrubyPrepareGems' , type : JRubyPrepareGems ) {
64
- group ' JRuby '
65
+ group TASK_GROUP_NAME
65
66
description ' Prepare the gems from the `gem` dependencies, extracts into jruby.installGemDir'
66
67
gems project. configurations. gems
67
68
outputDir project. jruby. gemInstallDir
68
69
}
69
70
70
71
project. task(' jrubyCacheJars' , type : Copy ) {
71
- group ' JRuby '
72
+ group TASK_GROUP_NAME
72
73
description ' Cache .jar-based dependencies into .jarcache/'
73
74
74
75
from project. configurations. jrubyWar
@@ -77,38 +78,12 @@ class JRubyPlugin implements Plugin<Project> {
77
78
}
78
79
79
80
project. task(' jrubyPrepare' ) {
80
- group ' JRuby '
81
+ group TASK_GROUP_NAME
81
82
description ' Pre-cache and prepare all dependencies (jars and gems)'
82
83
dependsOn project. tasks. jrubyCacheJars, project. tasks. jrubyPrepareGems
83
84
}
84
85
85
- project. task(' jrubyWar' , type : War ) {
86
- group ' JRuby'
87
- description ' Create a executable JRuby-based web archive'
88
- dependsOn project. tasks. jrubyPrepare
89
-
90
- from " $project . buildDir /classes/main"
91
- // Bring our vendored gems into the created war file
92
- webInf {
93
- from project. jruby. gemInstallDir
94
- into ' gems'
95
- }
96
-
97
- // Bring the jrubyWar configuration's dependencies into
98
- // WEB-INF/libs
99
- classpath project. configurations. jrubyWar
100
-
101
- // note that zipTree call is wrapped in closure so that configuration
102
- // is only resolved at execution time. This will take the embeds
103
- // from within the `jrubyEmbeds` configuration and dump them into the war
104
- from {
105
- project. configurations. jrubyEmbeds. collect { project. zipTree(it) }
106
- }
107
-
108
- // By adding the WarMain class as the main-class we can have a
109
- // runnable war
110
- manifest { attributes ' Main-Class' : ' com.lookout.jruby.WarMain' }
111
- }
86
+ project. task(' jrubyWar' , type : JRubyWar )
112
87
}
113
88
114
89
}
0 commit comments