@@ -12,48 +12,38 @@ The Ruby gem dependency code for this project relies on the [Rubygems Maven
12
12
proxy] ( http://rubygems-proxy.torquebox.org/ ) provided by the
13
13
[ Torquebox] ( http://torquebox.org ) project.
14
14
15
- ## Compatilibity
16
-
17
- This plugin requires Gradle 2.0 or better
18
-
19
- ## Getting Started
20
-
21
- ### Setting up Gradle
15
+ This is the base plugin. If you are interesting in doing the following then consult the pages for the appropriate
16
+ plugins:
22
17
23
- ** Note:** This assumes you already have [ Gradle] ( http://gradle.org ) installed.
18
+ * Building JRuby-based Java JARs, including making them executable -
19
+ [ jruby-gradle-jar-plugin] ( http://github.come/jruby-gradle/jruby-gradle-jar-plugin )
20
+ * Building JRuby-based Java Web Applications (WARs), -
21
+ [ jruby-gradle-war-plugin] ( http://github.come/jruby-gradle/jruby-gradle-war-plugin )
24
22
25
- ``` bash
26
- % mkdir fancy-webapp
27
- % cd fancy-webapp
28
- % git init
29
- Initialized empty Git repository in /usr/home/tyler/source/github/fancy-webapp/.git/
30
- % gradle wrapper # Create the wrappers to easily bootstrap others
31
- wrapper
32
23
33
- BUILD SUCCESSFUL
34
-
35
- Total time: 6.411 secs
36
- % git add gradle gradlew gradlew.bat
37
- % git commit -m " Initial commit with gradle wrappers"
38
- ```
24
+ ## Compatilibity
39
25
40
- ### Creating a gradle configuration file
26
+ This plugin requires Gradle 2.0 or better
41
27
42
- Create a ` build.gradle ` file in the root of ` fancy-webapp/ ` with the following:
28
+ ` JRuby 1.7.14 ` seem to have some bugs. Although this plugin has a workaround for this version it is recommended that you
29
+ avoid using ` 1.7.14 ` with the ` jruby-gradle-plugin ` .
43
30
31
+ ## Getting Started
44
32
45
33
``` groovy
46
- apply plugin: 'com.lookout.jruby'
47
-
48
34
buildscript {
49
35
repositories { jcenter() }
50
36
51
37
dependencies {
52
- classpath group: 'com.lookout ', name: 'jruby-gradle-plugin', version: '2 .1.+ '
38
+ classpath group: 'com.github.jrubygradle ', name: 'jruby-gradle-plugin', version: '0 .1.2 '
53
39
}
54
40
}
41
+
42
+ apply plugin: 'com.github.jrubygradle.base'
55
43
```
56
44
45
+ ### Adding gems
46
+
57
47
You can also add Ruby gem dependencies in your ` build.gradle ` file under the
58
48
` gem ` configuration, e.g.:
59
49
@@ -64,141 +54,14 @@ dependencies {
64
54
}
65
55
```
66
56
67
- In order to include Java-based dependencies in a ` .war ` file, declare those
68
- dependencies under the ` jrubyWar ` configuration, e.g.:
69
-
70
- ``` groovy
71
- dependencies {
72
- jrubyWar group: 'org.apache.kafka', name: 'kafka_2.9.2', version: '0.8.+'
73
- jrubyWar group: 'log4j', name: 'log4j', version: '1.2.+', transitive: true
74
- }
75
- ```
76
-
77
- Dependencies declared under the ` jrubyWar ` configuration will be copied into
78
- ` .jarcache/ ` and ` .war/WEB-INF/libs ` when the archive is created.
79
-
80
-
81
57
## Default Tasks
82
58
83
59
The plugin provides the following tasks:
84
60
85
- * ` jrubyWar ` - Creates a runnable web archive file in ` build/libs ` for your
86
- project.
87
61
* ` jrubyPrepareGems ` - Extract GEMs declared as dependencies under ` gems ` to ` jruby.gemInstallDir ` . This is as instance
88
62
of ` JRubyPrepareGems ` .
89
63
* ` jrubyPrepare ` - Call ` jrubyPrepareGems ` . Also copies the
90
64
content of Java-based dependencies into ` .jarcache/ ` for interpreted use
91
- (see below)
92
- * ` jrubyClean ` - Cleans up the temporary directories that tasks like
93
- ` jrubyWar ` - Creates a ` war ` file
94
-
95
- ## Creating a .war
96
-
97
- Currently the Gradle tooling expects the web application to reside in
98
- ` src/main/webapp/WEB-INF ` , so make sure your ` config.ru ` and application code
99
- are under that root directory. It may be useful to symbolicly link this to
100
- ` app/ ` in your root project directory. An * full* example of this can be found in the
101
- [ ruby-gradle-example] ( https://github.com/rtyler/ruby-gradle-example )
102
- repository.
103
-
104
- Once your application is ready, you can create the ` .war ` by executing the ` jrubyWar ` task:
105
-
106
- ``` bash
107
- % ./gradlew jrubyWar
108
- :compileJava UP-TO-DATE
109
- :processResources UP-TO-DATE
110
- :classes UP-TO-DATE
111
- :jrubyCacheJars
112
- :jrubyCacheGems
113
- :jrubyPrepareGems
114
- /home/tyler/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/yaml.rb:84:in ` < top (required)> ' :
115
- It seems your ruby installation is missing psych (for YAML output).
116
- To eliminate this warning, please install libyaml and reinstall your ruby.
117
- Successfully installed rack-1.5.2
118
- Successfully installed rack-protection-1.5.3
119
- 2 gems installed
120
- /home/tyler/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/yaml.rb:84:in `<top (required)>' :
121
- It seems your ruby installation is missing psych (for YAML output).
122
- To eliminate this warning, please install libyaml and reinstall your ruby.
123
- Successfully installed rake-10.3.2
124
- 1 gem installed
125
- /home/tyler/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/yaml.rb:84:in ` < top (required)> ' :
126
- It seems your ruby installation is missing psych (for YAML output).
127
- To eliminate this warning, please install libyaml and reinstall your ruby.
128
- Successfully installed tilt-1.4.1
129
- 1 gem installed
130
- /home/tyler/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/yaml.rb:84:in `<top (required)>' :
131
- It seems your ruby installation is missing psych (for YAML output).
132
- To eliminate this warning, please install libyaml and reinstall your ruby.
133
- Successfully installed sinatra-1.4.5
134
- 1 gem installed
135
- :jrubyPrepare
136
- :jrubyWar
137
-
138
- BUILD SUCCESSFUL
139
-
140
- Total time: 1 mins 34.84 secs
141
- %
142
- ```
143
-
144
- Once the ` .war ` has been created you can find it in ` build/libs ` and deploy that into a servlet container such as Tomcat or Jetty.
145
-
146
-
147
- ## Using the Ruby interpreter
148
-
149
- There are still plenty of cases, such as for local development, when you might
150
- not want to create a full ` .war ` file to run some tests. In order to use the
151
- same gems and ` .jar ` based dependencies, add the following to the entry point
152
- for your application:
153
-
154
- ``` ruby
155
- # Hack our GEM_HOME to make sure that the `rubygems` support can find our
156
- # unpacked gems in ./vendor/
157
- vendored_gems = File .expand_path(File .dirname(__FILE__ ) + ' /vendor' )
158
- if File .exists?(vendored_gems)
159
- ENV [' GEM_HOME' ] = vendored_gems
160
- end
161
-
162
- jar_cache = File .expand_path(File .dirname(__FILE__ ) + ' /.jarcache/' )
163
- if File .exists?(jar_cache)
164
- # Under JRuby `require`ing a `.jar` file will result in it being added to the
165
- # classpath for easy importing
166
- Dir [" #{ jar_cache } /*.jar" ].each { |j | require j }
167
- end
168
- ```
169
-
170
- ** Note:** in the example above, the ` .rb ` file is assuming it's in the top
171
- level of the source tree, i.e. where ` build.gradle ` is located
172
-
173
- ## Advanced Usage
174
-
175
- ### Using a custom Gem repository
176
-
177
- By default the jruby plugin will use
178
- [ rubygems-proxy.torquebox.org] ( http://rubygems-proxy.torquebox.org ) as its
179
- source of Ruby gems. This is a server operated by the Torquebox project which
180
- presents [ rubygems.org] ( https://rubygems.org ) as a Maven repository.
181
-
182
- If you ** do not** wish to use this repository, you can run your own Maven
183
- proxy repository for either rubygems.org or your own gem repository by
184
- running the [ rubygems-servlets] ( https://github.com/torquebox/rubygems-servlets )
185
- server.
186
-
187
- You can then use that custom Gem repository with:
188
-
189
- ``` groovy
190
- jruby {
191
- defaultRepositories = false
192
- }
193
-
194
- repositories {
195
- maven { url : 'http://localhost:8989/releases' }
196
- }
197
-
198
- dependencies {
199
- gems group: 'com.lookout', name: 'custom-gem', version: '1.0.+'
200
- }
201
- ```
202
65
203
66
## JRubyExec - Task for Executing a Ruby Script
204
67
@@ -287,8 +150,89 @@ task unpackMyGems( type : JRubyPrepareGems ) {
287
150
outputDir buildDir
288
151
289
152
// Add one or more gems
290
- // Can be String(s), File(s), FleCollection (s) or Configuration(s)
153
+ // Can be String(s), File(s), FileCollection (s) or Configuration(s)
291
154
gems project.configuration.gems
292
155
293
156
}
294
157
```
158
+
159
+
160
+ ## Advanced Usage
161
+
162
+ ### Using a custom Gem repository
163
+
164
+ By default the jruby plugin will use
165
+ [ rubygems-proxy.torquebox.org] ( http://rubygems-proxy.torquebox.org ) as its
166
+ source of Ruby gems. This is a server operated by the Torquebox project which
167
+ presents [ rubygems.org] ( https://rubygems.org ) as a Maven repository.
168
+
169
+ If you ** do not** wish to use this repository, you can run your own Maven
170
+ proxy repository for either rubygems.org or your own gem repository by
171
+ running the [ rubygems-servlets] ( https://github.com/torquebox/rubygems-servlets )
172
+ server.
173
+
174
+ You can then use that custom Gem repository with:
175
+
176
+ ``` groovy
177
+ jruby {
178
+ defaultRepositories = false
179
+ }
180
+
181
+ repositories {
182
+ maven { url : 'http://localhost:8989/releases' }
183
+ }
184
+
185
+ dependencies {
186
+ gems group: 'com.lookout', name: 'custom-gem', version: '1.0.+'
187
+ }
188
+ ```
189
+
190
+ ## Using the Ruby interpreter
191
+
192
+ There are still plenty of cases, such as for local development, when you might
193
+ not want to create a full ` .war ` file to run some tests. In order to use the
194
+ same gems and ` .jar ` based dependencies, add the following to the entry point
195
+ for your application:
196
+
197
+ ``` ruby
198
+ # Hack our GEM_HOME to make sure that the `rubygems` support can find our
199
+ # unpacked gems in build/vendor/
200
+ vendored_gems = File .expand_path(File .dirname(__FILE__ ) + ' /build/vendor' )
201
+ if File .exists?(vendored_gems)
202
+ ENV [' GEM_HOME' ] = vendored_gems
203
+ end
204
+
205
+ jar_cache = File .expand_path(File .dirname(__FILE__ ) + ' /.jarcache/' )
206
+ if File .exists?(jar_cache)
207
+ # Under JRuby `require`ing a `.jar` file will result in it being added to the
208
+ # classpath for easy importing
209
+ Dir [" #{ jar_cache } /*.jar" ].each { |j | require j }
210
+ end
211
+ ```
212
+
213
+ ** Note:** in the example above, the ` .rb ` file is assuming it's in the top
214
+ level of the source tree, i.e. where ` build.gradle ` is located
215
+
216
+
217
+ ## Quickstart for those unfamiliar with Gradle
218
+
219
+ ** Note:** This assumes you already have [ Gradle] ( http://gradle.org ) installed. If you are not on Windows it is recommended
220
+ that you use [ GVM] ( http://gvmtool.net ) to install Gradle
221
+
222
+ ``` bash
223
+ % mkdir fancy-webapp
224
+ % cd fancy-webapp
225
+ % git init
226
+ Initialized empty Git repository in /usr/home/tyler/source/github/fancy-webapp/.git/
227
+ % gradle wrapper init # Create the wrappers to easily bootstrap others
228
+ :wrapper
229
+ :init
230
+
231
+ BUILD SUCCESSFUL
232
+
233
+ Total time: 6.411 secs
234
+ % git add gradle gradlew gradlew.bat
235
+ % git commit -m " Initial commit with gradle wrappers"
236
+ ```
237
+
238
+ Edit the created ` build.gradle ` file in the root of ` fancy-webapp/ ` as above
0 commit comments