2014-08-25 23:39:40 +00:00
|
|
|
jruby-gradle-jar-plugin
|
|
|
|
=======================
|
|
|
|
|
2014-12-03 17:14:41 +00:00
|
|
|
[![Build Status](https://buildhive.cloudbees.com/job/jruby-gradle/job/jruby-gradle-jar-plugin/badge/icon)](https://buildhive.cloudbees.com/job/jruby-gradle/job/jruby-gradle-jar-plugin/) [![Download](https://api.bintray.com/packages/jruby-gradle/plugins/jruby-gradle-jar-plugin/images/download.png)](https://bintray.com/jruby-gradle/plugins/jruby-gradle-jar-plugin) [![Gitter chat](https://badges.gitter.im/jruby-gradle/jruby-gradle-plugin.png)](https://gitter.im/jruby-gradle/jruby-gradle-plugin)
|
2014-08-26 00:15:06 +00:00
|
|
|
|
2014-08-25 23:39:40 +00:00
|
|
|
Plugin for creating JRuby-based java archives
|
2014-08-28 00:10:34 +00:00
|
|
|
|
|
|
|
|
2014-09-13 20:09:02 +00:00
|
|
|
## Compatibility
|
2014-08-28 00:10:34 +00:00
|
|
|
|
2014-09-04 16:46:44 +00:00
|
|
|
This plugin requires Gradle 2.0 or better.
|
2014-08-28 00:10:34 +00:00
|
|
|
|
|
|
|
## Bootstrap
|
|
|
|
|
|
|
|
To add the plugin to your project
|
|
|
|
```groovy
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
jcenter()
|
|
|
|
}
|
2014-09-29 00:30:44 +00:00
|
|
|
|
2014-08-28 00:10:34 +00:00
|
|
|
dependencies {
|
2014-09-29 00:30:44 +00:00
|
|
|
classpath group: 'com.github.jruby-gradle', name: 'jruby-gradle-jar-plugin', version: '0.1.1'
|
|
|
|
classpath group: 'com.github.jruby-gradle', name: 'jruby-gradle-plugin', version: '0.1.+'
|
|
|
|
}
|
2014-08-28 00:10:34 +00:00
|
|
|
}
|
|
|
|
|
2014-09-29 00:30:44 +00:00
|
|
|
apply plugin: 'com.github.jruby-gradle.jar'
|
2014-08-28 00:10:34 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Implicit loaded plugins
|
|
|
|
|
|
|
|
This loads the following plugins if they are not already loaded:
|
2014-11-16 03:19:21 +00:00
|
|
|
|
2014-08-28 00:10:34 +00:00
|
|
|
+ `com.github.jrubygradle.base`
|
2014-09-25 09:53:05 +00:00
|
|
|
+ `java-base`
|
2014-11-16 03:19:21 +00:00
|
|
|
+ `com.github.johnrengelman.shadow`
|
2014-08-28 00:10:34 +00:00
|
|
|
|
|
|
|
## Using the plugin
|
|
|
|
|
|
|
|
This plugin does not add any new tasks or extensions, extends the `Jar` task type with a `jruby` closure. If the `java` plugin
|
|
|
|
is loaded, then the `jar` task can also be configured.
|
|
|
|
|
|
|
|
```groovy
|
2014-09-25 09:53:05 +00:00
|
|
|
apply plugin: 'java'
|
|
|
|
|
2014-08-28 00:10:34 +00:00
|
|
|
jar {
|
|
|
|
jruby {
|
2014-09-29 00:30:44 +00:00
|
|
|
|
2014-08-28 00:10:34 +00:00
|
|
|
// Use the default GEM installation directory
|
|
|
|
defaultGems()
|
|
|
|
|
2014-08-28 09:28:31 +00:00
|
|
|
// Add this GEM installation directory to the JAR.
|
|
|
|
// Can be called more than once for additional directories
|
2014-08-28 00:10:34 +00:00
|
|
|
gemDir '/path/to/my/gemDir'
|
2014-09-29 00:30:44 +00:00
|
|
|
|
2014-09-13 20:09:02 +00:00
|
|
|
// Equivalent to calling defaultGems()
|
|
|
|
defaults 'gem'
|
2014-09-29 00:30:44 +00:00
|
|
|
|
2014-08-28 00:10:34 +00:00
|
|
|
}
|
2014-09-29 00:30:44 +00:00
|
|
|
|
2014-08-28 00:10:34 +00:00
|
|
|
// All other JAR methods and properties are still valid
|
|
|
|
}
|
|
|
|
|
|
|
|
task myJar (type :Jar) {
|
|
|
|
jruby {
|
|
|
|
// As above
|
|
|
|
}
|
|
|
|
|
|
|
|
// All other JAR methods and properties are still valid
|
|
|
|
}
|
2014-09-20 00:02:00 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Controlling the Ruby entry point script
|
|
|
|
|
2014-09-29 00:30:44 +00:00
|
|
|
If nothing is specified, then the bootstrap will look for a Ruby script `META-INF/init.rb`.
|
2014-09-20 00:02:00 +00:00
|
|
|
It is also possible to set the entry script. This must be specified relative to the root of the created JAR.
|
2014-08-28 00:10:34 +00:00
|
|
|
|
2014-10-15 21:35:41 +00:00
|
|
|
**NOTE:** There is currently a [known
|
|
|
|
issue](https://github.com/jruby-gradle/jruby-gradle-jar-plugin/issues/14) with
|
|
|
|
rebuilding a `shadowJar` when using the `initScript` setting. If you change the
|
|
|
|
setting, you will need to execute the `clean` task and rebuild for it to take
|
|
|
|
effect.
|
|
|
|
|
2014-09-20 00:02:00 +00:00
|
|
|
```groovy
|
|
|
|
jrubyJavaBootstrap {
|
|
|
|
jruby {
|
|
|
|
initScript = 'bin/asciidoctor'
|
|
|
|
}
|
|
|
|
}
|
2014-08-28 00:10:34 +00:00
|
|
|
```
|
|
|
|
|
2014-09-20 00:02:00 +00:00
|
|
|
It is the user's responsibility to ensure that entry point script is created and added to the JAR, be it `META-INF/init.rb`
|
|
|
|
or another specified script.
|
|
|
|
|
|
|
|
|
2014-09-13 20:09:02 +00:00
|
|
|
## Executable JARs
|
|
|
|
|
2014-09-20 00:02:00 +00:00
|
|
|
**Please note that executable JARs are still an incubating feature**.
|
|
|
|
|
|
|
|
Executable JARs are indirectly supported via the [Gradle Shadow Jar plugin](http://plugins.gradle.org/plugin/com.github.johnrengelman.shadow).
|
|
|
|
|
|
|
|
|
|
|
|
### Configuring Shadow JAR
|
|
|
|
|
|
|
|
Configuration is exactly the same as for a normal JAR class.
|
|
|
|
|
|
|
|
```groovy
|
|
|
|
shadowJar {
|
2014-09-13 20:09:02 +00:00
|
|
|
jruby {
|
2014-09-29 00:30:44 +00:00
|
|
|
|
2014-09-20 00:02:00 +00:00
|
|
|
// Use the default bootstrap class
|
2014-09-13 20:09:02 +00:00
|
|
|
defaultMainClass()
|
2014-09-29 00:30:44 +00:00
|
|
|
|
2014-09-13 20:09:02 +00:00
|
|
|
// Make the JAR executable by supplying your own main class
|
2014-09-20 09:32:26 +00:00
|
|
|
mainClass 'my.own.main'
|
2014-09-29 00:30:44 +00:00
|
|
|
|
2014-09-13 20:09:02 +00:00
|
|
|
// Equivalent to calling defaultMainClass()
|
2014-09-20 00:02:00 +00:00
|
|
|
defaults 'gems', 'mainClass'
|
2014-09-29 00:30:44 +00:00
|
|
|
|
|
|
|
}
|
2014-09-13 20:09:02 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2014-09-20 00:02:00 +00:00
|
|
|
See [Shadow JAR README](https://github.com/johnrengelman/shadow/blob/master/README.md) for configuration specifics.
|
|
|
|
In a similar fashion to the `jar` task, the `shadowJar` task will make use of the `jrubyJavaBootstrap` task to
|
2014-09-29 00:30:44 +00:00
|
|
|
create and compile a basic bootstrap class.
|