// TODO: Remove this block once rubygems.lasagna.io is back, or jruby-gradle-jar-plugin is upgraded to 1.5.0. // See also: https://github.com/jruby-gradle/jruby-gradle-plugin/issues/297 // jruby-gradle-jar-plugin is not upgraded yet because its 1.5.0 depends on Java 8. repositories { mavenLocal() maven { url 'http://rubygems-proxy.torquebox.org/releases' } } buildscript { repositories { jcenter() } dependencies { classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3.1' classpath "com.github.jruby-gradle:jruby-gradle-jar-plugin:1.0.1" classpath 'com.github.ben-manes:gradle-versions-plugin:0.11.3' classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3' } } apply plugin: "com.github.jruby-gradle.jar" apply plugin: 'com.jfrog.bintray' apply plugin: 'com.github.johnrengelman.shadow' def java_projects = [project(":embulk-core"), project(":embulk-standards"), project(":embulk-cli"), project(":embulk-test"), project(":embulk-jruby-strptime")] def release_projects = [project(":embulk-core"), project(":embulk-standards"), project(":embulk-test"), project(":embulk-jruby-strptime")] allprojects { group = 'org.embulk' version = '0.8.38' ext { jrubyVersion = '9.1.13.0' } apply plugin: 'java' apply plugin: 'maven-publish' apply plugin: 'com.jfrog.bintray' test { maxHeapSize = "1536m" forkEvery = 1 // test processes are forked by each test class (default is 0) } // // 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 = 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() } sourceCompatibility = 1.7 targetCompatibility = 1.7 def defaultEncoding = 'UTF-8' [compileJava, compileTestJava]*.options*.encoding = defaultEncoding dependencies { testCompile 'junit:junit:4.12' } tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" //<< "-Xlint:deprecation" } tasks.withType(Test) { systemProperties System.properties.findAll { it.key.startsWith("org.embulk") } } tasks.withType(FindBugs) { reports { xml.enabled = false html.enabled = true } } findbugs { ignoreFailures = true } javadoc { options { locale = 'en_US' encoding = 'UTF-8' } } // add tests/javadoc/source jar tasks as artifacts to be released task testsJar(type: Jar, dependsOn: classes) { classifier = 'tests' from sourceSets.test.output } 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 testsJar, sourcesJar, javadocJar } } publishing { publications { if (release_projects.contains(project)) { bintrayMavenRelease(MavenPublication) { from components.java artifact testsJar artifact sourcesJar artifact javadocJar } } } } } task wrapper(type: Wrapper) { gradleVersion = '3.2.1' } import com.github.jrubygradle.JRubyExec jruby { execVersion = project.jrubyVersion } dependencies { jrubyExec 'rubygems:simplecov:0.10.+' jrubyExec 'rubygems:test-unit:3.0.+' } import java.util.zip.ZipFile import java.util.zip.ZipEntry task updateResources(dependsOn: 'classpath') { doFirst { List packages = [] List dirs = [] file("classpath").listFiles().each { jarFile -> List names = new ZipFile(jarFile.toString()).entries().iterator().collect { it.getName() } packages.addAll(names.findAll { it.endsWith(".class") }.collect { it.replaceFirst(/(?:^|\/)[^\/]*\.class$/, '').replaceAll(/\//, '.') }.unique()) dirs.addAll(names.findAll { !it.endsWith("/") && !it.endsWith(".class") }.collect { it.replaceFirst(/(?:^|\/)[^\/]*$/, '') }.unique()) } packages = packages.unique() dirs = dirs.unique() List uniquePackages = packages.clone() List uniqueDirs = dirs.clone() packages.each { pk -> uniquePackages.removeAll { it.startsWith(pk + '.') } } dirs.each { dir -> uniqueDirs.removeAll { it.startsWith(dir + '/') } } uniquePackages.removeAll { it.isEmpty() } uniqueDirs.removeAll { it.isEmpty() || it == "META-INF" } String date = new Date().format('yyyy-MM-dd HH:mm:ss z', TimeZone.getTimeZone("UTC")) file("embulk-core/src/main/resources/embulk/parent_first_packages.properties").withWriter { out -> out.println("# generated by './gradlew updateResources' at $date") uniquePackages.sort().each { out.println it } } file("embulk-core/src/main/resources/embulk/parent_first_resources.properties").withWriter { out -> out.println("# generated by './gradlew updateResources' at $date") uniqueDirs.sort().each { out.println it } } } doLast { classpath.execute() } } // // classpath task // task classpath(dependsOn: ['build', ':embulk-cli:classpath']) { doLast {} } clean { delete 'classpath' } // // cli task // task cli(dependsOn: ':embulk-cli:shadowJar') { doLast { file('pkg').mkdirs() File f = file("pkg/embulk-${project.version}.jar") f.write("") f.append("\n: <.rst file println "Ready. Run 'release' task." } } task release(dependsOn: ["cli", "releaseCheck", "bintrayUpload", "rubyGemsUpload"]) { doLast { println """ Manual operations: git commit -am v${project.version} git tag v${project.version} """ } } bintrayUpload.mustRunAfter('releaseCheck') rubyGemsUpload.mustRunAfter('releaseCheck') rubyGemsUploadJRuby.mustRunAfter('releaseCheck') task setVersion { doLast { if (!project.hasProperty("to")) { throw new GradleException("Usage: ./gradlew setVersion -Pto=VERSION") } File gradle_ver = file('build.gradle') gradle_ver.write(gradle_ver.getText().replaceFirst("version = '(\\d+)(\\.\\d+){2}'", "version = '${to}'")) // TODO(v2)[#562]: Remove this part to update the version number in lib/embulk/version.rb. // https://github.com/embulk/embulk/issues/562 File ruby_ver = file('lib/embulk/version.rb') ruby_ver.write(ruby_ver.getText().replaceFirst("VERSION_INTERNAL = '(\\d+)(\\.\\d+){2}'", "VERSION_INTERNAL = '${to}'")) List docs = [ 'README.md', ] 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" } } task updateJRuby { doLast { if (!project.hasProperty("to")) { throw new GradleException("Usage: ./gradlew updateJRuby -Pto=VERSION") } File gradle_ver = file('build.gradle') gradle_ver.write(gradle_ver.getText().replaceFirst("jrubyVersion = '(\\d+)(\\.\\d+){3}'", "jrubyVersion = '${to}'")) File gemspec_ver = file('embulk.gemspec') gemspec_ver.write(gemspec_ver.getText().replaceFirst("gem.add_dependency \"jruby-jars\", '= (\\d+)(\\.\\d+){3}'", "gem.add_dependency \"jruby-jars\", '= ${to}'")) File migrate_plugin_ver = file('embulk-cli/src/main/java/org/embulk/cli/EmbulkMigrate.java') migrate_plugin_ver.write(migrate_plugin_ver.getText().replaceFirst("\".ruby-version\", \"jruby-(\\d+)(\\.\\d+){3}\"", "\".ruby-version\", \"jruby-${to}\"")) File gemfile_lock_ver = file('Gemfile.lock') gemfile_lock_ver.write(gemfile_lock_ver.getText().replaceFirst("jruby-jars \\(= (\\d+)(\\.\\d+){3}\\)", "jruby-jars (= ${to})")) gemfile_lock_ver.write(gemfile_lock_ver.getText().replaceFirst("jruby-jars \\((\\d+)(\\.\\d+){3}\\)", "jruby-jars (${to})")) List dot_ruby_vers = [ 'lib/embulk/data/bundle/.ruby-version', 'lib/embulk/data/new/ruby/.ruby-version' ] dot_ruby_vers.each() { path -> File dot_ruby_ver = file(path) dot_ruby_ver.write(dot_ruby_ver.getText().replaceAll('jruby-(\\d+)(\\.\\d+){3}', "jruby-${to}")) } } }