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

Commit 3ebf32f

Browse files
committed
Moved code from jruby-gradle-plugin to here
1 parent b1f74df commit 3ebf32f

File tree

5 files changed

+112
-1
lines changed

5 files changed

+112
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.gradle
22
build/
33
*.sw*
4+
*.iml

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
group = 'com.github.jruby-gradle'
11-
version = '0.1.0'
11+
version = '0.1.1'
1212

1313
if (System.env.RELEASE != '1') {
1414
version = "${version}-SNAPSHOT"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.github.jrubygradle
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+
description 'Create a JRuby-based .jar file'
18+
19+
// Bring in any compiled classes from our project
20+
from "$project.buildDir/classes/main"
21+
22+
// By adding the JarMain class as the main-class we can have a
23+
// runnable jar
24+
manifest {
25+
attributes 'Main-Class' : mainClass
26+
}
27+
}
28+
29+
/** Update dependencies on the project to include those necessary for
30+
* building JRubyJar's
31+
*/
32+
static void updateJRubyDependencies(Project project) {
33+
project.dependencies {
34+
jrubyJar group: 'org.jruby', name: 'jruby-complete', version: project.jruby.defaultVersion
35+
}
36+
}
37+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.github.jrubygradle
2+
3+
/**
4+
* Created by schalkc on 27/08/2014.
5+
*/
6+
class JRubyJarPlugin {
7+
void apply(Project project) {
8+
// MIGHT NEED: project.apply plugin: 'java', 'java-base'
9+
10+
project.configurations.create(JRubyWar.JRUBYWAR_CONFIG)
11+
12+
// TODO: Should probably check whether it exists before creating it
13+
project.configurations {
14+
jrubyEmbeds
15+
}
16+
17+
project.dependencies {
18+
jrubyEmbeds group: 'com.lookout', name: 'warbler-bootstrap', version: '1.+'
19+
}
20+
21+
// TODO: This will depend on which plugin we pull in
22+
// // In order to update the testing cycle we need to tell unit tests where to
23+
// // find GEMs. We are assuming that if someone includes this plugin, that they
24+
// // will be writing tests that includes jruby and that they might need some
25+
// // GEMs as part of the tests.
26+
// project.tasks.test {
27+
// environment GEM_HOME : project.extensions.getByName('jruby').gemInstallDir
28+
// dependsOn 'jrubyPrepareGems'
29+
// }
30+
31+
project.task('jrubyJar', type: JRubyJar) {
32+
group JRubyPlugin.TASK_GROUP_NAME
33+
dependsOn project.tasks.jrubyPrepare
34+
dependsOn project.tasks.classes
35+
}
36+
37+
}
38+
39+
40+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.github.jrubygradle
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.github.jruby-gradle.base'
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+
project.tasks.jrubyJar.group == 'JRuby'
32+
}
33+
}

0 commit comments

Comments
 (0)