File tree Expand file tree Collapse file tree 4 files changed +76
-1
lines changed
main/groovy/com/lookout/jruby
test/groovy/com/lookout/jruby Expand file tree Collapse file tree 4 files changed +76
-1
lines changed Original file line number Diff line number Diff line change
1
+ package com.lookout.jruby
2
+
3
+ import org.gradle.api.Project
4
+ import org.gradle.api.tasks.bundling.Jar
5
+
6
+ /**
7
+ *
8
+ * @author R. Tyler Croy
9
+ */
10
+ class JRubyJar extends Jar {
11
+
12
+ static final String mainClass = ' com.lookout.jruby.JarMain'
13
+ static final String JRUBYJAR_CONFIG = ' jrubyJar'
14
+
15
+ JRubyJar () {
16
+ super ()
17
+ group JRubyPlugin . TASK_GROUP_NAME
18
+ description ' Create a JRuby-based .jar file'
19
+ dependsOn project. tasks. jrubyPrepare
20
+
21
+ // Bring in any compiled classes from our project
22
+ from " $project . buildDir /classes/main"
23
+
24
+ // By adding the JarMain class as the main-class we can have a
25
+ // runnable jar
26
+ manifest {
27
+ attributes ' Main-Class' : mainClass
28
+ }
29
+ }
30
+
31
+ /* * Update dependencies on the project to include those necessary for
32
+ * building JRubyJar's
33
+ */
34
+ static void updateJRubyDependencies (Project project ) {
35
+ project. dependencies {
36
+ jrubyJar group : ' org.jruby' , name : ' jruby-complete' , version : project. jruby. defaultVersion
37
+ }
38
+ }
39
+ }
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ class JRubyPlugin implements Plugin<Project> {
31
31
32
32
project. configurations. create(JRubyExec . JRUBYEXEC_CONFIG )
33
33
project. configurations. create(JRubyWar . JRUBYWAR_CONFIG )
34
+ project. configurations. create(JRubyJar . JRUBYJAR_CONFIG )
34
35
JRubyExecDelegate . addToProject(project)
35
36
36
37
// In order for jrubyWar to work we'll need to pull in the warbler
@@ -84,6 +85,7 @@ class JRubyPlugin implements Plugin<Project> {
84
85
}
85
86
86
87
project. task(' jrubyWar' , type : JRubyWar )
88
+ project. task(' jrubyJar' , type : JRubyJar )
87
89
}
88
90
89
91
}
Original file line number Diff line number Diff line change
1
+ package com.lookout.jruby
2
+
3
+ import org.gradle.testfixtures.ProjectBuilder
4
+ import spock.lang.*
5
+ import static org.gradle.api.logging.LogLevel.*
6
+
7
+ /**
8
+ * @author R. Tyler Croy
9
+ *
10
+ */
11
+ class JRubyJarSpec extends Specification {
12
+ static final File TEST_SCRIPT_DIR = new File ( System . getProperty(' TEST_SCRIPT_DIR' ) ?: ' src/test/resources/scripts' )
13
+ static final File TESTROOT = new File (System . getProperty(' TESTROOT' ) ?: ' build/tmp/test/unittests' )
14
+ static final String TASK_NAME = ' JarJar'
15
+
16
+ def project
17
+ def jarTask
18
+
19
+ void setup () {
20
+ project = ProjectBuilder . builder(). build()
21
+ project. buildDir = TESTROOT
22
+ project. logging. level = LIFECYCLE
23
+ project. apply plugin : ' com.lookout.jruby'
24
+ jarTask = project. task(TASK_NAME , type : JRubyJar )
25
+
26
+ }
27
+
28
+ def " basic sanity check" () {
29
+ expect : " jarTask to be an instance"
30
+ jarTask instanceof JRubyJar
31
+ jarTask. group == ' JRuby'
32
+ }
33
+ }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ package com.lookout.jruby
3
3
import org.gradle.api.*
4
4
import org.gradle.api.tasks.*
5
5
import org.gradle.api.artifacts.repositories.*
6
- import org.gradle.api.tasks.bundling.War
6
+ import org.gradle.api.tasks.bundling.*
7
7
8
8
import org.gradle.testfixtures.ProjectBuilder
9
9
@@ -43,6 +43,7 @@ class JRubyPluginTest {
43
43
public void jrubyPluginAddsPrimaryTasks () {
44
44
assertTrue (project. tasks. jrubyPrepare instanceof Task )
45
45
assertTrue (project. tasks. jrubyWar instanceof War )
46
+ assertTrue (project. tasks. jrubyJar instanceof Jar )
46
47
assertTrue (project. tasks. jrubyClean instanceof Delete )
47
48
}
48
49
You can’t perform that action at this time.
0 commit comments