Skip to content

Commit b67edfd

Browse files
committed
Towards ISSUE #42. Placed some config back into jrubyWar & jrubyJar
1 parent 501ba7a commit b67edfd

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

src/main/groovy/com/lookout/jruby/JRubyJar.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ class JRubyJar extends Jar {
1414

1515
JRubyJar() {
1616
super()
17-
group JRubyPlugin.TASK_GROUP_NAME
1817
description 'Create a JRuby-based .jar file'
19-
dependsOn project.tasks.jrubyPrepare
2018

2119
// Bring in any compiled classes from our project
2220
from "$project.buildDir/classes/main"

src/main/groovy/com/lookout/jruby/JRubyPlugin.groovy

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ class JRubyPlugin implements Plugin<Project> {
5151
jrubyEmbeds group: 'com.lookout', name: 'warbler-bootstrap', version: '1.+'
5252
}
5353

54+
// In order to update the testing cycle we need to tell
55+
project.tasks.test {
56+
environment GEM_HOME : project.extensions.getByName('jruby').gemInstallDir
57+
dependsOn 'jrubyPrepareGems'
58+
}
59+
5460
JRubyExec.updateJRubyDependencies(project)
5561
JRubyWar.updateJRubyDependencies(project)
5662
}
@@ -84,8 +90,21 @@ class JRubyPlugin implements Plugin<Project> {
8490
dependsOn project.tasks.jrubyCacheJars, project.tasks.jrubyPrepareGems
8591
}
8692

87-
project.task('jrubyWar', type: JRubyWar)
88-
project.task('jrubyJar', type: JRubyJar)
93+
// Only jRubyWar will depend on jrubyPrepare. Other JRubyWar tasks created by
94+
// build script authors will be under their own control
95+
// jrubyWar task will use jrubyWar as configuration
96+
project.task('jrubyWar', type: JRubyWar) {
97+
group JRubyPlugin.TASK_GROUP_NAME
98+
description 'Create a JRuby-based web archive'
99+
dependsOn project.tasks.jrubyPrepare
100+
classpath project.configurations.jrubyWar
101+
}
102+
103+
project.task('jrubyJar', type: JRubyJar) {
104+
group JRubyPlugin.TASK_GROUP_NAME
105+
dependsOn project.tasks.jrubyPrepare
106+
dependsOn project.tasks.classes
107+
}
89108
}
90109

91110
}

src/main/groovy/com/lookout/jruby/JRubyWar.groovy

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.lookout.jruby
22

33
import org.gradle.api.Project
4+
import org.gradle.api.tasks.Input
45
import org.gradle.api.tasks.bundling.War
56

67
/**
@@ -9,14 +10,17 @@ import org.gradle.api.tasks.bundling.War
910
*/
1011
class JRubyWar extends War {
1112

12-
static final String mainClass = 'com.lookout.jruby.WarMain'
13+
static final String JRUBYWAR_MAINCLASS = 'com.lookout.jruby.WarMain'
1314
static final String JRUBYWAR_CONFIG = 'jrubyWar'
1415

16+
/** Setting the main class allows for a runnable War.
17+
* By default the value is {@code JRUBYWAR_MAINCLASS}
18+
*/
19+
@Input
20+
String mainClass = JRUBYWAR_MAINCLASS
21+
1522
JRubyWar() {
1623
super()
17-
group JRubyPlugin.TASK_GROUP_NAME
18-
description 'Create a JRuby-based web archive'
19-
dependsOn project.tasks.jrubyPrepare
2024

2125
// Bring in any compiled classes from our project
2226
from "$project.buildDir/classes/main"
@@ -27,10 +31,6 @@ class JRubyWar extends War {
2731
into 'gems'
2832
}
2933

30-
// Bring the jrubyWar configuration's dependencies into
31-
// WEB-INF/libs
32-
classpath project.configurations.jrubyWar
33-
3434
// note that zipTree call is wrapped in closure so that configuration
3535
// is only resolved at execution time. This will take the embeds
3636
// from within the `jrubyEmbeds` configuration and dump them into the war
@@ -39,12 +39,14 @@ class JRubyWar extends War {
3939
project.zipTree(it)
4040
}
4141
}
42+
}
4243

43-
// By adding the WarMain class as the main-class we can have a
44-
// runnable war
44+
@Override
45+
void copy() {
4546
manifest {
4647
attributes 'Main-Class' : mainClass
4748
}
49+
super.copy()
4850
}
4951

5052
/** Update dependencies on the project to include those necessary for

src/test/groovy/com/lookout/jruby/JRubyWarSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ class JRubyWarSpec extends Specification {
2828
def "basic sanity check"() {
2929
expect: "warTask to be an instance"
3030
warTask instanceof JRubyWar
31-
warTask.group == 'JRuby'
31+
project.tasks.jrubyWar.group == 'JRuby'
3232
}
3333
}

0 commit comments

Comments
 (0)