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