plugins { id 'com.jfrog.bintray' version '1.1' id 'com.github.ben-manes.versions' version '0.7' id 'com.github.jruby-gradle.base' version '0.1.5' id 'com.github.johnrengelman.shadow' version '1.2.0' } import com.github.jrubygradle.JRubyExec def java_projects = [project(":embulk-core"), project(":embulk-standards"), project(":embulk-cli")] def release_projects = [project(":embulk-core"), project(":embulk-standards")] allprojects { group = 'org.embulk' version = '0.4.9' apply plugin: 'java' apply plugin: 'maven-publish' apply plugin: 'com.jfrog.bintray' // // bintrayUpload task // bintray { // write at your bintray user name and api key to ~/.gradle/gradle.properties file: // bintray_user=frsyuki // bintray_api_key=xxxxxxxxxxx user = project.hasProperty('bintray_user') ? bintray_user : '' key = project.hasProperty('bintray_api_key') ? bintray_api_key : '' publications = ['bintrayMavenRelease'] filesSpec { // include embulk-.jar built by 'cli' task from "pkg/embulk-${project.version}.jar" into "." } dryRun = false publish = false // TODO automate uploading embulk.jar and make this true pkg { userOrg = 'embulk' repo = 'maven' name = 'embulk' desc = 'Embulk, a plugin-based parallel bulk data loader' websiteUrl = 'https://github.com/embulk/embulk' issueTrackerUrl = 'https://github.com/embulk/embulk/issues' vcsUrl = 'https://github.com/embulk/embulk.git' licenses = ['Apache-2.0'] labels = ['embulk', 'ruby', 'java'] publicDownloadNumbers = true version { name = project.version // TODO //mavenCentralSync { // sync = true // user = 'userToken' // password = 'paasword' // close = '1' //} } } } } subprojects { if (java_projects.contains(project)) { apply plugin: 'maven' apply plugin: 'findbugs' apply plugin: 'jacoco' repositories { mavenCentral() jcenter() } compileJava.options.encoding = 'UTF-8' // source encoding sourceCompatibility = 1.7 targetCompatibility = 1.7 dependencies { testCompile 'junit:junit:4.12' } tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" //<< "-Xlint:deprecation" } tasks.withType(FindBugs) { reports { xml.enabled = false html.enabled = true } } findbugs { ignoreFailures = true } javadoc { options { locale = 'en_US' encoding = 'UTF-8' } } // add javadoc/source jar tasks as artifacts to be released task sourcesJar(type: Jar, dependsOn: classes) { classifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives sourcesJar, javadocJar } } publishing { publications { if (release_projects.contains(project)) { bintrayMavenRelease(MavenPublication) { from components.java artifact sourcesJar artifact javadocJar } } } } } dependencies { jrubyExec 'rubygems:test-unit:3.0.+' } // // classpath task // task classpath(dependsOn: ['build', ':embulk-cli:classpath']) << { } clean { delete 'classpath' } // // cli task // task cli(dependsOn: ':embulk-cli:shadowJar') << { file('pkg').mkdirs() File f = file("pkg/embulk-${project.version}.jar") f.write("") f.append(file("embulk-cli/src/main/sh/selfrun.sh").readBytes()) f.append(file("embulk-cli/build/libs/embulk-cli-${project.version}-all.jar").readBytes()) f.setExecutable(true) } bintrayUpload.dependsOn(['cli']) project(':embulk-cli') { apply plugin: 'com.github.johnrengelman.shadow' shadowJar { manifest { attributes 'Implementation-Title': project.name, 'Implementation-Version': project.version, 'Implementation-Vendor-Id': project.group, 'Specification-Title': project.name, 'Specification-Version': project.version, 'Main-Class': 'org.embulk.cli.Main' } append("${rootProject.projectDir}/COPYING") } task classpath(type: Copy) { doFirst { file("${rootProject.projectDir}/classpath").mkdirs() } from configurations.runtime into "${rootProject.projectDir}/classpath" } } task rubyTest(type: JRubyExec) { jrubyArgs '-Ilib', '-Itest', '-rtest/unit', '-eTest::Unit::AutoRunner.run(true, *ARGV)' script 'test' } // // gem task // task gem(type: JRubyExec) { jrubyArgs '-rrubygems/gem_runner', '-eGem::GemRunner.new.run(ARGV)', 'build' script 'embulk.gemspec' doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") } } gem.dependsOn('classpath') // // rubyGemsUpload task // task rubyGemsUpload(type: JRubyExec, dependsOn: ["gem"]) { jrubyArgs '-rrubygems/gem_runner', '-eGem::GemRunner.new.run(ARGV)', 'push' script "pkg/embulk-${project.version}.gem" } // // releaseCheck and release tasks // task releaseCheck << { if (!file("lib/embulk/version.rb").getText().contains("${project.version}")) { throw new GradleException("lib/embulk/version.rb doesn't include ${project.version}") } if (!file("embulk-docs/src/release/release-${project.version}.rst").getText().contains("${project.version}")) { throw new GradleException("Release note for ${project.version} doesn't exist") } if (!file("embulk-docs/src/release.rst").getText().contains("release-${project.version}")) { throw new GradleException("embulk-docs/src/release.rst doesn't include release-${project.version}") } String date = new Date().format("yyyy-MM-dd") if (!file("embulk-docs/src/release/release-${project.version}.rst").getText().contains(date)) { throw new GradleException("embulk-docs/src/release/release-${project.version}.rst doesn't include today's release date") } // TODO check git-ls-files includes release-.rst file println "Ready. Run 'release' task." } task release(dependsOn: ["releaseCheck", "bintrayUpload", "rubyGemsUpload"]) << { println """ Manual operations: git commit -am v${project.version} git tag v${project.version} """ } bintrayUpload.mustRunAfter('releaseCheck') rubyGemsUpload.mustRunAfter('releaseCheck') task set_version << { if (!project.hasProperty("to")) { throw new GradleException("Usage: ./gradlew -Pto=VERSION") } File gradle_ver = file('build.gradle') gradle_ver.write(gradle_ver.getText().replaceFirst("version = '(\\d+)(\\.\\d+){2}'", "version = '${to}'")) File ruby_ver = file('lib/embulk/version.rb') ruby_ver.write(ruby_ver.getText().replaceFirst("VERSION = '(\\d+)(\\.\\d+){2}'", "VERSION = '${to}'")) List docs = [ 'README.md', 'embulk-docs/src/recipe/scheduled-csv-load-to-elasticsearch-kibana4.rst' ] docs.each() { path -> File doc = file(path) doc.write(doc.getText().replaceAll('embulk-(\\d+)(\\.\\d+){2}', "embulk-${to}")) } file("embulk-docs/src/release/release-${to}.rst").append("") "git add embulk-docs/src/release/release-${to}.rst".execute().waitFor() println "add 'release/release-${to}' line to embulk-docs/src/release.rst" }