Skip to content
This repository was archived by the owner on May 19, 2019. It is now read-only.

Commit 8a4f659

Browse files
committed
Updated README to reflect changes for shadowJar + minor syntatic updates for soem source files
1 parent 69d9e4f commit 8a4f659

File tree

3 files changed

+56
-30
lines changed

3 files changed

+56
-30
lines changed

README.md

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ apply plugin: 'com.github.jrubygradle.jar'
3131

3232
This loads the following plugins if they are not already loaded:
3333
+ `com.github.jrubygradle.base`
34+
+ `java`
3435

3536
## Using the plugin
3637

@@ -63,47 +64,71 @@ task myJar (type :Jar) {
6364
6465
// All other JAR methods and properties are still valid
6566
}
67+
```
68+
69+
## Controlling the Ruby entry point script
70+
71+
If nothing is specified, then the bootstrap will look for a Ruby script `META-INF/init.rb`.
72+
It is also possible to set the entry script. This must be specified relative to the root of the created JAR.
6673

74+
```groovy
75+
jrubyJavaBootstrap {
76+
jruby {
77+
initScript = 'bin/asciidoctor'
78+
}
79+
}
6780
```
6881

82+
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`
83+
or another specified script.
84+
85+
6986
## Executable JARs
7087

71-
Please note that executable JARs are still an incubating feature. At this point appropriate libs will be copied
72-
to the `META-INF/lib` directory, but a working `init.rb` is not available. It is still the responsibility of the
73-
the user to craft an appropriate `init.rb` and copy it to `META-INF` via the provided the [metaInf {}](http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.bundling.Jar.html) closure.
74-
75-
```groovy
76-
jar {
88+
**Please note that executable JARs are still an incubating feature**.
89+
90+
Executable JARs are indirectly supported via the [Gradle Shadow Jar plugin](http://plugins.gradle.org/plugin/com.github.johnrengelman.shadow).
91+
92+
93+
### Adding Shadow JAR
94+
```groovy
95+
buildscript {
96+
repositories {
97+
jcenter()
98+
}
99+
100+
dependencies {
101+
classpath 'com.github.jengelman.gradle.plugins:shadow:1.1.1'
102+
classpath group: 'com.github.jrubygradle:jruby-gradle-jar-plugin:0.1.1'
103+
}
104+
}
105+
106+
apply plugin: 'com.github.jrubygradle.jar'
107+
apply plugin: 'com.github.johnrengelman.shadow'
108+
109+
```
110+
111+
### Configuring Shadow JAR
112+
113+
Configuration is exactly the same as for a normal JAR class.
114+
115+
```groovy
116+
shadowJar {
77117
jruby {
78118
79-
// Make the JAR executable and use the default main class
119+
// Use the default bootstrap class
80120
defaultMainClass()
81121
82122
// Make the JAR executable by supplying your own main class
83123
mainClass 'my.own.main.'
84124
85125
// Equivalent to calling defaultMainClass()
86-
defaults 'mainClass'
126+
defaults 'gems', 'mainClass'
87127
88-
// Adds dependencies from this configuration into `META-INF/lib`
89-
// If none are specified, the plugin will default to 'jrubyJar','compile' & 'runtime'
90-
configurations 'myConfig'
91128
}
92129
}
93130
```
94131

95-
Using the default main class method `defaultMainClass()` will include class files from
96-
[warbler-bootstrap](https://github.com/jruby-gradle/warbler-bootstrap)
97-
98-
99-
## Controlling the version of warbler-bootstrap
100-
101-
By default the version is set to `1.+` meaning anything version 1.0 or beyond. If your project wants to lock
102-
down the specific version, then it can be set via
103-
104-
```groovy
105-
jruby {
106-
warblerBootstrapversion = '1.0.0'
107-
}
108-
```
109-
132+
See [Shadow JAR README](https://github.com/johnrengelman/shadow/blob/master/README.md) for configuration specifics.
133+
In a similar fashion to the `jar` task, the `shadowJar` task will make use of the `jrubyJavaBootstrap` task to
134+
create and compile a basic bootstrap class.

src/main/groovy/com/github/jrubygradle/jar/BootstrapClassExtension.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.github.jrubygradle.jar
22

3-
import groovy.transform.PackageScope
43
import groovy.transform.TupleConstructor
54
import org.gradle.api.GradleException
65
import org.gradle.api.Task
@@ -16,6 +15,8 @@ class BootstrapClassExtension {
1615
static final String BOOTSTRAP_TEMPLATE_PATH = 'META-INF/gradle-plugins/bootstrap.java.template'
1716

1817
/** The task this extension instance is attached to.
18+
*
19+
* @since 0.1.1
1920
*
2021
*/
2122
Task task
@@ -60,6 +61,6 @@ class BootstrapClassExtension {
6061
}
6162
}
6263

63-
}
64+
}
6465

6566
}

src/main/groovy/com/github/jrubygradle/jar/JRubyJarPlugin.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import org.gradle.api.tasks.testing.Test
1515
*/
1616
class JRubyJarPlugin implements Plugin<Project> {
1717

18-
static final String BOOTSTRAP_TASK_NAME = 'jrubyJavaStub'
18+
static final String BOOTSTRAP_TASK_NAME = 'jrubyJavaBootstrap'
1919

2020
void apply(Project project) {
2121

2222
project.apply plugin : 'com.github.jruby-gradle.base'
23-
project.apply plugin : 'java-base'
23+
project.apply plugin : 'java'
2424
project.configurations.maybeCreate('jrubyEmbeds')
2525
project.configurations.maybeCreate('jrubyJar')
2626

0 commit comments

Comments
 (0)