// // Primary gradle file for building and testing redstorm // buildscript { repositories { jcenter() } dependencies { classpath 'com.github.jruby-gradle:jruby-gradle-jar-plugin:1.0.3' classpath 'com.github.jruby-gradle:jruby-gradle-plugin:1.0.3' classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2" } } apply plugin: 'idea' apply plugin: 'maven' apply plugin: 'java' apply plugin: 'com.github.jruby-gradle.jar' apply plugin: 'com.jfrog.bintray' version = '0.9.2' group = 'com.github.jruby-gradle' description = "RedStorm integrates Ruby code via JRuby into the Storm distributed computation system" defaultTasks 'check', 'assemble' // Any time we're not expicitly saying "build me a release build" we'll change // the version to -SNAPSHOT if (!(System.env.TRAVIS_TAG as Boolean)) { version = "${version}-SNAPSHOT" } import com.github.jrubygradle.JRubyExec jruby { /* jrubyVersion defined in gradle.properties */ defaultVersion jrubyVersion execVersion jrubyVersion } repositories { jcenter() // These two repositories are for storm dependencies maven { url 'http://clojars.org/repo/' } maven { url 'http://conjars.org/repo/' } } configurations { // We don't need to include storm-core in the runtime dependencies for the // redstorm.jar since it's provided by the storm cluster this code runs on top of runtime.exclude module: 'storm-core' // Make sure that any task using the jrubyExec configuration inherits the // dependencies enumerated in the `compile` configuration jrubyExec.extendsFrom compile } dependencies { // These compile dependencies are required just to compile our Java-based // redstorm code compile 'com.github.jnr:jffi:[1.2.7,1.3)' compile 'org.apache.storm:storm-core:0.9.2-incubating' // We don't yet support JRuby 9k so we'll limit ourselfs to the 1.7.x compile "org.jruby:jruby-complete:[1.7.20,1.8)" // Gem dependencies needed to run our Ruby development tasks like 'spec' jrubyExec 'rubygems:rspec:2.99.0+' jrubyExec 'rubygems:coveralls:0.6.7+' } //////////////////////////////////////////////////////////////////////////////// // DEVELOPMENT TASKS //////////////////////////////////////////////////////////////////////////////// task compileRedstormJRuby(type: JRubyExec) { def generatedDir = file("${buildDir}/generated/java") group 'build' description "Compile the right Ruby files to Java files for compilation" inputs.dir('lib/red_storm') outputs.dir(generatedDir) workingDir 'lib/red_storm' script 'jrubyc' scriptArgs '--prefix', 'red_storm', '--java', '--target', generatedDir.absolutePath, 'topology_launcher.rb' doFirst { generatedDir.mkdirs() } } // Chain our compileJava task off of the Ruby compilation task, this makes sure // we are rebuilding the generated Java code from our Ruby files every time we // need to rebuild the jar/recompile project.compileJava.dependsOn compileRedstormJRuby task spec(type: JRubyExec) { group 'JRuby' description 'Run the RSpec examples' script 'rspec' dependsOn compileJava } check.dependsOn spec //////////////////////////////////////////////////////////////////////////////// sourceSets { main { java { srcDirs "src/main", "${buildDir}/generated/java" } } } /* Needed, according to @ysb33r to make sure we build against JDK7 */ plugins.withType(JavaPlugin) { sourceCompatibility = 1.7 targetCompatibility = 1.7 project.tasks.withType(JavaCompile) { task -> task.sourceCompatibility = project.sourceCompatibility task.targetCompatibility = project.targetCompatibility } project.tasks.withType(GroovyCompile) { task -> task.sourceCompatibility = project.sourceCompatibility task.targetCompatibility = project.targetCompatibility } } // In addition to all of the compiled java sources, we need to include the Ruby // code from ./lib in the .jar archive jar { from 'lib' } // Make sure we're created a sources jar to be published to jcenter task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } artifacts { archives sourcesJar } bintray { user = project.bintrayUser key = project.bintrayKey publish = true configurations = ['archives'] /* * Only only publish when we're tagging a release and if we've executed on * the JDK7 build. This is to prevent multiple attempts by the build matrix * to publish the artifacts */ dryRun = !((System.env.TRAVIS_TAG as boolean) && (System.env.TRAVIS_JDK_VERSION == 'openjdk7')) pkg { userOrg = 'jruby-gradle' repo = 'libraries' name = 'redstorm' labels = ['jruby', 'redstorm', 'storm'] version { name = project.version vcsTag = "v${project.version}" desc = project.description } } } bintrayUpload.dependsOn assemble install.dependsOn check, assemble idea { module { downloadJavadoc true downloadSources true } } // vim: ft=groovy et ts=4 sw=4