Moved code from jruby-gradle-plugin to here

This commit is contained in:
Schalk W. Cronjé 2014-08-27 18:19:06 +01:00
parent b1f74df0a3
commit 3ebf32fcdd
5 changed files with 112 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.gradle
build/
*.sw*
*.iml

View File

@ -8,7 +8,7 @@ buildscript {
}
group = 'com.github.jruby-gradle'
version = '0.1.0'
version = '0.1.1'
if (System.env.RELEASE != '1') {
version = "${version}-SNAPSHOT"

View File

@ -0,0 +1,37 @@
package com.github.jrubygradle
import org.gradle.api.Project
import org.gradle.api.tasks.bundling.Jar
/**
*
* @author R. Tyler Croy
*/
class JRubyJar extends Jar {
static final String mainClass = 'com.lookout.jruby.JarMain'
static final String JRUBYJAR_CONFIG = 'jrubyJar'
JRubyJar() {
super()
description 'Create a JRuby-based .jar file'
// Bring in any compiled classes from our project
from "$project.buildDir/classes/main"
// By adding the JarMain class as the main-class we can have a
// runnable jar
manifest {
attributes 'Main-Class' : mainClass
}
}
/** Update dependencies on the project to include those necessary for
* building JRubyJar's
*/
static void updateJRubyDependencies(Project project) {
project.dependencies {
jrubyJar group: 'org.jruby', name: 'jruby-complete', version: project.jruby.defaultVersion
}
}
}

View File

@ -0,0 +1,40 @@
package com.github.jrubygradle
/**
* Created by schalkc on 27/08/2014.
*/
class JRubyJarPlugin {
void apply(Project project) {
// MIGHT NEED: project.apply plugin: 'java', 'java-base'
project.configurations.create(JRubyWar.JRUBYWAR_CONFIG)
// TODO: Should probably check whether it exists before creating it
project.configurations {
jrubyEmbeds
}
project.dependencies {
jrubyEmbeds group: 'com.lookout', name: 'warbler-bootstrap', version: '1.+'
}
// TODO: This will depend on which plugin we pull in
// // In order to update the testing cycle we need to tell unit tests where to
// // find GEMs. We are assuming that if someone includes this plugin, that they
// // will be writing tests that includes jruby and that they might need some
// // GEMs as part of the tests.
// project.tasks.test {
// environment GEM_HOME : project.extensions.getByName('jruby').gemInstallDir
// dependsOn 'jrubyPrepareGems'
// }
project.task('jrubyJar', type: JRubyJar) {
group JRubyPlugin.TASK_GROUP_NAME
dependsOn project.tasks.jrubyPrepare
dependsOn project.tasks.classes
}
}
}

View File

@ -0,0 +1,33 @@
package com.github.jrubygradle
import org.gradle.testfixtures.ProjectBuilder
import spock.lang.*
import static org.gradle.api.logging.LogLevel.*
/**
* @author R. Tyler Croy
*
*/
class JRubyJarSpec extends Specification {
static final File TEST_SCRIPT_DIR = new File( System.getProperty('TEST_SCRIPT_DIR') ?: 'src/test/resources/scripts')
static final File TESTROOT = new File(System.getProperty('TESTROOT') ?: 'build/tmp/test/unittests')
static final String TASK_NAME = 'JarJar'
def project
def jarTask
void setup() {
project = ProjectBuilder.builder().build()
project.buildDir = TESTROOT
project.logging.level = LIFECYCLE
project.apply plugin: 'com.github.jruby-gradle.base'
jarTask = project.task(TASK_NAME, type: JRubyJar)
}
def "basic sanity check"() {
expect: "jarTask to be an instance"
jarTask instanceof JRubyJar
project.tasks.jrubyJar.group == 'JRuby'
}
}