From 4c2a3f35b846873f6c62b7f00de48ba170be2c94 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Mon, 20 Jan 2014 12:47:01 +0000 Subject: [PATCH 01/26] Remove redundant build configuration. The value being specified is the conventional default. --- build.gradle | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build.gradle b/build.gradle index 090d9b6336..22c39dca7a 100644 --- a/build.gradle +++ b/build.gradle @@ -71,7 +71,3 @@ subprojects { } } } - -project(':rxjava-core') { - sourceSets.test.java.srcDir 'src/test/java' -} From a27388bba792278075d9dd15c602636da7f53494 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Mon, 20 Jan 2014 17:19:58 +0000 Subject: [PATCH 02/26] Remove unnecessary configuration for scala compilation. --- language-adaptors/rxjava-scala/build.gradle | 26 +-------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/language-adaptors/rxjava-scala/build.gradle b/language-adaptors/rxjava-scala/build.gradle index 8083feaf37..a30f152ba5 100644 --- a/language-adaptors/rxjava-scala/build.gradle +++ b/language-adaptors/rxjava-scala/build.gradle @@ -13,31 +13,7 @@ tasks.withType(ScalaCompile) { } sourceSets { - main { - scala { - srcDir 'src/main/scala' - } - } - test { - scala { - srcDir 'src/main/scala' - srcDir 'src/test/scala' - srcDir 'src/examples/scala' - //srcDir 'src/examples/java' - } - java.srcDirs = [] - } - examples { - // It seems that in Gradle, the dependency "compileScala depends on compileJava" is hardcoded, - // or at least not meant to be removed. - // However, compileScala also runs javac at the very end, so we just add the Java sources to - // the scala source set: - scala { - srcDir 'src/examples/scala' - //srcDir 'src/examples/java' - } - java.srcDirs = [] - } + test.scala.srcDir 'src/examples/scala' } dependencies { From 3753da2adb5510c3f3bdc1db079cbb3cadc09dde Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 10:10:57 +0000 Subject: [PATCH 03/26] Simplify build configuration. - Make extra 'examples' and 'perf' source sets super sets of test classpaths (simplifies IDE configuration) - Consolidate all standard configuration to convention.gradle - Remove redundant configuration - Use more conventional configuration idioms --- build.gradle | 62 ++----------- gradle/convention.gradle | 88 ++++++++++++++----- language-adaptors/rxjava-groovy/build.gradle | 4 +- language-adaptors/rxjava-scala/build.gradle | 19 +--- .../rx/lang/scala/examples/MovieLibUsage.java | 0 5 files changed, 79 insertions(+), 94 deletions(-) rename language-adaptors/rxjava-scala/src/examples/{java => scala}/rx/lang/scala/examples/MovieLibUsage.java (100%) diff --git a/build.gradle b/build.gradle index 22c39dca7a..caec0a87e0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,5 @@ ext.githubProjectName = 'RxJava' -apply from: file('gradle/convention.gradle') -apply from: file('gradle/maven.gradle') -//apply from: file('gradle/check.gradle') -apply from: file('gradle/license.gradle') -apply from: file('gradle/release.gradle') - buildscript { repositories { mavenLocal() @@ -15,59 +9,19 @@ buildscript { } allprojects { + group = "com.netflix.rxjava" + apply plugin: 'eclipse' apply plugin: 'idea' + repositories { mavenLocal() mavenCentral() // maven { url: 'http://jcenter.bintray.com/' } } } -subprojects { - apply plugin: 'java' - group = "com.netflix.rxjava" - - // make 'examples' use the same classpath - configurations { - examplesCompile.extendsFrom compile - examplesRuntime.extendsFrom runtime - perfCompile.extendsFrom compile - perfRuntime.extendsFrom runtime - } - - - tasks.withType(Javadoc).each { - it.classpath = sourceSets.main.compileClasspath - } - - sourceSets { - //include /src/examples folder - examples - //include /src/perf folder - // perf //-> Not working so commented out - } - - tasks.build { - //include 'examples' in build task - dependsOn(examplesClasses) - //include 'perf' in build task - // dependsOn(perfClasses) //-> Not working so commented out - } - - eclipse { - classpath { - // include 'provided' dependencies on the classpath - plusConfigurations += configurations.provided - - downloadSources = true - downloadJavadoc = true - } - } - - idea { - module { - // include 'provided' dependencies on the classpath - scopes.PROVIDED.plus += configurations.provided - } - } -} +apply from: file('gradle/convention.gradle') +apply from: file('gradle/maven.gradle') +//apply from: file('gradle/check.gradle') +apply from: file('gradle/license.gradle') +apply from: file('gradle/release.gradle') diff --git a/gradle/convention.gradle b/gradle/convention.gradle index f581db7cc5..84068a0a5a 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -1,7 +1,8 @@ // GRADLE-2087 workaround, perform after java plugin -status = project.hasProperty('preferredStatus')?project.preferredStatus:(version.contains('SNAPSHOT')?'snapshot':'release') +status = project.hasProperty('preferredStatus') ? project.preferredStatus : (version.contains('SNAPSHOT') ? 'snapshot' : 'release') subprojects { project -> + apply plugin: 'java' // Plugin as major conventions sourceCompatibility = 1.6 @@ -9,23 +10,25 @@ subprojects { project -> // Restore status after Java plugin status = rootProject.status - task sourcesJar(type: Jar, dependsOn:classes) { + task sourcesJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource classifier 'sources' extension 'jar' } - task javadocJar(type: Jar, dependsOn:javadoc) { + task javadocJar(type: Jar, dependsOn: javadoc) { from javadoc.destinationDir classifier 'javadoc' extension 'jar' } - configurations.create('sources') - configurations.create('javadoc') - configurations.archives { - extendsFrom configurations.sources - extendsFrom configurations.javadoc + configurations { + create("sources") + create("javadoc") + archives { + extendsFrom configurations.sources + extendsFrom configurations.javadoc + } } // When outputing to an Ivy repo, we want to use the proper type field @@ -56,26 +59,72 @@ subprojects { project -> } } - project.sourceSets { - main.compileClasspath += project.configurations.provided - main.runtimeClasspath -= project.configurations.provided - test.compileClasspath += project.configurations.provided - test.runtimeClasspath += project.configurations.provided + sourceSets { + main { + compileClasspath += configurations.provided + runtimeClasspath -= configurations.provided + } + test { + compileClasspath += configurations.provided + runtimeClasspath += configurations.provided + } + examples { + compileClasspath += configurations.provided + main.output + } + perf { + compileClasspath += configurations.provided + main.output + } + } + + configurations { + examplesCompile.extendsFrom testCompile + examplesRuntime.extendsFrom testRuntime + perfCompile.extendsFrom testCompile + perfRuntime.extendsFrom testRuntime + } + + build { + dependsOn examplesClasses } + + // Individual projects will apply specific language plugins which add to source sets… + // do this late so we get those additions + afterEvaluate { + idea { + module { + [sourceSets.examples, sourceSets.perf].each { + [it.allSource.srcDirs, it.resources.srcDirs].each { + testSourceDirs += it + } + } + scopes.PROVIDED.plus += configurations.provided + } + } + + eclipse { + classpath { + plusConfigurations += configurations.provided + downloadJavadoc = true + } + } + } + } apply plugin: 'github-pages' // Used to create publishGhPages task def docTasks = [:] -[Javadoc,ScalaDoc,Groovydoc].each{ Class docClass -> - def allSources = allprojects.tasks*.withType(docClass).flatten()*.source +[Javadoc, ScalaDoc, Groovydoc].each { Class docClass -> + def allSources = allprojects.tasks*.withType(docClass).flatten()*.source if (allSources) { def shortName = docClass.simpleName.toLowerCase() def docTask = task "aggregate${shortName.capitalize()}"(type: docClass, description: "Aggregate subproject ${shortName}s") { source = allSources destinationDir = file("${project.buildDir}/docs/${shortName}") doFirst { - def classpaths = allprojects.findAll { it.plugins.hasPlugin(JavaPlugin) }.collect { it.sourceSets.main.compileClasspath } + def classpaths = allprojects.findAll { it.plugins.hasPlugin(JavaPlugin) }.collect { + it.sourceSets.main.compileClasspath + } classpath = files(classpaths) } } @@ -93,9 +142,4 @@ githubPages { } } } -} - -// Generate wrapper, which is distributed as part of source to alleviate the need of installing gradle -task createWrapper(type: Wrapper) { - gradleVersion = '1.6' -} +} \ No newline at end of file diff --git a/language-adaptors/rxjava-groovy/build.gradle b/language-adaptors/rxjava-groovy/build.gradle index c26a383a34..f45b0d8fb6 100644 --- a/language-adaptors/rxjava-groovy/build.gradle +++ b/language-adaptors/rxjava-groovy/build.gradle @@ -4,8 +4,8 @@ apply plugin: 'osgi' dependencies { compile project(':rxjava-core') compile 'org.codehaus.groovy:groovy-all:2.+' - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' } jar { diff --git a/language-adaptors/rxjava-scala/build.gradle b/language-adaptors/rxjava-scala/build.gradle index a30f152ba5..046be2c505 100644 --- a/language-adaptors/rxjava-scala/build.gradle +++ b/language-adaptors/rxjava-scala/build.gradle @@ -12,26 +12,13 @@ tasks.withType(ScalaCompile) { } } -sourceSets { - test.scala.srcDir 'src/examples/scala' -} - dependencies { compile 'org.scala-lang:scala-library:2.10.+' - compile project(':rxjava-core') - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' - provided 'org.scalatest:scalatest_2.10:1.9.1' -} - -tasks.compileScala { - classpath = classpath + (configurations.compile + configurations.provided) -} - -tasks.compileExamplesScala { - classpath = classpath + files(compileScala.destinationDir) + (configurations.compile + configurations.provided) + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' + testCompile 'org.scalatest:scalatest_2.10:1.9.1' } // Add RxJava core to Scaladoc input: diff --git a/language-adaptors/rxjava-scala/src/examples/java/rx/lang/scala/examples/MovieLibUsage.java b/language-adaptors/rxjava-scala/src/examples/scala/rx/lang/scala/examples/MovieLibUsage.java similarity index 100% rename from language-adaptors/rxjava-scala/src/examples/java/rx/lang/scala/examples/MovieLibUsage.java rename to language-adaptors/rxjava-scala/src/examples/scala/rx/lang/scala/examples/MovieLibUsage.java From d970e6db818f246c2be4b8755f6a9b82c12ceefe Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 11:20:35 +0000 Subject: [PATCH 04/26] Cleanup clojure project buildscript. --- language-adaptors/rxjava-clojure/build.gradle | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/language-adaptors/rxjava-clojure/build.gradle b/language-adaptors/rxjava-clojure/build.gradle index 6e59b61305..dfc5083f48 100644 --- a/language-adaptors/rxjava-clojure/build.gradle +++ b/language-adaptors/rxjava-clojure/build.gradle @@ -1,46 +1,30 @@ +buildscript { + repositories { maven { url "http://clojars.org/repo" } } + dependencies { classpath "clojuresque:clojuresque:1.5.8" } +} + apply plugin: 'clojure' apply plugin: 'osgi' +repositories { + clojarsRepo() +} + dependencies { compile project(':rxjava-core') - - // clojure compile 'org.clojure:clojure:1.4.+' - - // this should be 'compile' for the 'examples' module ... can't figure that out right now so making 'provided' - provided 'clj-http:clj-http:0.6.4' // https://clojars.org/clj-http + compile 'clj-http:clj-http:0.6.4' // https://clojars.org/clj-http } -tasks.compileExamplesClojure.classpath = files(tasks.compileClojure.destinationDir) + tasks.compileClojure.classpath - -/* - * Clojure - */ aotCompile = true warnOnReflection = false -buildscript { - repositories { maven { url "http://clojars.org/repo" } } - dependencies { classpath "clojuresque:clojuresque:1.5.8" } -} - -repositories { - clojarsRepo() -} - -/* - * Add Counterclockwise and include 'provided' dependencies - */ eclipse { project { natures "ccw.nature" } } -tasks.clojureTest { - classpath = classpath + configurations.provided -} - jar { manifest { name = 'rxjava-clojure' From 98446dd8efeca485cae1e6669acebdeef0f42421 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 11:32:45 +0000 Subject: [PATCH 05/26] Cleanup rxjava-computation-expressions build script. --- rxjava-contrib/rxjava-computation-expressions/build.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rxjava-contrib/rxjava-computation-expressions/build.gradle b/rxjava-contrib/rxjava-computation-expressions/build.gradle index 21bc395344..c334b53adf 100644 --- a/rxjava-contrib/rxjava-computation-expressions/build.gradle +++ b/rxjava-contrib/rxjava-computation-expressions/build.gradle @@ -5,9 +5,8 @@ targetCompatibility = JavaVersion.VERSION_1_6 dependencies { compile project(':rxjava-core') - testCompile project(":rxjava-core").sourceSets.test.output - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' } jar { From 25dc7b9712ec9587e62048b635c5757a57ef2905 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 11:36:25 +0000 Subject: [PATCH 06/26] Only need to specify compatibility level in one place. --- gradle/convention.gradle | 3 ++- rxjava-contrib/rxjava-apache-http/build.gradle | 3 --- rxjava-contrib/rxjava-async-util/build.gradle | 3 --- rxjava-contrib/rxjava-computation-expressions/build.gradle | 3 --- rxjava-contrib/rxjava-string/build.gradle | 3 --- rxjava-contrib/rxjava-swing/build.gradle | 3 --- rxjava-core/build.gradle | 3 --- 7 files changed, 2 insertions(+), 19 deletions(-) diff --git a/gradle/convention.gradle b/gradle/convention.gradle index 84068a0a5a..ab48c42265 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -5,7 +5,8 @@ subprojects { project -> apply plugin: 'java' // Plugin as major conventions - sourceCompatibility = 1.6 + sourceCompatibility = JavaVersion.VERSION_1_6 + targetCompatibility = JavaVersion.VERSION_1_6 // Restore status after Java plugin status = rootProject.status diff --git a/rxjava-contrib/rxjava-apache-http/build.gradle b/rxjava-contrib/rxjava-apache-http/build.gradle index 81d150ccc3..ae7590a43b 100644 --- a/rxjava-contrib/rxjava-apache-http/build.gradle +++ b/rxjava-contrib/rxjava-apache-http/build.gradle @@ -1,8 +1,5 @@ apply plugin: 'osgi' -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - dependencies { compile project(':rxjava-core') compile 'org.apache.httpcomponents:httpclient:4.3' diff --git a/rxjava-contrib/rxjava-async-util/build.gradle b/rxjava-contrib/rxjava-async-util/build.gradle index 09d9aae655..a7c43c944f 100644 --- a/rxjava-contrib/rxjava-async-util/build.gradle +++ b/rxjava-contrib/rxjava-async-util/build.gradle @@ -1,8 +1,5 @@ apply plugin: 'osgi' -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - dependencies { compile project(':rxjava-core') testCompile project(":rxjava-core").sourceSets.test.output diff --git a/rxjava-contrib/rxjava-computation-expressions/build.gradle b/rxjava-contrib/rxjava-computation-expressions/build.gradle index c334b53adf..ab96ed1d19 100644 --- a/rxjava-contrib/rxjava-computation-expressions/build.gradle +++ b/rxjava-contrib/rxjava-computation-expressions/build.gradle @@ -1,8 +1,5 @@ apply plugin: 'osgi' -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - dependencies { compile project(':rxjava-core') testCompile 'junit:junit-dep:4.10' diff --git a/rxjava-contrib/rxjava-string/build.gradle b/rxjava-contrib/rxjava-string/build.gradle index 5c578ae04d..132aa8dae7 100644 --- a/rxjava-contrib/rxjava-string/build.gradle +++ b/rxjava-contrib/rxjava-string/build.gradle @@ -1,8 +1,5 @@ apply plugin: 'osgi' -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - dependencies { compile project(':rxjava-core') testCompile project(":rxjava-core").sourceSets.test.output diff --git a/rxjava-contrib/rxjava-swing/build.gradle b/rxjava-contrib/rxjava-swing/build.gradle index ea863813a2..4015bcb069 100644 --- a/rxjava-contrib/rxjava-swing/build.gradle +++ b/rxjava-contrib/rxjava-swing/build.gradle @@ -1,8 +1,5 @@ apply plugin: 'osgi' -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - dependencies { compile project(':rxjava-core') provided 'junit:junit-dep:4.10' diff --git a/rxjava-core/build.gradle b/rxjava-core/build.gradle index 1732de3017..b563723058 100644 --- a/rxjava-core/build.gradle +++ b/rxjava-core/build.gradle @@ -1,9 +1,6 @@ apply plugin: 'maven' apply plugin: 'osgi' -sourceCompatibility = JavaVersion.VERSION_1_6 -targetCompatibility = JavaVersion.VERSION_1_6 - dependencies { provided 'junit:junit-dep:4.10' provided 'org.mockito:mockito-core:1.8.5' From 5cdea30cf76d8c0f411564d5699da0838a077963 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 12:15:26 +0000 Subject: [PATCH 07/26] Consolidate the Javadoc configuration. --- gradle/convention.gradle | 12 ++++++++++++ rxjava-contrib/rxjava-android/build.gradle | 9 --------- rxjava-contrib/rxjava-string/build.gradle | 10 ---------- rxjava-contrib/rxjava-swing/build.gradle | 10 ---------- rxjava-core/build.gradle | 13 ------------- 5 files changed, 12 insertions(+), 42 deletions(-) diff --git a/gradle/convention.gradle b/gradle/convention.gradle index ab48c42265..6dbed94819 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -2,6 +2,7 @@ status = project.hasProperty('preferredStatus') ? project.preferredStatus : (version.contains('SNAPSHOT') ? 'snapshot' : 'release') subprojects { project -> + description = name.capitalize().replaceAll("-\\w") { " " + (it.toUpperCase() - "-") }.replaceAll("Rxjava", "RxJava") apply plugin: 'java' // Plugin as major conventions @@ -84,6 +85,17 @@ subprojects { project -> perfRuntime.extendsFrom testRuntime } + javadoc { + options { + doclet = "org.benjchristensen.doclet.DocletExclude" + docletpath = [rootProject.file('gradle/doclet-exclude.jar')] + stylesheetFile = rootProject.file('gradle/javadocStyleSheet.css') + windowTitle = "$project.description Javadoc $project.version" + addStringOption('top').value = '

' + project.description + '

'.toString() + } + classpath += configurations.provided + } + build { dependsOn examplesClasses } diff --git a/rxjava-contrib/rxjava-android/build.gradle b/rxjava-contrib/rxjava-android/build.gradle index 144d3cd68a..783010150f 100644 --- a/rxjava-contrib/rxjava-android/build.gradle +++ b/rxjava-contrib/rxjava-android/build.gradle @@ -11,15 +11,6 @@ dependencies { provided 'org.robolectric:robolectric:2.1.1' } -javadoc { - options { - doclet = "org.benjchristensen.doclet.DocletExclude" - docletpath = [rootProject.file('./gradle/doclet-exclude.jar')] - stylesheetFile = rootProject.file('./gradle/javadocStyleSheet.css') - windowTitle = "RxJava Android Javadoc ${project.version}" - } - options.addStringOption('top').value = '

RxJava Android

' -} jar { manifest { diff --git a/rxjava-contrib/rxjava-string/build.gradle b/rxjava-contrib/rxjava-string/build.gradle index 132aa8dae7..91621aedaf 100644 --- a/rxjava-contrib/rxjava-string/build.gradle +++ b/rxjava-contrib/rxjava-string/build.gradle @@ -7,16 +7,6 @@ dependencies { provided 'org.mockito:mockito-core:1.8.5' } -javadoc { - options { - doclet = "org.benjchristensen.doclet.DocletExclude" - docletpath = [rootProject.file('./gradle/doclet-exclude.jar')] - stylesheetFile = rootProject.file('./gradle/javadocStyleSheet.css') - windowTitle = "RxJava Javadoc ${project.version}" - } - options.addStringOption('top').value = '

RxJava

' -} - jar { manifest { name = 'rxjava-string' diff --git a/rxjava-contrib/rxjava-swing/build.gradle b/rxjava-contrib/rxjava-swing/build.gradle index 4015bcb069..8e9eb84eae 100644 --- a/rxjava-contrib/rxjava-swing/build.gradle +++ b/rxjava-contrib/rxjava-swing/build.gradle @@ -6,16 +6,6 @@ dependencies { provided 'org.mockito:mockito-core:1.8.5' } -javadoc { - options { - doclet = "org.benjchristensen.doclet.DocletExclude" - docletpath = [rootProject.file('./gradle/doclet-exclude.jar')] - stylesheetFile = rootProject.file('./gradle/javadocStyleSheet.css') - windowTitle = "RxJava Javadoc ${project.version}" - } - options.addStringOption('top').value = '

RxJava

' -} - jar { manifest { name = 'rxjava-swing' diff --git a/rxjava-core/build.gradle b/rxjava-core/build.gradle index b563723058..496d3a95c9 100644 --- a/rxjava-core/build.gradle +++ b/rxjava-core/build.gradle @@ -6,19 +6,6 @@ dependencies { provided 'org.mockito:mockito-core:1.8.5' } -javadoc { - // we do not want the org.rx.operations package include - exclude '**/operations/**' - - options { - doclet = "org.benjchristensen.doclet.DocletExclude" - docletpath = [rootProject.file('./gradle/doclet-exclude.jar')] - stylesheetFile = rootProject.file('./gradle/javadocStyleSheet.css') - windowTitle = "RxJava Javadoc ${project.version}" - } - options.addStringOption('top').value = '

RxJava

' -} - jar { manifest { name = 'rxjava-core' From 6076f230f4187d225e58954978a3063ba9ff68ba Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 12:17:41 +0000 Subject: [PATCH 08/26] Move osgi plugin application to the conventions script. --- gradle/convention.gradle | 6 +++++- language-adaptors/rxjava-clojure/build.gradle | 1 - language-adaptors/rxjava-groovy/build.gradle | 1 - language-adaptors/rxjava-jruby/build.gradle | 2 -- language-adaptors/rxjava-kotlin/build.gradle | 1 - language-adaptors/rxjava-scala/build.gradle | 1 - rxjava-contrib/rxjava-android/build.gradle | 2 +- rxjava-contrib/rxjava-apache-http/build.gradle | 2 -- rxjava-contrib/rxjava-async-util/build.gradle | 2 -- rxjava-contrib/rxjava-computation-expressions/build.gradle | 2 -- rxjava-contrib/rxjava-string/build.gradle | 2 -- rxjava-contrib/rxjava-swing/build.gradle | 2 -- rxjava-core/build.gradle | 1 - 13 files changed, 6 insertions(+), 19 deletions(-) diff --git a/gradle/convention.gradle b/gradle/convention.gradle index 6dbed94819..75789b0df8 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -2,9 +2,13 @@ status = project.hasProperty('preferredStatus') ? project.preferredStatus : (version.contains('SNAPSHOT') ? 'snapshot' : 'release') subprojects { project -> + if (!subprojects.empty) { // is a container + return + } + description = name.capitalize().replaceAll("-\\w") { " " + (it.toUpperCase() - "-") }.replaceAll("Rxjava", "RxJava") - apply plugin: 'java' // Plugin as major conventions + apply plugin: 'java' sourceCompatibility = JavaVersion.VERSION_1_6 targetCompatibility = JavaVersion.VERSION_1_6 diff --git a/language-adaptors/rxjava-clojure/build.gradle b/language-adaptors/rxjava-clojure/build.gradle index dfc5083f48..a15fd99360 100644 --- a/language-adaptors/rxjava-clojure/build.gradle +++ b/language-adaptors/rxjava-clojure/build.gradle @@ -4,7 +4,6 @@ buildscript { } apply plugin: 'clojure' -apply plugin: 'osgi' repositories { clojarsRepo() diff --git a/language-adaptors/rxjava-groovy/build.gradle b/language-adaptors/rxjava-groovy/build.gradle index f45b0d8fb6..2ad281ff70 100644 --- a/language-adaptors/rxjava-groovy/build.gradle +++ b/language-adaptors/rxjava-groovy/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'groovy' -apply plugin: 'osgi' dependencies { compile project(':rxjava-core') diff --git a/language-adaptors/rxjava-jruby/build.gradle b/language-adaptors/rxjava-jruby/build.gradle index 0369d6e36e..de21d1f702 100644 --- a/language-adaptors/rxjava-jruby/build.gradle +++ b/language-adaptors/rxjava-jruby/build.gradle @@ -1,5 +1,3 @@ -apply plugin: 'osgi' - repositories { maven { url 'http://deux.gemjars.org/' diff --git a/language-adaptors/rxjava-kotlin/build.gradle b/language-adaptors/rxjava-kotlin/build.gradle index aa44049d05..99581ade18 100644 --- a/language-adaptors/rxjava-kotlin/build.gradle +++ b/language-adaptors/rxjava-kotlin/build.gradle @@ -9,7 +9,6 @@ buildscript { } apply plugin: 'kotlin' -apply plugin: 'osgi' dependencies { compile project(':rxjava-core') diff --git a/language-adaptors/rxjava-scala/build.gradle b/language-adaptors/rxjava-scala/build.gradle index 046be2c505..95628cbb1f 100644 --- a/language-adaptors/rxjava-scala/build.gradle +++ b/language-adaptors/rxjava-scala/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'scala' -apply plugin: 'osgi' tasks.withType(ScalaCompile) { scalaCompileOptions.fork = true diff --git a/rxjava-contrib/rxjava-android/build.gradle b/rxjava-contrib/rxjava-android/build.gradle index 783010150f..55f4e33b67 100644 --- a/rxjava-contrib/rxjava-android/build.gradle +++ b/rxjava-contrib/rxjava-android/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'osgi' + dependencies { compile project(':rxjava-core') diff --git a/rxjava-contrib/rxjava-apache-http/build.gradle b/rxjava-contrib/rxjava-apache-http/build.gradle index ae7590a43b..a6f7f4931f 100644 --- a/rxjava-contrib/rxjava-apache-http/build.gradle +++ b/rxjava-contrib/rxjava-apache-http/build.gradle @@ -1,5 +1,3 @@ -apply plugin: 'osgi' - dependencies { compile project(':rxjava-core') compile 'org.apache.httpcomponents:httpclient:4.3' diff --git a/rxjava-contrib/rxjava-async-util/build.gradle b/rxjava-contrib/rxjava-async-util/build.gradle index a7c43c944f..1fca841426 100644 --- a/rxjava-contrib/rxjava-async-util/build.gradle +++ b/rxjava-contrib/rxjava-async-util/build.gradle @@ -1,5 +1,3 @@ -apply plugin: 'osgi' - dependencies { compile project(':rxjava-core') testCompile project(":rxjava-core").sourceSets.test.output diff --git a/rxjava-contrib/rxjava-computation-expressions/build.gradle b/rxjava-contrib/rxjava-computation-expressions/build.gradle index ab96ed1d19..95fd66a7ea 100644 --- a/rxjava-contrib/rxjava-computation-expressions/build.gradle +++ b/rxjava-contrib/rxjava-computation-expressions/build.gradle @@ -1,5 +1,3 @@ -apply plugin: 'osgi' - dependencies { compile project(':rxjava-core') testCompile 'junit:junit-dep:4.10' diff --git a/rxjava-contrib/rxjava-string/build.gradle b/rxjava-contrib/rxjava-string/build.gradle index 91621aedaf..0094d63be2 100644 --- a/rxjava-contrib/rxjava-string/build.gradle +++ b/rxjava-contrib/rxjava-string/build.gradle @@ -1,5 +1,3 @@ -apply plugin: 'osgi' - dependencies { compile project(':rxjava-core') testCompile project(":rxjava-core").sourceSets.test.output diff --git a/rxjava-contrib/rxjava-swing/build.gradle b/rxjava-contrib/rxjava-swing/build.gradle index 8e9eb84eae..379245ca13 100644 --- a/rxjava-contrib/rxjava-swing/build.gradle +++ b/rxjava-contrib/rxjava-swing/build.gradle @@ -1,5 +1,3 @@ -apply plugin: 'osgi' - dependencies { compile project(':rxjava-core') provided 'junit:junit-dep:4.10' diff --git a/rxjava-core/build.gradle b/rxjava-core/build.gradle index 496d3a95c9..4df5e66916 100644 --- a/rxjava-core/build.gradle +++ b/rxjava-core/build.gradle @@ -1,5 +1,4 @@ apply plugin: 'maven' -apply plugin: 'osgi' dependencies { provided 'junit:junit-dep:4.10' From fab6b5b02e20d930014051770c08eeb64af18dac Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 12:30:18 +0000 Subject: [PATCH 09/26] Move osgi plugin application to the conventions script. --- gradle/convention.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle/convention.gradle b/gradle/convention.gradle index 75789b0df8..395dc885a2 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -9,6 +9,7 @@ subprojects { project -> description = name.capitalize().replaceAll("-\\w") { " " + (it.toUpperCase() - "-") }.replaceAll("Rxjava", "RxJava") apply plugin: 'java' + apply plugin: 'osgi' sourceCompatibility = JavaVersion.VERSION_1_6 targetCompatibility = JavaVersion.VERSION_1_6 From 6f8b33573bd1bab4bbf6efd8c8c3b84164fa8673 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 12:42:45 +0000 Subject: [PATCH 10/26] Extract the Swing unit tests so that test classes don't have to be on the main compile classpath. --- .../java/rx/schedulers/SwingScheduler.java | 139 +---------------- .../swing/sources/AbstractButtonSource.java | 53 +------ .../java/rx/swing/sources/KeyEventSource.java | 107 +------------ .../rx/swing/sources/MouseEventSource.java | 67 +------- .../rx/schedulers/SwingSchedulerTest.java | 147 ++++++++++++++++++ .../sources/AbstractButtonSourceTest.java | 66 ++++++++ .../rx/swing/sources/KeyEventSourceTest.java | 118 ++++++++++++++ .../swing/sources/MouseEventSourceTest.java | 76 +++++++++ 8 files changed, 431 insertions(+), 342 deletions(-) create mode 100644 rxjava-contrib/rxjava-swing/src/test/java/rx/schedulers/SwingSchedulerTest.java create mode 100644 rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/AbstractButtonSourceTest.java create mode 100644 rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/KeyEventSourceTest.java create mode 100644 rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/MouseEventSourceTest.java diff --git a/rxjava-contrib/rxjava-swing/src/main/java/rx/schedulers/SwingScheduler.java b/rxjava-contrib/rxjava-swing/src/main/java/rx/schedulers/SwingScheduler.java index 7ce2c4e2d1..1a794e0dcc 100644 --- a/rxjava-contrib/rxjava-swing/src/main/java/rx/schedulers/SwingScheduler.java +++ b/rxjava-contrib/rxjava-swing/src/main/java/rx/schedulers/SwingScheduler.java @@ -15,24 +15,6 @@ */ package rx.schedulers; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; - -import java.awt.EventQueue; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import javax.swing.SwingUtilities; -import javax.swing.Timer; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.mockito.InOrder; - import rx.Scheduler; import rx.Subscription; import rx.subscriptions.CompositeSubscription; @@ -40,6 +22,13 @@ import rx.util.functions.Action0; import rx.util.functions.Func2; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + /** * Executes work on the Swing UI thread. * This scheduler should only be used with actions that execute quickly. @@ -157,118 +146,4 @@ private static void assertThatTheDelayIsValidForTheSwingTimer(long delay) { } } - public static class UnitTest { - @Rule - public ExpectedException exception = ExpectedException.none(); - - @Test - public void testInvalidDelayValues() { - final SwingScheduler scheduler = new SwingScheduler(); - final Action0 action = mock(Action0.class); - - exception.expect(IllegalArgumentException.class); - scheduler.schedulePeriodically(action, -1L, 100L, TimeUnit.SECONDS); - - exception.expect(IllegalArgumentException.class); - scheduler.schedulePeriodically(action, 100L, -1L, TimeUnit.SECONDS); - - exception.expect(IllegalArgumentException.class); - scheduler.schedulePeriodically(action, 1L + Integer.MAX_VALUE, 100L, TimeUnit.MILLISECONDS); - - exception.expect(IllegalArgumentException.class); - scheduler.schedulePeriodically(action, 100L, 1L + Integer.MAX_VALUE / 1000, TimeUnit.SECONDS); - } - - @Test - public void testPeriodicScheduling() throws Exception { - final SwingScheduler scheduler = new SwingScheduler(); - - final CountDownLatch latch = new CountDownLatch(4); - - final Action0 innerAction = mock(Action0.class); - final Action0 action = new Action0() { - @Override - public void call() { - try { - innerAction.call(); - assertTrue(SwingUtilities.isEventDispatchThread()); - } finally { - latch.countDown(); - } - } - }; - - Subscription sub = scheduler.schedulePeriodically(action, 50, 200, TimeUnit.MILLISECONDS); - - if (!latch.await(5000, TimeUnit.MILLISECONDS)) { - fail("timed out waiting for tasks to execute"); - } - - sub.unsubscribe(); - waitForEmptyEventQueue(); - verify(innerAction, times(4)).call(); - } - - @Test - public void testNestedActions() throws Exception { - final SwingScheduler scheduler = new SwingScheduler(); - - final Action0 firstStepStart = mock(Action0.class); - final Action0 firstStepEnd = mock(Action0.class); - - final Action0 secondStepStart = mock(Action0.class); - final Action0 secondStepEnd = mock(Action0.class); - - final Action0 thirdStepStart = mock(Action0.class); - final Action0 thirdStepEnd = mock(Action0.class); - - final Action0 firstAction = new Action0() { - @Override - public void call() { - assertTrue(SwingUtilities.isEventDispatchThread()); - firstStepStart.call(); - firstStepEnd.call(); - } - }; - final Action0 secondAction = new Action0() { - @Override - public void call() { - assertTrue(SwingUtilities.isEventDispatchThread()); - secondStepStart.call(); - scheduler.schedule(firstAction); - secondStepEnd.call(); - } - }; - final Action0 thirdAction = new Action0() { - @Override - public void call() { - assertTrue(SwingUtilities.isEventDispatchThread()); - thirdStepStart.call(); - scheduler.schedule(secondAction); - thirdStepEnd.call(); - } - }; - - InOrder inOrder = inOrder(firstStepStart, firstStepEnd, secondStepStart, secondStepEnd, thirdStepStart, thirdStepEnd); - - scheduler.schedule(thirdAction); - waitForEmptyEventQueue(); - - inOrder.verify(thirdStepStart, times(1)).call(); - inOrder.verify(thirdStepEnd, times(1)).call(); - inOrder.verify(secondStepStart, times(1)).call(); - inOrder.verify(secondStepEnd, times(1)).call(); - inOrder.verify(firstStepStart, times(1)).call(); - inOrder.verify(firstStepEnd, times(1)).call(); - } - - private static void waitForEmptyEventQueue() throws Exception { - EventQueue.invokeAndWait(new Runnable() { - @Override - public void run() { - // nothing to do, we're just waiting here for the event queue to be emptied - } - }); - } - } } diff --git a/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/AbstractButtonSource.java b/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/AbstractButtonSource.java index ef5c7db50a..d01b7bd9a6 100644 --- a/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/AbstractButtonSource.java +++ b/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/AbstractButtonSource.java @@ -15,23 +15,16 @@ */ package rx.swing.sources; -import static org.mockito.Mockito.*; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.AbstractButton; - -import org.junit.Test; -import org.mockito.Matchers; - import rx.Observable; import rx.Observable.OnSubscribeFunc; import rx.Observer; import rx.Subscription; import rx.subscriptions.Subscriptions; import rx.util.functions.Action0; -import rx.util.functions.Action1; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; public enum AbstractButtonSource { ; // no instances @@ -60,42 +53,4 @@ public void call() { }); } - public static class UnitTest { - @Test - public void testObservingActionEvents() { - @SuppressWarnings("unchecked") - Action1 action = mock(Action1.class); - @SuppressWarnings("unchecked") - Action1 error = mock(Action1.class); - Action0 complete = mock(Action0.class); - - final ActionEvent event = new ActionEvent(this, 1, "command"); - - @SuppressWarnings("serial") - class TestButton extends AbstractButton { - void testAction() { - fireActionPerformed(event); - } - } - - TestButton button = new TestButton(); - Subscription sub = fromActionOf(button).subscribe(action, error, complete); - - verify(action, never()).call(Matchers.any()); - verify(error, never()).call(Matchers.any()); - verify(complete, never()).call(); - - button.testAction(); - verify(action, times(1)).call(Matchers.any()); - - button.testAction(); - verify(action, times(2)).call(Matchers.any()); - - sub.unsubscribe(); - button.testAction(); - verify(action, times(2)).call(Matchers.any()); - verify(error, never()).call(Matchers.any()); - verify(complete, never()).call(); - } - } } diff --git a/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/KeyEventSource.java b/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/KeyEventSource.java index e3b37a7868..ad193d600c 100644 --- a/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/KeyEventSource.java +++ b/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/KeyEventSource.java @@ -15,32 +15,22 @@ */ package rx.swing.sources; -import static java.util.Arrays.*; -import static org.mockito.Mockito.*; - -import java.awt.Component; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import javax.swing.JPanel; - -import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Matchers; - import rx.Observable; import rx.Observable.OnSubscribeFunc; import rx.Observer; import rx.Subscription; import rx.subscriptions.Subscriptions; import rx.util.functions.Action0; -import rx.util.functions.Action1; import rx.util.functions.Func1; import rx.util.functions.Func2; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + public enum KeyEventSource { ; // no instances /** @@ -110,88 +100,5 @@ public Boolean call(KeyEvent event) { return filteredKeyEvents.scan(Collections.emptySet(), new CollectKeys()); } - - public static class UnitTest { - private Component comp = new JPanel(); - - @Test - public void testObservingKeyEvents() { - @SuppressWarnings("unchecked") - Action1 action = mock(Action1.class); - @SuppressWarnings("unchecked") - Action1 error = mock(Action1.class); - Action0 complete = mock(Action0.class); - - final KeyEvent event = mock(KeyEvent.class); - - Subscription sub = fromKeyEventsOf(comp).subscribe(action, error, complete); - - verify(action, never()).call(Matchers.any()); - verify(error, never()).call(Matchers.any()); - verify(complete, never()).call(); - - fireKeyEvent(event); - verify(action, times(1)).call(Matchers.any()); - - fireKeyEvent(event); - verify(action, times(2)).call(Matchers.any()); - - sub.unsubscribe(); - fireKeyEvent(event); - verify(action, times(2)).call(Matchers.any()); - verify(error, never()).call(Matchers.any()); - verify(complete, never()).call(); - } - - @Test - public void testObservingPressedKeys() { - @SuppressWarnings("unchecked") - Action1> action = mock(Action1.class); - @SuppressWarnings("unchecked") - Action1 error = mock(Action1.class); - Action0 complete = mock(Action0.class); - - Subscription sub = currentlyPressedKeysOf(comp).subscribe(action, error, complete); - - InOrder inOrder = inOrder(action); - inOrder.verify(action, times(1)).call(Collections.emptySet()); - verify(error, never()).call(Matchers.any()); - verify(complete, never()).call(); - - fireKeyEvent(keyEvent(1, KeyEvent.KEY_PRESSED)); - inOrder.verify(action, times(1)).call(new HashSet(asList(1))); - verify(error, never()).call(Matchers.any()); - verify(complete, never()).call(); - - fireKeyEvent(keyEvent(2, KeyEvent.KEY_PRESSED)); - fireKeyEvent(keyEvent(KeyEvent.VK_UNDEFINED, KeyEvent.KEY_TYPED)); - inOrder.verify(action, times(1)).call(new HashSet(asList(1, 2))); - - fireKeyEvent(keyEvent(2, KeyEvent.KEY_RELEASED)); - inOrder.verify(action, times(1)).call(new HashSet(asList(1))); - - fireKeyEvent(keyEvent(3, KeyEvent.KEY_RELEASED)); - inOrder.verify(action, times(1)).call(new HashSet(asList(1))); - - fireKeyEvent(keyEvent(1, KeyEvent.KEY_RELEASED)); - inOrder.verify(action, times(1)).call(Collections.emptySet()); - - sub.unsubscribe(); - fireKeyEvent(keyEvent(1, KeyEvent.KEY_PRESSED)); - inOrder.verify(action, never()).call(Matchers.>any()); - verify(error, never()).call(Matchers.any()); - verify(complete, never()).call(); - } - - private KeyEvent keyEvent(int keyCode, int id) { - return new KeyEvent(comp, id, -1L, 0, keyCode, ' '); - } - - private void fireKeyEvent(KeyEvent event) { - for (KeyListener listener: comp.getKeyListeners()) { - listener.keyTyped(event); - } - } - } } diff --git a/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/MouseEventSource.java b/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/MouseEventSource.java index f6589da054..2aad7ccf93 100644 --- a/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/MouseEventSource.java +++ b/rxjava-contrib/rxjava-swing/src/main/java/rx/swing/sources/MouseEventSource.java @@ -15,30 +15,20 @@ */ package rx.swing.sources; -import static org.mockito.Mockito.*; - -import java.awt.Component; -import java.awt.Point; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; - -import javax.swing.JPanel; - -import org.junit.Test; -import org.mockito.InOrder; -import org.mockito.Matchers; - import rx.Observable; import rx.Observable.OnSubscribeFunc; import rx.Observer; import rx.Subscription; import rx.subscriptions.Subscriptions; import rx.util.functions.Action0; -import rx.util.functions.Action1; import rx.util.functions.Func1; import rx.util.functions.Func2; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; + public enum MouseEventSource { ; // no instances /** @@ -151,50 +141,5 @@ public Point call(OldAndRelative oar) { .map(new OnlyRelative()) .skip(2); // skip the useless initial value and the invalid first computation } - - public static class UnitTest { - private Component comp = new JPanel(); - - @Test - public void testRelativeMouseMotion() { - @SuppressWarnings("unchecked") - Action1 action = mock(Action1.class); - @SuppressWarnings("unchecked") - Action1 error = mock(Action1.class); - Action0 complete = mock(Action0.class); - - Subscription sub = fromRelativeMouseMotion(comp).subscribe(action, error, complete); - - InOrder inOrder = inOrder(action); - - verify(action, never()).call(Matchers.any()); - verify(error, never()).call(Matchers.any()); - verify(complete, never()).call(); - - fireMouseEvent(mouseEvent(0, 0)); - verify(action, never()).call(Matchers.any()); - - fireMouseEvent(mouseEvent(10, -5)); - inOrder.verify(action, times(1)).call(new Point(10, -5)); - - fireMouseEvent(mouseEvent(6, 10)); - inOrder.verify(action, times(1)).call(new Point(-4, 15)); - - sub.unsubscribe(); - fireMouseEvent(mouseEvent(0, 0)); - inOrder.verify(action, never()).call(Matchers.any()); - verify(error, never()).call(Matchers.any()); - verify(complete, never()).call(); - } - - private MouseEvent mouseEvent(int x, int y) { - return new MouseEvent(comp, MouseEvent.MOUSE_MOVED, 1L, 0, x, y, 0, false); - } - - private void fireMouseEvent(MouseEvent event) { - for (MouseMotionListener listener: comp.getMouseMotionListeners()) { - listener.mouseMoved(event); - } - } - } + } diff --git a/rxjava-contrib/rxjava-swing/src/test/java/rx/schedulers/SwingSchedulerTest.java b/rxjava-contrib/rxjava-swing/src/test/java/rx/schedulers/SwingSchedulerTest.java new file mode 100644 index 0000000000..cafa469e1c --- /dev/null +++ b/rxjava-contrib/rxjava-swing/src/test/java/rx/schedulers/SwingSchedulerTest.java @@ -0,0 +1,147 @@ +/** + * Copyright 2013 Netflix, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.schedulers; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.InOrder; +import rx.Subscription; +import rx.util.functions.Action0; + +import javax.swing.*; +import java.awt.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.*; + +public class SwingSchedulerTest { + @Rule + public ExpectedException exception = ExpectedException.none(); + + @Test + public void testInvalidDelayValues() { + final SwingScheduler scheduler = SwingScheduler.getInstance(); + final Action0 action = mock(Action0.class); + + exception.expect(IllegalArgumentException.class); + scheduler.schedulePeriodically(action, -1L, 100L, TimeUnit.SECONDS); + + exception.expect(IllegalArgumentException.class); + scheduler.schedulePeriodically(action, 100L, -1L, TimeUnit.SECONDS); + + exception.expect(IllegalArgumentException.class); + scheduler.schedulePeriodically(action, 1L + Integer.MAX_VALUE, 100L, TimeUnit.MILLISECONDS); + + exception.expect(IllegalArgumentException.class); + scheduler.schedulePeriodically(action, 100L, 1L + Integer.MAX_VALUE / 1000, TimeUnit.SECONDS); + } + + @Test + public void testPeriodicScheduling() throws Exception { + final SwingScheduler scheduler = SwingScheduler.getInstance(); + + final CountDownLatch latch = new CountDownLatch(4); + + final Action0 innerAction = mock(Action0.class); + final Action0 action = new Action0() { + @Override + public void call() { + try { + innerAction.call(); + assertTrue(SwingUtilities.isEventDispatchThread()); + } finally { + latch.countDown(); + } + } + }; + + Subscription sub = scheduler.schedulePeriodically(action, 50, 200, TimeUnit.MILLISECONDS); + + if (!latch.await(5000, TimeUnit.MILLISECONDS)) { + fail("timed out waiting for tasks to execute"); + } + + sub.unsubscribe(); + waitForEmptyEventQueue(); + verify(innerAction, times(4)).call(); + } + + @Test + public void testNestedActions() throws Exception { + final SwingScheduler scheduler = SwingScheduler.getInstance(); + + final Action0 firstStepStart = mock(Action0.class); + final Action0 firstStepEnd = mock(Action0.class); + + final Action0 secondStepStart = mock(Action0.class); + final Action0 secondStepEnd = mock(Action0.class); + + final Action0 thirdStepStart = mock(Action0.class); + final Action0 thirdStepEnd = mock(Action0.class); + + final Action0 firstAction = new Action0() { + @Override + public void call() { + assertTrue(SwingUtilities.isEventDispatchThread()); + firstStepStart.call(); + firstStepEnd.call(); + } + }; + final Action0 secondAction = new Action0() { + @Override + public void call() { + assertTrue(SwingUtilities.isEventDispatchThread()); + secondStepStart.call(); + scheduler.schedule(firstAction); + secondStepEnd.call(); + } + }; + final Action0 thirdAction = new Action0() { + @Override + public void call() { + assertTrue(SwingUtilities.isEventDispatchThread()); + thirdStepStart.call(); + scheduler.schedule(secondAction); + thirdStepEnd.call(); + } + }; + + InOrder inOrder = inOrder(firstStepStart, firstStepEnd, secondStepStart, secondStepEnd, thirdStepStart, thirdStepEnd); + + scheduler.schedule(thirdAction); + waitForEmptyEventQueue(); + + inOrder.verify(thirdStepStart, times(1)).call(); + inOrder.verify(thirdStepEnd, times(1)).call(); + inOrder.verify(secondStepStart, times(1)).call(); + inOrder.verify(secondStepEnd, times(1)).call(); + inOrder.verify(firstStepStart, times(1)).call(); + inOrder.verify(firstStepEnd, times(1)).call(); + } + + private static void waitForEmptyEventQueue() throws Exception { + EventQueue.invokeAndWait(new Runnable() { + @Override + public void run() { + // nothing to do, we're just waiting here for the event queue to be emptied + } + }); + } +} diff --git a/rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/AbstractButtonSourceTest.java b/rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/AbstractButtonSourceTest.java new file mode 100644 index 0000000000..c4196540e2 --- /dev/null +++ b/rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/AbstractButtonSourceTest.java @@ -0,0 +1,66 @@ +/** + * Copyright 2013 Netflix, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.swing.sources; + +import org.junit.Test; +import org.mockito.Matchers; +import rx.Subscription; +import rx.util.functions.Action0; +import rx.util.functions.Action1; + +import javax.swing.*; +import java.awt.event.ActionEvent; + +import static org.mockito.Mockito.*; + +public class AbstractButtonSourceTest { + @Test + public void testObservingActionEvents() { + @SuppressWarnings("unchecked") + Action1 action = mock(Action1.class); + @SuppressWarnings("unchecked") + Action1 error = mock(Action1.class); + Action0 complete = mock(Action0.class); + + final ActionEvent event = new ActionEvent(this, 1, "command"); + + @SuppressWarnings("serial") + class TestButton extends AbstractButton { + void testAction() { + fireActionPerformed(event); + } + } + + TestButton button = new TestButton(); + Subscription sub = AbstractButtonSource.fromActionOf(button).subscribe(action, error, complete); + + verify(action, never()).call(Matchers.any()); + verify(error, never()).call(Matchers.any()); + verify(complete, never()).call(); + + button.testAction(); + verify(action, times(1)).call(Matchers.any()); + + button.testAction(); + verify(action, times(2)).call(Matchers.any()); + + sub.unsubscribe(); + button.testAction(); + verify(action, times(2)).call(Matchers.any()); + verify(error, never()).call(Matchers.any()); + verify(complete, never()).call(); + } +} diff --git a/rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/KeyEventSourceTest.java b/rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/KeyEventSourceTest.java new file mode 100644 index 0000000000..332da5ff66 --- /dev/null +++ b/rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/KeyEventSourceTest.java @@ -0,0 +1,118 @@ +/** + * Copyright 2013 Netflix, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.swing.sources; + +import org.junit.Test; +import org.mockito.InOrder; +import org.mockito.Matchers; +import rx.Subscription; +import rx.util.functions.Action0; +import rx.util.functions.Action1; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +import static java.util.Arrays.asList; +import static org.mockito.Mockito.*; + +public class KeyEventSourceTest { + private Component comp = new JPanel(); + + @Test + public void testObservingKeyEvents() { + @SuppressWarnings("unchecked") + Action1 action = mock(Action1.class); + @SuppressWarnings("unchecked") + Action1 error = mock(Action1.class); + Action0 complete = mock(Action0.class); + + final KeyEvent event = mock(KeyEvent.class); + + Subscription sub = KeyEventSource.fromKeyEventsOf(comp).subscribe(action, error, complete); + + verify(action, never()).call(Matchers.any()); + verify(error, never()).call(Matchers.any()); + verify(complete, never()).call(); + + fireKeyEvent(event); + verify(action, times(1)).call(Matchers.any()); + + fireKeyEvent(event); + verify(action, times(2)).call(Matchers.any()); + + sub.unsubscribe(); + fireKeyEvent(event); + verify(action, times(2)).call(Matchers.any()); + verify(error, never()).call(Matchers.any()); + verify(complete, never()).call(); + } + + @Test + public void testObservingPressedKeys() { + @SuppressWarnings("unchecked") + Action1> action = mock(Action1.class); + @SuppressWarnings("unchecked") + Action1 error = mock(Action1.class); + Action0 complete = mock(Action0.class); + + Subscription sub = KeyEventSource.currentlyPressedKeysOf(comp).subscribe(action, error, complete); + + InOrder inOrder = inOrder(action); + inOrder.verify(action, times(1)).call(Collections.emptySet()); + verify(error, never()).call(Matchers.any()); + verify(complete, never()).call(); + + fireKeyEvent(keyEvent(1, KeyEvent.KEY_PRESSED)); + inOrder.verify(action, times(1)).call(new HashSet(asList(1))); + verify(error, never()).call(Matchers.any()); + verify(complete, never()).call(); + + fireKeyEvent(keyEvent(2, KeyEvent.KEY_PRESSED)); + fireKeyEvent(keyEvent(KeyEvent.VK_UNDEFINED, KeyEvent.KEY_TYPED)); + inOrder.verify(action, times(1)).call(new HashSet(asList(1, 2))); + + fireKeyEvent(keyEvent(2, KeyEvent.KEY_RELEASED)); + inOrder.verify(action, times(1)).call(new HashSet(asList(1))); + + fireKeyEvent(keyEvent(3, KeyEvent.KEY_RELEASED)); + inOrder.verify(action, times(1)).call(new HashSet(asList(1))); + + fireKeyEvent(keyEvent(1, KeyEvent.KEY_RELEASED)); + inOrder.verify(action, times(1)).call(Collections.emptySet()); + + sub.unsubscribe(); + + fireKeyEvent(keyEvent(1, KeyEvent.KEY_PRESSED)); + inOrder.verify(action, never()).call(Matchers.>any()); + verify(error, never()).call(Matchers.any()); + verify(complete, never()).call(); + } + + private KeyEvent keyEvent(int keyCode, int id) { + return new KeyEvent(comp, id, -1L, 0, keyCode, ' '); + } + + private void fireKeyEvent(KeyEvent event) { + for (KeyListener listener: comp.getKeyListeners()) { + listener.keyTyped(event); + } + } +} diff --git a/rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/MouseEventSourceTest.java b/rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/MouseEventSourceTest.java new file mode 100644 index 0000000000..7e36e6764f --- /dev/null +++ b/rxjava-contrib/rxjava-swing/src/test/java/rx/swing/sources/MouseEventSourceTest.java @@ -0,0 +1,76 @@ +/** + * Copyright 2013 Netflix, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package rx.swing.sources; + +import org.junit.Test; +import org.mockito.InOrder; +import org.mockito.Matchers; +import rx.Subscription; +import rx.util.functions.Action0; +import rx.util.functions.Action1; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionListener; + +import static org.mockito.Mockito.*; + +public class MouseEventSourceTest { + private Component comp = new JPanel(); + + @Test + public void testRelativeMouseMotion() { + @SuppressWarnings("unchecked") + Action1 action = mock(Action1.class); + @SuppressWarnings("unchecked") + Action1 error = mock(Action1.class); + Action0 complete = mock(Action0.class); + + Subscription sub = MouseEventSource.fromRelativeMouseMotion(comp).subscribe(action, error, complete); + + InOrder inOrder = inOrder(action); + + verify(action, never()).call(Matchers.any()); + verify(error, never()).call(Matchers.any()); + verify(complete, never()).call(); + + fireMouseEvent(mouseEvent(0, 0)); + verify(action, never()).call(Matchers.any()); + + fireMouseEvent(mouseEvent(10, -5)); + inOrder.verify(action, times(1)).call(new Point(10, -5)); + + fireMouseEvent(mouseEvent(6, 10)); + inOrder.verify(action, times(1)).call(new Point(-4, 15)); + + sub.unsubscribe(); + fireMouseEvent(mouseEvent(0, 0)); + inOrder.verify(action, never()).call(Matchers.any()); + verify(error, never()).call(Matchers.any()); + verify(complete, never()).call(); + } + + private MouseEvent mouseEvent(int x, int y) { + return new MouseEvent(comp, MouseEvent.MOUSE_MOVED, 1L, 0, x, y, 0, false); + } + + private void fireMouseEvent(MouseEvent event) { + for (MouseMotionListener listener: comp.getMouseMotionListeners()) { + listener.mouseMoved(event); + } + } +} From f4f44e555ac9811ff7b1d38bb9706369587fb3e8 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:08:09 +0000 Subject: [PATCH 11/26] Don't use provided dependency configuration for test dependencies. Gets test dependencies off the compile classpath and removes the need to prevent imports of packages in the OSGi manifest. --- language-adaptors/rxjava-clojure/build.gradle | 1 - language-adaptors/rxjava-groovy/build.gradle | 1 - language-adaptors/rxjava-jruby/build.gradle | 5 ++--- language-adaptors/rxjava-kotlin/build.gradle | 5 ++--- language-adaptors/rxjava-scala/build.gradle | 1 - rxjava-contrib/rxjava-android/build.gradle | 8 +++----- rxjava-contrib/rxjava-apache-http/build.gradle | 1 - rxjava-contrib/rxjava-async-util/build.gradle | 5 ++--- .../rxjava-computation-expressions/build.gradle | 1 - rxjava-contrib/rxjava-string/build.gradle | 5 ++--- rxjava-contrib/rxjava-swing/build.gradle | 5 ++--- rxjava-core/build.gradle | 5 ++--- 12 files changed, 15 insertions(+), 28 deletions(-) diff --git a/language-adaptors/rxjava-clojure/build.gradle b/language-adaptors/rxjava-clojure/build.gradle index a15fd99360..1dcf82eba3 100644 --- a/language-adaptors/rxjava-clojure/build.gradle +++ b/language-adaptors/rxjava-clojure/build.gradle @@ -29,7 +29,6 @@ jar { name = 'rxjava-clojure' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' instruction 'Fragment-Host', 'com.netflix.rxjava.core' } } diff --git a/language-adaptors/rxjava-groovy/build.gradle b/language-adaptors/rxjava-groovy/build.gradle index 2ad281ff70..79a622374c 100644 --- a/language-adaptors/rxjava-groovy/build.gradle +++ b/language-adaptors/rxjava-groovy/build.gradle @@ -12,7 +12,6 @@ jar { name = 'rxjava-groovy' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' instruction 'Fragment-Host', 'com.netflix.rxjava.core' } } \ No newline at end of file diff --git a/language-adaptors/rxjava-jruby/build.gradle b/language-adaptors/rxjava-jruby/build.gradle index de21d1f702..e540d83164 100644 --- a/language-adaptors/rxjava-jruby/build.gradle +++ b/language-adaptors/rxjava-jruby/build.gradle @@ -20,8 +20,8 @@ sourceSets { dependencies { compile project(':rxjava-core') compile 'org.jruby:jruby:1.7+' - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' rspec 'org.jruby:jruby-complete:1.7.4' rspec 'org.rubygems:rspec:2.14.1' } @@ -41,7 +41,6 @@ jar { name = 'rxjava-jruby' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' instruction 'Fragment-Host', 'com.netflix.rxjava.core' } } diff --git a/language-adaptors/rxjava-kotlin/build.gradle b/language-adaptors/rxjava-kotlin/build.gradle index 99581ade18..15d625d85e 100644 --- a/language-adaptors/rxjava-kotlin/build.gradle +++ b/language-adaptors/rxjava-kotlin/build.gradle @@ -13,8 +13,8 @@ apply plugin: 'kotlin' dependencies { compile project(':rxjava-core') compile 'org.jetbrains.kotlin:kotlin-stdlib:0.6.1673' - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' } jar { @@ -22,7 +22,6 @@ jar { name = 'rxjava-kotlin' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' instruction 'Fragment-Host', 'com.netflix.rxjava.core' } } \ No newline at end of file diff --git a/language-adaptors/rxjava-scala/build.gradle b/language-adaptors/rxjava-scala/build.gradle index 95628cbb1f..e9d1b3363a 100644 --- a/language-adaptors/rxjava-scala/build.gradle +++ b/language-adaptors/rxjava-scala/build.gradle @@ -40,7 +40,6 @@ jar { name = 'rxjava-scala' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,!org.scalatest.*,*' instruction 'Fragment-Host', 'com.netflix.rxjava.core' } } diff --git a/rxjava-contrib/rxjava-android/build.gradle b/rxjava-contrib/rxjava-android/build.gradle index 55f4e33b67..5e7ace0555 100644 --- a/rxjava-contrib/rxjava-android/build.gradle +++ b/rxjava-contrib/rxjava-android/build.gradle @@ -5,10 +5,9 @@ dependencies { provided 'com.google.android:android:4.0.1.2' provided 'com.google.android:support-v4:r7' - // testing - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' - provided 'org.robolectric:robolectric:2.1.1' + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' + testCompile 'org.robolectric:robolectric:2.1.1' } @@ -17,7 +16,6 @@ jar { name = 'rxjava-android' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' } } diff --git a/rxjava-contrib/rxjava-apache-http/build.gradle b/rxjava-contrib/rxjava-apache-http/build.gradle index a6f7f4931f..32f6d788b0 100644 --- a/rxjava-contrib/rxjava-apache-http/build.gradle +++ b/rxjava-contrib/rxjava-apache-http/build.gradle @@ -10,6 +10,5 @@ jar { name = 'rxjava-apache-http' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' } } diff --git a/rxjava-contrib/rxjava-async-util/build.gradle b/rxjava-contrib/rxjava-async-util/build.gradle index 1fca841426..6ec16872bf 100644 --- a/rxjava-contrib/rxjava-async-util/build.gradle +++ b/rxjava-contrib/rxjava-async-util/build.gradle @@ -1,8 +1,8 @@ dependencies { compile project(':rxjava-core') testCompile project(":rxjava-core").sourceSets.test.output - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' } jar { @@ -10,6 +10,5 @@ jar { name = 'rxjava-async-util' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' } } diff --git a/rxjava-contrib/rxjava-computation-expressions/build.gradle b/rxjava-contrib/rxjava-computation-expressions/build.gradle index 95fd66a7ea..a9bbcd7a31 100644 --- a/rxjava-contrib/rxjava-computation-expressions/build.gradle +++ b/rxjava-contrib/rxjava-computation-expressions/build.gradle @@ -9,6 +9,5 @@ jar { name = 'rxjava-computation-expressions' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' } } diff --git a/rxjava-contrib/rxjava-string/build.gradle b/rxjava-contrib/rxjava-string/build.gradle index 0094d63be2..aa434e6543 100644 --- a/rxjava-contrib/rxjava-string/build.gradle +++ b/rxjava-contrib/rxjava-string/build.gradle @@ -1,8 +1,8 @@ dependencies { compile project(':rxjava-core') testCompile project(":rxjava-core").sourceSets.test.output - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' } jar { @@ -10,6 +10,5 @@ jar { name = 'rxjava-string' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' } } diff --git a/rxjava-contrib/rxjava-swing/build.gradle b/rxjava-contrib/rxjava-swing/build.gradle index 379245ca13..775a567e71 100644 --- a/rxjava-contrib/rxjava-swing/build.gradle +++ b/rxjava-contrib/rxjava-swing/build.gradle @@ -1,7 +1,7 @@ dependencies { compile project(':rxjava-core') - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' } jar { @@ -9,6 +9,5 @@ jar { name = 'rxjava-swing' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' } } diff --git a/rxjava-core/build.gradle b/rxjava-core/build.gradle index 4df5e66916..ef0064e8fe 100644 --- a/rxjava-core/build.gradle +++ b/rxjava-core/build.gradle @@ -1,8 +1,8 @@ apply plugin: 'maven' dependencies { - provided 'junit:junit-dep:4.10' - provided 'org.mockito:mockito-core:1.8.5' + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' } jar { @@ -10,7 +10,6 @@ jar { name = 'rxjava-core' instruction 'Bundle-Vendor', 'Netflix' instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*' } } From 055078c8ff5ec5704a46365b5f0cc1e74d57e2cf Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:13:14 +0000 Subject: [PATCH 12/26] Consolidate the manifest entry configuration. --- gradle/convention.gradle | 11 +++++++++++ language-adaptors/rxjava-clojure/build.gradle | 9 --------- language-adaptors/rxjava-groovy/build.gradle | 9 --------- language-adaptors/rxjava-jruby/build.gradle | 11 +---------- language-adaptors/rxjava-kotlin/build.gradle | 9 --------- language-adaptors/rxjava-scala/build.gradle | 11 +---------- rxjava-contrib/rxjava-android/build.gradle | 9 --------- rxjava-contrib/rxjava-apache-http/build.gradle | 8 -------- rxjava-contrib/rxjava-async-util/build.gradle | 8 -------- .../rxjava-computation-expressions/build.gradle | 8 -------- rxjava-contrib/rxjava-string/build.gradle | 10 +--------- rxjava-contrib/rxjava-swing/build.gradle | 10 +--------- rxjava-core/build.gradle | 8 -------- 13 files changed, 15 insertions(+), 106 deletions(-) diff --git a/gradle/convention.gradle b/gradle/convention.gradle index 395dc885a2..1673515c28 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -29,6 +29,17 @@ subprojects { project -> extension 'jar' } + jar { + manifest { + name = project.name + instruction 'Bundle-Vendor', 'Netflix' + instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' + if (project.path != ":rxjava-core") { + instruction 'Fragment-Host', 'com.netflix.rxjava.core' + } + } + } + configurations { create("sources") create("javadoc") diff --git a/language-adaptors/rxjava-clojure/build.gradle b/language-adaptors/rxjava-clojure/build.gradle index 1dcf82eba3..fcca775fea 100644 --- a/language-adaptors/rxjava-clojure/build.gradle +++ b/language-adaptors/rxjava-clojure/build.gradle @@ -23,12 +23,3 @@ eclipse { natures "ccw.nature" } } - -jar { - manifest { - name = 'rxjava-clojure' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} diff --git a/language-adaptors/rxjava-groovy/build.gradle b/language-adaptors/rxjava-groovy/build.gradle index 79a622374c..1d1e573bf1 100644 --- a/language-adaptors/rxjava-groovy/build.gradle +++ b/language-adaptors/rxjava-groovy/build.gradle @@ -6,12 +6,3 @@ dependencies { testCompile 'junit:junit-dep:4.10' testCompile 'org.mockito:mockito-core:1.8.5' } - -jar { - manifest { - name = 'rxjava-groovy' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} \ No newline at end of file diff --git a/language-adaptors/rxjava-jruby/build.gradle b/language-adaptors/rxjava-jruby/build.gradle index e540d83164..5001194b89 100644 --- a/language-adaptors/rxjava-jruby/build.gradle +++ b/language-adaptors/rxjava-jruby/build.gradle @@ -34,13 +34,4 @@ task(rspec, type: JavaExec) { } tasks.build.dependsOn << 'rspec' -*/ - -jar { - manifest { - name = 'rxjava-jruby' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} +*/ \ No newline at end of file diff --git a/language-adaptors/rxjava-kotlin/build.gradle b/language-adaptors/rxjava-kotlin/build.gradle index 15d625d85e..eb5b66c992 100644 --- a/language-adaptors/rxjava-kotlin/build.gradle +++ b/language-adaptors/rxjava-kotlin/build.gradle @@ -15,13 +15,4 @@ dependencies { compile 'org.jetbrains.kotlin:kotlin-stdlib:0.6.1673' testCompile 'junit:junit-dep:4.10' testCompile 'org.mockito:mockito-core:1.8.5' -} - -jar { - manifest { - name = 'rxjava-kotlin' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } } \ No newline at end of file diff --git a/language-adaptors/rxjava-scala/build.gradle b/language-adaptors/rxjava-scala/build.gradle index e9d1b3363a..2c5391edac 100644 --- a/language-adaptors/rxjava-scala/build.gradle +++ b/language-adaptors/rxjava-scala/build.gradle @@ -33,13 +33,4 @@ task test(overwrite: true, dependsOn: testClasses) << { ant.scalatest(runpath: sourceSets.test.output.classesDir, haltonfailure: 'true', fork: 'false') {reporter(type: 'stdout')} -} - -jar { - manifest { - name = 'rxjava-scala' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - instruction 'Fragment-Host', 'com.netflix.rxjava.core' - } -} +} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-android/build.gradle b/rxjava-contrib/rxjava-android/build.gradle index 5e7ace0555..6372ac6f85 100644 --- a/rxjava-contrib/rxjava-android/build.gradle +++ b/rxjava-contrib/rxjava-android/build.gradle @@ -10,15 +10,6 @@ dependencies { testCompile 'org.robolectric:robolectric:2.1.1' } - -jar { - manifest { - name = 'rxjava-android' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - } -} - test { testLogging { exceptionFormat "full" diff --git a/rxjava-contrib/rxjava-apache-http/build.gradle b/rxjava-contrib/rxjava-apache-http/build.gradle index 32f6d788b0..1587847167 100644 --- a/rxjava-contrib/rxjava-apache-http/build.gradle +++ b/rxjava-contrib/rxjava-apache-http/build.gradle @@ -4,11 +4,3 @@ dependencies { compile 'org.apache.httpcomponents:httpcore-nio:4.3' compile 'org.apache.httpcomponents:httpasyncclient:4.0' } - -jar { - manifest { - name = 'rxjava-apache-http' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - } -} diff --git a/rxjava-contrib/rxjava-async-util/build.gradle b/rxjava-contrib/rxjava-async-util/build.gradle index 6ec16872bf..40dd0a4371 100644 --- a/rxjava-contrib/rxjava-async-util/build.gradle +++ b/rxjava-contrib/rxjava-async-util/build.gradle @@ -4,11 +4,3 @@ dependencies { testCompile 'junit:junit-dep:4.10' testCompile 'org.mockito:mockito-core:1.8.5' } - -jar { - manifest { - name = 'rxjava-async-util' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - } -} diff --git a/rxjava-contrib/rxjava-computation-expressions/build.gradle b/rxjava-contrib/rxjava-computation-expressions/build.gradle index a9bbcd7a31..43f6b6cf04 100644 --- a/rxjava-contrib/rxjava-computation-expressions/build.gradle +++ b/rxjava-contrib/rxjava-computation-expressions/build.gradle @@ -3,11 +3,3 @@ dependencies { testCompile 'junit:junit-dep:4.10' testCompile 'org.mockito:mockito-core:1.8.5' } - -jar { - manifest { - name = 'rxjava-computation-expressions' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - } -} diff --git a/rxjava-contrib/rxjava-string/build.gradle b/rxjava-contrib/rxjava-string/build.gradle index aa434e6543..8fdb7e06eb 100644 --- a/rxjava-contrib/rxjava-string/build.gradle +++ b/rxjava-contrib/rxjava-string/build.gradle @@ -3,12 +3,4 @@ dependencies { testCompile project(":rxjava-core").sourceSets.test.output testCompile 'junit:junit-dep:4.10' testCompile 'org.mockito:mockito-core:1.8.5' -} - -jar { - manifest { - name = 'rxjava-string' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - } -} +} \ No newline at end of file diff --git a/rxjava-contrib/rxjava-swing/build.gradle b/rxjava-contrib/rxjava-swing/build.gradle index 775a567e71..b1d78dc2a0 100644 --- a/rxjava-contrib/rxjava-swing/build.gradle +++ b/rxjava-contrib/rxjava-swing/build.gradle @@ -2,12 +2,4 @@ dependencies { compile project(':rxjava-core') testCompile 'junit:junit-dep:4.10' testCompile 'org.mockito:mockito-core:1.8.5' -} - -jar { - manifest { - name = 'rxjava-swing' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - } -} +} \ No newline at end of file diff --git a/rxjava-core/build.gradle b/rxjava-core/build.gradle index ef0064e8fe..0a4380e63d 100644 --- a/rxjava-core/build.gradle +++ b/rxjava-core/build.gradle @@ -5,11 +5,3 @@ dependencies { testCompile 'org.mockito:mockito-core:1.8.5' } -jar { - manifest { - name = 'rxjava-core' - instruction 'Bundle-Vendor', 'Netflix' - instruction 'Bundle-DocURL', 'https://github.com/Netflix/RxJava' - } -} - From 21ba03c58faf59991b9b7feb1a42a3175ec3ff0a Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:25:30 +0000 Subject: [PATCH 13/26] Move common dependencies to convention script. --- gradle/convention.gradle | 17 +++++++++++++---- language-adaptors/rxjava-clojure/build.gradle | 1 - language-adaptors/rxjava-groovy/build.gradle | 3 --- language-adaptors/rxjava-jruby/build.gradle | 3 --- language-adaptors/rxjava-kotlin/build.gradle | 3 --- language-adaptors/rxjava-scala/build.gradle | 4 ---- rxjava-contrib/rxjava-android/build.gradle | 5 ----- rxjava-contrib/rxjava-apache-http/build.gradle | 1 - rxjava-contrib/rxjava-async-util/build.gradle | 5 +---- .../rxjava-computation-expressions/build.gradle | 5 ----- rxjava-contrib/rxjava-string/build.gradle | 5 +---- rxjava-contrib/rxjava-swing/build.gradle | 5 ----- 12 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 rxjava-contrib/rxjava-computation-expressions/build.gradle delete mode 100644 rxjava-contrib/rxjava-swing/build.gradle diff --git a/gradle/convention.gradle b/gradle/convention.gradle index 1673515c28..708770c7ef 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -1,7 +1,7 @@ // GRADLE-2087 workaround, perform after java plugin status = project.hasProperty('preferredStatus') ? project.preferredStatus : (version.contains('SNAPSHOT') ? 'snapshot' : 'release') -subprojects { project -> +subprojects { if (!subprojects.empty) { // is a container return } @@ -11,6 +11,15 @@ subprojects { project -> apply plugin: 'java' apply plugin: 'osgi' + dependencies { + if (project.path != ":rxjava-core") { + compile project(':rxjava-core') + } + + testCompile 'junit:junit-dep:4.10' + testCompile 'org.mockito:mockito-core:1.8.5' + } + sourceCompatibility = JavaVersion.VERSION_1_6 targetCompatibility = JavaVersion.VERSION_1_6 @@ -49,7 +58,7 @@ subprojects { project -> } } - // When outputing to an Ivy repo, we want to use the proper type field +// When outputing to an Ivy repo, we want to use the proper type field gradle.taskGraph.whenReady { def isNotMaven = !it.hasTask(project.uploadMavenCentral) if (isNotMaven) { @@ -116,8 +125,8 @@ subprojects { project -> dependsOn examplesClasses } - // Individual projects will apply specific language plugins which add to source sets… - // do this late so we get those additions +// Individual projects will apply specific language plugins which add to source sets… +// do this late so we get those additions afterEvaluate { idea { module { diff --git a/language-adaptors/rxjava-clojure/build.gradle b/language-adaptors/rxjava-clojure/build.gradle index fcca775fea..5619cf9d4e 100644 --- a/language-adaptors/rxjava-clojure/build.gradle +++ b/language-adaptors/rxjava-clojure/build.gradle @@ -10,7 +10,6 @@ repositories { } dependencies { - compile project(':rxjava-core') compile 'org.clojure:clojure:1.4.+' compile 'clj-http:clj-http:0.6.4' // https://clojars.org/clj-http } diff --git a/language-adaptors/rxjava-groovy/build.gradle b/language-adaptors/rxjava-groovy/build.gradle index 1d1e573bf1..24e45c1604 100644 --- a/language-adaptors/rxjava-groovy/build.gradle +++ b/language-adaptors/rxjava-groovy/build.gradle @@ -1,8 +1,5 @@ apply plugin: 'groovy' dependencies { - compile project(':rxjava-core') compile 'org.codehaus.groovy:groovy-all:2.+' - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' } diff --git a/language-adaptors/rxjava-jruby/build.gradle b/language-adaptors/rxjava-jruby/build.gradle index 5001194b89..2f4a9f1c6a 100644 --- a/language-adaptors/rxjava-jruby/build.gradle +++ b/language-adaptors/rxjava-jruby/build.gradle @@ -18,10 +18,7 @@ sourceSets { } dependencies { - compile project(':rxjava-core') compile 'org.jruby:jruby:1.7+' - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' rspec 'org.jruby:jruby-complete:1.7.4' rspec 'org.rubygems:rspec:2.14.1' } diff --git a/language-adaptors/rxjava-kotlin/build.gradle b/language-adaptors/rxjava-kotlin/build.gradle index eb5b66c992..08433b7947 100644 --- a/language-adaptors/rxjava-kotlin/build.gradle +++ b/language-adaptors/rxjava-kotlin/build.gradle @@ -11,8 +11,5 @@ buildscript { apply plugin: 'kotlin' dependencies { - compile project(':rxjava-core') compile 'org.jetbrains.kotlin:kotlin-stdlib:0.6.1673' - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' } \ No newline at end of file diff --git a/language-adaptors/rxjava-scala/build.gradle b/language-adaptors/rxjava-scala/build.gradle index 2c5391edac..6f2bd507fe 100644 --- a/language-adaptors/rxjava-scala/build.gradle +++ b/language-adaptors/rxjava-scala/build.gradle @@ -13,10 +13,6 @@ tasks.withType(ScalaCompile) { dependencies { compile 'org.scala-lang:scala-library:2.10.+' - compile project(':rxjava-core') - - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' testCompile 'org.scalatest:scalatest_2.10:1.9.1' } diff --git a/rxjava-contrib/rxjava-android/build.gradle b/rxjava-contrib/rxjava-android/build.gradle index 6372ac6f85..430ebc08ce 100644 --- a/rxjava-contrib/rxjava-android/build.gradle +++ b/rxjava-contrib/rxjava-android/build.gradle @@ -1,12 +1,7 @@ - - dependencies { - compile project(':rxjava-core') provided 'com.google.android:android:4.0.1.2' provided 'com.google.android:support-v4:r7' - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' testCompile 'org.robolectric:robolectric:2.1.1' } diff --git a/rxjava-contrib/rxjava-apache-http/build.gradle b/rxjava-contrib/rxjava-apache-http/build.gradle index 1587847167..fbc99f7179 100644 --- a/rxjava-contrib/rxjava-apache-http/build.gradle +++ b/rxjava-contrib/rxjava-apache-http/build.gradle @@ -1,5 +1,4 @@ dependencies { - compile project(':rxjava-core') compile 'org.apache.httpcomponents:httpclient:4.3' compile 'org.apache.httpcomponents:httpcore-nio:4.3' compile 'org.apache.httpcomponents:httpasyncclient:4.0' diff --git a/rxjava-contrib/rxjava-async-util/build.gradle b/rxjava-contrib/rxjava-async-util/build.gradle index 40dd0a4371..14bcedd41b 100644 --- a/rxjava-contrib/rxjava-async-util/build.gradle +++ b/rxjava-contrib/rxjava-async-util/build.gradle @@ -1,6 +1,3 @@ dependencies { - compile project(':rxjava-core') - testCompile project(":rxjava-core").sourceSets.test.output - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' + testCompile project(":rxjava-core").sourceSets.test.output } diff --git a/rxjava-contrib/rxjava-computation-expressions/build.gradle b/rxjava-contrib/rxjava-computation-expressions/build.gradle deleted file mode 100644 index 43f6b6cf04..0000000000 --- a/rxjava-contrib/rxjava-computation-expressions/build.gradle +++ /dev/null @@ -1,5 +0,0 @@ -dependencies { - compile project(':rxjava-core') - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' -} diff --git a/rxjava-contrib/rxjava-string/build.gradle b/rxjava-contrib/rxjava-string/build.gradle index 8fdb7e06eb..cc5b80a18a 100644 --- a/rxjava-contrib/rxjava-string/build.gradle +++ b/rxjava-contrib/rxjava-string/build.gradle @@ -1,6 +1,3 @@ dependencies { - compile project(':rxjava-core') - testCompile project(":rxjava-core").sourceSets.test.output - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' + testCompile project(":rxjava-core").sourceSets.test.output } \ No newline at end of file diff --git a/rxjava-contrib/rxjava-swing/build.gradle b/rxjava-contrib/rxjava-swing/build.gradle deleted file mode 100644 index b1d78dc2a0..0000000000 --- a/rxjava-contrib/rxjava-swing/build.gradle +++ /dev/null @@ -1,5 +0,0 @@ -dependencies { - compile project(':rxjava-core') - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' -} \ No newline at end of file From 2cda41191f55004878f25e1046f0dcd315be804e Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:26:37 +0000 Subject: [PATCH 14/26] Formatting. --- settings.gradle | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/settings.gradle b/settings.gradle index 22dd94ec82..cd914cd14d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,13 +1,14 @@ -rootProject.name='rxjava' -include 'rxjava-core', \ -'language-adaptors:rxjava-groovy', \ -'language-adaptors:rxjava-clojure', \ -'language-adaptors:rxjava-jruby', \ -'language-adaptors:rxjava-scala', \ -'language-adaptors:rxjava-kotlin', \ -'rxjava-contrib:rxjava-swing', \ -'rxjava-contrib:rxjava-android', \ -'rxjava-contrib:rxjava-apache-http', \ -'rxjava-contrib:rxjava-string', \ -'rxjava-contrib:rxjava-async-util', \ -'rxjava-contrib:rxjava-computation-expressions' +rootProject.name = 'rxjava' + +include 'rxjava-core', + 'language-adaptors:rxjava-groovy', + 'language-adaptors:rxjava-clojure', + 'language-adaptors:rxjava-jruby', + 'language-adaptors:rxjava-scala', + 'language-adaptors:rxjava-kotlin', + 'rxjava-contrib:rxjava-swing', + 'rxjava-contrib:rxjava-android', + 'rxjava-contrib:rxjava-apache-http', + 'rxjava-contrib:rxjava-string', + 'rxjava-contrib:rxjava-async-util', + 'rxjava-contrib:rxjava-computation-expressions' From ba765866a664c27dc41c99f67d8d188889c08f2c Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:36:55 +0000 Subject: [PATCH 15/26] Extract reusable test utilities out into separate project. This allows them to be properly shared and tested, and this configuration maps to IDEs better. --- rxjava-contrib/rxjava-async-util/build.gradle | 2 +- rxjava-contrib/rxjava-string/build.gradle | 2 +- rxjava-core/build.gradle | 3 +-- .../src/main}/java/rx/util/AssertObservable.java | 0 .../src/test/java/rx/util/AssertObservableTest.java | 0 settings.gradle | 1 + 6 files changed, 4 insertions(+), 4 deletions(-) rename {rxjava-core/src/test => rxjava-test/src/main}/java/rx/util/AssertObservable.java (100%) rename {rxjava-core => rxjava-test}/src/test/java/rx/util/AssertObservableTest.java (100%) diff --git a/rxjava-contrib/rxjava-async-util/build.gradle b/rxjava-contrib/rxjava-async-util/build.gradle index 14bcedd41b..374e1d8c37 100644 --- a/rxjava-contrib/rxjava-async-util/build.gradle +++ b/rxjava-contrib/rxjava-async-util/build.gradle @@ -1,3 +1,3 @@ dependencies { - testCompile project(":rxjava-core").sourceSets.test.output + testCompile project(":rxjava-test") } diff --git a/rxjava-contrib/rxjava-string/build.gradle b/rxjava-contrib/rxjava-string/build.gradle index cc5b80a18a..31ec9b1875 100644 --- a/rxjava-contrib/rxjava-string/build.gradle +++ b/rxjava-contrib/rxjava-string/build.gradle @@ -1,3 +1,3 @@ dependencies { - testCompile project(":rxjava-core").sourceSets.test.output + testCompile project(":rxjava-test") } \ No newline at end of file diff --git a/rxjava-core/build.gradle b/rxjava-core/build.gradle index 0a4380e63d..6693224d33 100644 --- a/rxjava-core/build.gradle +++ b/rxjava-core/build.gradle @@ -1,7 +1,6 @@ apply plugin: 'maven' dependencies { - testCompile 'junit:junit-dep:4.10' - testCompile 'org.mockito:mockito-core:1.8.5' + testCompile project(":rxjava-test") } diff --git a/rxjava-core/src/test/java/rx/util/AssertObservable.java b/rxjava-test/src/main/java/rx/util/AssertObservable.java similarity index 100% rename from rxjava-core/src/test/java/rx/util/AssertObservable.java rename to rxjava-test/src/main/java/rx/util/AssertObservable.java diff --git a/rxjava-core/src/test/java/rx/util/AssertObservableTest.java b/rxjava-test/src/test/java/rx/util/AssertObservableTest.java similarity index 100% rename from rxjava-core/src/test/java/rx/util/AssertObservableTest.java rename to rxjava-test/src/test/java/rx/util/AssertObservableTest.java diff --git a/settings.gradle b/settings.gradle index cd914cd14d..3ec339a5ed 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,7 @@ rootProject.name = 'rxjava' include 'rxjava-core', + 'rxjava-test', 'language-adaptors:rxjava-groovy', 'language-adaptors:rxjava-clojure', 'language-adaptors:rxjava-jruby', From 2e34dc02b215d60cd82f063ab429b3d9e4e51547 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:39:00 +0000 Subject: [PATCH 16/26] Formatting. No functional change. --- gradle/maven.gradle | 93 ++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 47 deletions(-) diff --git a/gradle/maven.gradle b/gradle/maven.gradle index 817846d77f..827b3731a7 100644 --- a/gradle/maven.gradle +++ b/gradle/maven.gradle @@ -1,4 +1,3 @@ -// Maven side of things subprojects { apply plugin: 'maven' // Java plugin has to have been already applied for the conf2scope mappings to work apply plugin: 'signing' @@ -8,63 +7,63 @@ subprojects { sign configurations.archives } -/** - * Publishing to Maven Central example provided from http://jedicoder.blogspot.com/2011/11/automated-gradle-project-deployment-to.html - * artifactory will execute uploadArchives to force generation of ivy.xml, and we don't want that to trigger an upload to maven - * central, so using custom upload task. - */ -task uploadMavenCentral(type:Upload, dependsOn: signArchives) { - configuration = configurations.archives - onlyIf { ['release', 'snapshot'].contains(project.status) } + /** + * Publishing to Maven Central example provided from http://jedicoder.blogspot.com/2011/11/automated-gradle-project-deployment-to.html + * artifactory will execute uploadArchives to force generation of ivy.xml, and we don't want that to trigger an upload to maven + * central, so using custom upload task. + */ + task uploadMavenCentral(type: Upload, dependsOn: signArchives) { + configuration = configurations.archives + onlyIf { ['release', 'snapshot'].contains(project.status) } repositories.mavenDeployer { beforeDeployment { signing.signPom(it) } - // To test deployment locally, use the following instead of oss.sonatype.org - //repository(url: "file://localhost/${rootProject.rootDir}/repo") + // To test deployment locally, use the following instead of oss.sonatype.org + //repository(url: "file://localhost/${rootProject.rootDir}/repo") - def sonatypeUsername = rootProject.hasProperty('sonatypeUsername')?rootProject.sonatypeUsername:'' - def sonatypePassword = rootProject.hasProperty('sonatypePassword')?rootProject.sonatypePassword:'' + def sonatypeUsername = rootProject.hasProperty('sonatypeUsername') ? rootProject.sonatypeUsername : '' + def sonatypePassword = rootProject.hasProperty('sonatypePassword') ? rootProject.sonatypePassword : '' - repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') { - authentication(userName: sonatypeUsername, password: sonatypePassword) - } + repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2') { + authentication(userName: sonatypeUsername, password: sonatypePassword) + } - snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') { - authentication(userName: sonatypeUsername, password: sonatypePassword) - } + snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/') { + authentication(userName: sonatypeUsername, password: sonatypePassword) + } - // Prevent datastamp from being appending to artifacts during deployment - uniqueVersion = false + // Prevent datastamp from being appending to artifacts during deployment + uniqueVersion = false - // Closure to configure all the POM with extra info, common to all projects - pom.project { - name "${project.name}" - description "${project.name} developed by Netflix" - developers { - developer { - id 'netflixgithub' - name 'Netflix Open Source Development' - email 'talent@netflix.com' - } - } - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } + // Closure to configure all the POM with extra info, common to all projects + pom.project { + name "${project.name}" + description "${project.name} developed by Netflix" + developers { + developer { + id 'netflixgithub' + name 'Netflix Open Source Development' + email 'talent@netflix.com' } - url "https://github.com/Netflix/$%7BrootProject.githubProjectName%7D" - scm { - connection "scm:git:git@github.com:Netflix/${rootProject.githubProjectName}.git" - url "scm:git:git@github.com:Netflix/${rootProject.githubProjectName}.git" - developerConnection "scm:git:git@github.com:Netflix/${rootProject.githubProjectName}.git" - } - issueManagement { - system 'github' - url "https://github.com/Netflix/$%7BrootProject.githubProjectName%7D/issues" + } + licenses { + license { + name 'The Apache Software License, Version 2.0' + url 'http://www.apache.org/licenses/LICENSE-2.0.txt' + distribution 'repo' } } + url "https://github.com/Netflix/$%7BrootProject.githubProjectName%7D" + scm { + connection "scm:git:git@github.com:Netflix/${rootProject.githubProjectName}.git" + url "scm:git:git@github.com:Netflix/${rootProject.githubProjectName}.git" + developerConnection "scm:git:git@github.com:Netflix/${rootProject.githubProjectName}.git" + } + issueManagement { + system 'github' + url "https://github.com/Netflix/$%7BrootProject.githubProjectName%7D/issues" + } } } + } } From 0bcef5e2176aac8c074aa3b1ad4aaf4434ffb063 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:39:35 +0000 Subject: [PATCH 17/26] Remove redundant build script content. --- rxjava-core/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/rxjava-core/build.gradle b/rxjava-core/build.gradle index 6693224d33..43f0c5dbfe 100644 --- a/rxjava-core/build.gradle +++ b/rxjava-core/build.gradle @@ -1,5 +1,3 @@ -apply plugin: 'maven' - dependencies { testCompile project(":rxjava-test") } From be07ef97b9b2d1c131aaca5ef09bf652e2032811 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:42:38 +0000 Subject: [PATCH 18/26] Run the Java tests in parallel. --- rxjava-core/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rxjava-core/build.gradle b/rxjava-core/build.gradle index 43f0c5dbfe..1d1bf4bf9c 100644 --- a/rxjava-core/build.gradle +++ b/rxjava-core/build.gradle @@ -2,3 +2,6 @@ dependencies { testCompile project(":rxjava-test") } +test { + maxParallelForks 4 +} \ No newline at end of file From 389ca6111ad14eeb9948d6650b481dc861951dcf Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:44:19 +0000 Subject: [PATCH 19/26] Simplify status configuration. --- gradle/convention.gradle | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/gradle/convention.gradle b/gradle/convention.gradle index 708770c7ef..7492886c42 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -1,6 +1,3 @@ -// GRADLE-2087 workaround, perform after java plugin -status = project.hasProperty('preferredStatus') ? project.preferredStatus : (version.contains('SNAPSHOT') ? 'snapshot' : 'release') - subprojects { if (!subprojects.empty) { // is a container return @@ -23,8 +20,7 @@ subprojects { sourceCompatibility = JavaVersion.VERSION_1_6 targetCompatibility = JavaVersion.VERSION_1_6 - // Restore status after Java plugin - status = rootProject.status + status = project.hasProperty('preferredStatus') ? project.preferredStatus : (version.contains('SNAPSHOT') ? 'snapshot' : 'release') task sourcesJar(type: Jar, dependsOn: classes) { from sourceSets.main.allSource From bd610f0d0deb79f0816b880c7da2baf5bfbcad04 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:45:41 +0000 Subject: [PATCH 20/26] Move the repositories to live with the rest of the common config. --- build.gradle | 6 ------ gradle/convention.gradle | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index caec0a87e0..d4b0e70686 100644 --- a/build.gradle +++ b/build.gradle @@ -10,14 +10,8 @@ buildscript { allprojects { group = "com.netflix.rxjava" - apply plugin: 'eclipse' apply plugin: 'idea' - - repositories { - mavenLocal() - mavenCentral() // maven { url: 'http://jcenter.bintray.com/' } - } } apply from: file('gradle/convention.gradle') diff --git a/gradle/convention.gradle b/gradle/convention.gradle index 7492886c42..0e65581c79 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -8,6 +8,11 @@ subprojects { apply plugin: 'java' apply plugin: 'osgi' + repositories { + mavenLocal() + mavenCentral() // maven { url: 'http://jcenter.bintray.com/' } + } + dependencies { if (project.path != ":rxjava-core") { compile project(':rxjava-core') From eee3be8f9ca7fcd08fe86c9f05824ecf71355356 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:48:18 +0000 Subject: [PATCH 21/26] Move github-pages config to its own file. --- build.gradle | 1 + gradle/convention.gradle | 39 +++----------------------------------- gradle/gtihub-pages.gradle | 32 +++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 36 deletions(-) create mode 100644 gradle/gtihub-pages.gradle diff --git a/build.gradle b/build.gradle index d4b0e70686..39f4dcc772 100644 --- a/build.gradle +++ b/build.gradle @@ -19,3 +19,4 @@ apply from: file('gradle/maven.gradle') //apply from: file('gradle/check.gradle') apply from: file('gradle/license.gradle') apply from: file('gradle/release.gradle') +apply from: file('gradle/github-pages.gradle') diff --git a/gradle/convention.gradle b/gradle/convention.gradle index 0e65581c79..33afde279b 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -59,7 +59,7 @@ subprojects { } } -// When outputing to an Ivy repo, we want to use the proper type field + // When outputing to an Ivy repo, we want to use the proper type field gradle.taskGraph.whenReady { def isNotMaven = !it.hasTask(project.uploadMavenCentral) if (isNotMaven) { @@ -126,8 +126,8 @@ subprojects { dependsOn examplesClasses } -// Individual projects will apply specific language plugins which add to source sets… -// do this late so we get those additions + // Individual projects will apply specific language plugins which add to source sets… + // do this late so we get those additions afterEvaluate { idea { module { @@ -148,37 +148,4 @@ subprojects { } } -} - -apply plugin: 'github-pages' // Used to create publishGhPages task - -def docTasks = [:] -[Javadoc, ScalaDoc, Groovydoc].each { Class docClass -> - def allSources = allprojects.tasks*.withType(docClass).flatten()*.source - if (allSources) { - def shortName = docClass.simpleName.toLowerCase() - def docTask = task "aggregate${shortName.capitalize()}"(type: docClass, description: "Aggregate subproject ${shortName}s") { - source = allSources - destinationDir = file("${project.buildDir}/docs/${shortName}") - doFirst { - def classpaths = allprojects.findAll { it.plugins.hasPlugin(JavaPlugin) }.collect { - it.sourceSets.main.compileClasspath - } - classpath = files(classpaths) - } - } - docTasks[shortName] = docTask - processGhPages.dependsOn(docTask) - } -} - -githubPages { - repoUri = "git@github.com:Netflix/${rootProject.githubProjectName}.git" - pages { - docTasks.each { shortName, docTask -> - from(docTask.outputs.files) { - into "docs/${shortName}" - } - } - } } \ No newline at end of file diff --git a/gradle/gtihub-pages.gradle b/gradle/gtihub-pages.gradle new file mode 100644 index 0000000000..4b1831c60e --- /dev/null +++ b/gradle/gtihub-pages.gradle @@ -0,0 +1,32 @@ +apply plugin: 'github-pages' // Used to create publishGhPages task + +def docTasks = [:] +[Javadoc, ScalaDoc, Groovydoc].each { Class docClass -> + def allSources = allprojects.tasks*.withType(docClass).flatten()*.source + if (allSources) { + def shortName = docClass.simpleName.toLowerCase() + def docTask = task "aggregate${shortName.capitalize()}"(type: docClass, description: "Aggregate subproject ${shortName}s") { + source = allSources + destinationDir = file("${project.buildDir}/docs/${shortName}") + doFirst { + def classpaths = allprojects.findAll { it.plugins.hasPlugin(JavaPlugin) }.collect { + it.sourceSets.main.compileClasspath + } + classpath = files(classpaths) + } + } + docTasks[shortName] = docTask + processGhPages.dependsOn(docTask) + } +} + +githubPages { + repoUri = "git@github.com:Netflix/${rootProject.githubProjectName}.git" + pages { + docTasks.each { shortName, docTask -> + from(docTask.outputs.files) { + into "docs/${shortName}" + } + } + } +} \ No newline at end of file From 1ee6f146d0480a1efa83cbc5986a978d3f1d90cc Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:49:04 +0000 Subject: [PATCH 22/26] Formatting. No functional change. --- gradle/check.gradle | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/gradle/check.gradle b/gradle/check.gradle index a3e4b4e7f5..1b06d64ce9 100644 --- a/gradle/check.gradle +++ b/gradle/check.gradle @@ -1,26 +1,23 @@ subprojects { -// Checkstyle -apply plugin: 'checkstyle' -checkstyle { - ignoreFailures = true - configFile = rootProject.file('codequality/checkstyle.xml') -} + apply plugin: 'checkstyle' + checkstyle { + ignoreFailures = true + configFile = rootProject.file('codequality/checkstyle.xml') + } -// FindBugs -apply plugin: 'findbugs' -findbugs { - ignoreFailures = true -} + apply plugin: 'findbugs' + findbugs { + ignoreFailures = true + } -// PMD -apply plugin: 'pmd' -//tasks.withType(Pmd) { reports.html.enabled true } + apply plugin: 'pmd' + //tasks.withType(Pmd) { reports.html.enabled true } -apply plugin: 'cobertura' -cobertura { - sourceDirs = sourceSets.main.java.srcDirs - format = 'html' - includes = ['**/*.java', '**/*.groovy'] - excludes = [] -} + apply plugin: 'cobertura' + cobertura { + sourceDirs = sourceSets.main.java.srcDirs + format = 'html' + includes = ['**/*.java', '**/*.groovy'] + excludes = [] + } } From 244c8ad2e090df243438b763e4a150575afe4ee2 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:50:09 +0000 Subject: [PATCH 23/26] Formatting. No functional change. --- gradle/license.gradle | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/gradle/license.gradle b/gradle/license.gradle index abd2e2c0e1..71d2ce373d 100644 --- a/gradle/license.gradle +++ b/gradle/license.gradle @@ -1,10 +1,8 @@ -// Dependency for plugin was set in buildscript.gradle - subprojects { -apply plugin: 'license' //nl.javadude.gradle.plugins.license.LicensePlugin -license { - header rootProject.file('codequality/HEADER') - ext.year = Calendar.getInstance().get(Calendar.YEAR) - skipExistingHeaders true -} + apply plugin: 'license' //nl.javadude.gradle.plugins.license.LicensePlugin + license { + header rootProject.file('codequality/HEADER') + ext.year = Calendar.getInstance().get(Calendar.YEAR) + skipExistingHeaders true + } } From 26483cbcbac01dd037f83be99cd47d906bef8869 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 13:51:24 +0000 Subject: [PATCH 24/26] Inline buildscript.gradle. It's only used at the root. --- build.gradle | 12 +++++++++--- gradle/buildscript.gradle | 11 ----------- 2 files changed, 9 insertions(+), 14 deletions(-) delete mode 100644 gradle/buildscript.gradle diff --git a/build.gradle b/build.gradle index 39f4dcc772..acc2ea2537 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,19 @@ -ext.githubProjectName = 'RxJava' - buildscript { repositories { mavenLocal() mavenCentral() // maven { url 'http://jcenter.bintray.com/' } + repositories { maven { url 'http://dl.bintray.com/content/netflixoss/external-gradle-plugins/' } } // For gradle-release + } + dependencies { + classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.1' + classpath 'com.mapvine:gradle-cobertura-plugin:0.1' + classpath 'gradle-release:gradle-release:1.1.5' + classpath 'org.ajoberstar:gradle-git:0.5.0' } - apply from: file('gradle/buildscript.gradle'), to: buildscript } +ext.githubProjectName = 'RxJava' + allprojects { group = "com.netflix.rxjava" apply plugin: 'eclipse' diff --git a/gradle/buildscript.gradle b/gradle/buildscript.gradle deleted file mode 100644 index 0b6da7ce84..0000000000 --- a/gradle/buildscript.gradle +++ /dev/null @@ -1,11 +0,0 @@ -// Executed in context of buildscript -repositories { - // Repo in addition to maven central - repositories { maven { url 'http://dl.bintray.com/content/netflixoss/external-gradle-plugins/' } } // For gradle-release -} -dependencies { - classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.6.1' - classpath 'com.mapvine:gradle-cobertura-plugin:0.1' - classpath 'gradle-release:gradle-release:1.1.5' - classpath 'org.ajoberstar:gradle-git:0.5.0' -} From f034d80692b2bde918458c252c02d3182cc091a4 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 14:17:41 +0000 Subject: [PATCH 25/26] Fix file name. --- gradle/{gtihub-pages.gradle => github-pages.gradle} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename gradle/{gtihub-pages.gradle => github-pages.gradle} (100%) diff --git a/gradle/gtihub-pages.gradle b/gradle/github-pages.gradle similarity index 100% rename from gradle/gtihub-pages.gradle rename to gradle/github-pages.gradle From f0869179e97f9ba8d683ef6b0132257259e54033 Mon Sep 17 00:00:00 2001 From: Luke Daley Date: Tue, 21 Jan 2014 17:28:24 +0000 Subject: [PATCH 26/26] Make clj-http dependency an examples only dependency. --- language-adaptors/rxjava-clojure/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language-adaptors/rxjava-clojure/build.gradle b/language-adaptors/rxjava-clojure/build.gradle index 5619cf9d4e..3fa9b95e08 100644 --- a/language-adaptors/rxjava-clojure/build.gradle +++ b/language-adaptors/rxjava-clojure/build.gradle @@ -11,7 +11,7 @@ repositories { dependencies { compile 'org.clojure:clojure:1.4.+' - compile 'clj-http:clj-http:0.6.4' // https://clojars.org/clj-http + examplesCompile 'clj-http:clj-http:0.6.4' // https://clojars.org/clj-http } aotCompile = true