Skip to content

Commit 3753da2

Browse files
committed
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
1 parent a27388b commit 3753da2

File tree

5 files changed

+79
-94
lines changed

5 files changed

+79
-94
lines changed

build.gradle

Lines changed: 8 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
ext.githubProjectName = 'RxJava'
22

3-
apply from: file('gradle/convention.gradle')
4-
apply from: file('gradle/maven.gradle')
5-
//apply from: file('gradle/check.gradle')
6-
apply from: file('gradle/license.gradle')
7-
apply from: file('gradle/release.gradle')
8-
93
buildscript {
104
repositories {
115
mavenLocal()
@@ -15,59 +9,19 @@ buildscript {
159
}
1610

1711
allprojects {
12+
group = "com.netflix.rxjava"
13+
1814
apply plugin: 'eclipse'
1915
apply plugin: 'idea'
16+
2017
repositories {
2118
mavenLocal()
2219
mavenCentral() // maven { url: 'http://jcenter.bintray.com' }
2320
}
2421
}
2522

26-
subprojects {
27-
apply plugin: 'java'
28-
group = "com.netflix.rxjava"
29-
30-
// make 'examples' use the same classpath
31-
configurations {
32-
examplesCompile.extendsFrom compile
33-
examplesRuntime.extendsFrom runtime
34-
perfCompile.extendsFrom compile
35-
perfRuntime.extendsFrom runtime
36-
}
37-
38-
39-
tasks.withType(Javadoc).each {
40-
it.classpath = sourceSets.main.compileClasspath
41-
}
42-
43-
sourceSets {
44-
//include /src/examples folder
45-
examples
46-
//include /src/perf folder
47-
// perf //-> Not working so commented out
48-
}
49-
50-
tasks.build {
51-
//include 'examples' in build task
52-
dependsOn(examplesClasses)
53-
//include 'perf' in build task
54-
// dependsOn(perfClasses) //-> Not working so commented out
55-
}
56-
57-
eclipse {
58-
classpath {
59-
// include 'provided' dependencies on the classpath
60-
plusConfigurations += configurations.provided
61-
62-
downloadSources = true
63-
downloadJavadoc = true
64-
}
65-
}
66-
67-
idea {
68-
module {
69-
// include 'provided' dependencies on the classpath
70-
scopes.PROVIDED.plus += configurations.provided
71-
}
72-
}
73-
}
23+
apply from: file('gradle/convention.gradle')
24+
apply from: file('gradle/maven.gradle')
25+
//apply from: file('gradle/check.gradle')
26+
apply from: file('gradle/license.gradle')
27+
apply from: file('gradle/release.gradle')

gradle/convention.gradle

Lines changed: 66 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
// GRADLE-2087 workaround, perform after java plugin
2-
status = project.hasProperty('preferredStatus')?project.preferredStatus:(version.contains('SNAPSHOT')?'snapshot':'release')
2+
status = project.hasProperty('preferredStatus') ? project.preferredStatus : (version.contains('SNAPSHOT') ? 'snapshot' : 'release')
33

44
subprojects { project ->
5+
56
apply plugin: 'java' // Plugin as major conventions
67

78
sourceCompatibility = 1.6
89

910
// Restore status after Java plugin
1011
status = rootProject.status
1112

12-
task sourcesJar(type: Jar, dependsOn:classes) {
13+
task sourcesJar(type: Jar, dependsOn: classes) {
1314
from sourceSets.main.allSource
1415
classifier 'sources'
1516
extension 'jar'
1617
}
1718

18-
task javadocJar(type: Jar, dependsOn:javadoc) {
19+
task javadocJar(type: Jar, dependsOn: javadoc) {
1920
from javadoc.destinationDir
2021
classifier 'javadoc'
2122
extension 'jar'
2223
}
2324

24-
configurations.create('sources')
25-
configurations.create('javadoc')
26-
configurations.archives {
27-
extendsFrom configurations.sources
28-
extendsFrom configurations.javadoc
25+
configurations {
26+
create("sources")
27+
create("javadoc")
28+
archives {
29+
extendsFrom configurations.sources
30+
extendsFrom configurations.javadoc
31+
}
2932
}
3033

3134
// When outputing to an Ivy repo, we want to use the proper type field
@@ -56,26 +59,72 @@ subprojects { project ->
5659
}
5760
}
5861

59-
project.sourceSets {
60-
main.compileClasspath += project.configurations.provided
61-
main.runtimeClasspath -= project.configurations.provided
62-
test.compileClasspath += project.configurations.provided
63-
test.runtimeClasspath += project.configurations.provided
62+
sourceSets {
63+
main {
64+
compileClasspath += configurations.provided
65+
runtimeClasspath -= configurations.provided
66+
}
67+
test {
68+
compileClasspath += configurations.provided
69+
runtimeClasspath += configurations.provided
70+
}
71+
examples {
72+
compileClasspath += configurations.provided + main.output
73+
}
74+
perf {
75+
compileClasspath += configurations.provided + main.output
76+
}
77+
}
78+
79+
configurations {
80+
examplesCompile.extendsFrom testCompile
81+
examplesRuntime.extendsFrom testRuntime
82+
perfCompile.extendsFrom testCompile
83+
perfRuntime.extendsFrom testRuntime
84+
}
85+
86+
build {
87+
dependsOn examplesClasses
6488
}
89+
90+
// Individual projects will apply specific language plugins which add to source sets…
91+
// do this late so we get those additions
92+
afterEvaluate {
93+
idea {
94+
module {
95+
[sourceSets.examples, sourceSets.perf].each {
96+
[it.allSource.srcDirs, it.resources.srcDirs].each {
97+
testSourceDirs += it
98+
}
99+
}
100+
scopes.PROVIDED.plus += configurations.provided
101+
}
102+
}
103+
104+
eclipse {
105+
classpath {
106+
plusConfigurations += configurations.provided
107+
downloadJavadoc = true
108+
}
109+
}
110+
}
111+
65112
}
66113

67114
apply plugin: 'github-pages' // Used to create publishGhPages task
68115

69116
def docTasks = [:]
70-
[Javadoc,ScalaDoc,Groovydoc].each{ Class docClass ->
71-
def allSources = allprojects.tasks*.withType(docClass).flatten()*.source
117+
[Javadoc, ScalaDoc, Groovydoc].each { Class docClass ->
118+
def allSources = allprojects.tasks*.withType(docClass).flatten()*.source
72119
if (allSources) {
73120
def shortName = docClass.simpleName.toLowerCase()
74121
def docTask = task "aggregate${shortName.capitalize()}"(type: docClass, description: "Aggregate subproject ${shortName}s") {
75122
source = allSources
76123
destinationDir = file("${project.buildDir}/docs/${shortName}")
77124
doFirst {
78-
def classpaths = allprojects.findAll { it.plugins.hasPlugin(JavaPlugin) }.collect { it.sourceSets.main.compileClasspath }
125+
def classpaths = allprojects.findAll { it.plugins.hasPlugin(JavaPlugin) }.collect {
126+
it.sourceSets.main.compileClasspath
127+
}
79128
classpath = files(classpaths)
80129
}
81130
}
@@ -93,9 +142,4 @@ githubPages {
93142
}
94143
}
95144
}
96-
}
97-
98-
// Generate wrapper, which is distributed as part of source to alleviate the need of installing gradle
99-
task createWrapper(type: Wrapper) {
100-
gradleVersion = '1.6'
101-
}
145+
}

language-adaptors/rxjava-groovy/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ apply plugin: 'osgi'
44
dependencies {
55
compile project(':rxjava-core')
66
compile 'org.codehaus.groovy:groovy-all:2.+'
7-
provided 'junit:junit-dep:4.10'
8-
provided 'org.mockito:mockito-core:1.8.5'
7+
testCompile 'junit:junit-dep:4.10'
8+
testCompile 'org.mockito:mockito-core:1.8.5'
99
}
1010

1111
jar {

language-adaptors/rxjava-scala/build.gradle

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,13 @@ tasks.withType(ScalaCompile) {
1212
}
1313
}
1414

15-
sourceSets {
16-
test.scala.srcDir 'src/examples/scala'
17-
}
18-
1915
dependencies {
2016
compile 'org.scala-lang:scala-library:2.10.+'
21-
2217
compile project(':rxjava-core')
2318

24-
provided 'junit:junit-dep:4.10'
25-
provided 'org.mockito:mockito-core:1.8.5'
26-
provided 'org.scalatest:scalatest_2.10:1.9.1'
27-
}
28-
29-
tasks.compileScala {
30-
classpath = classpath + (configurations.compile + configurations.provided)
31-
}
32-
33-
tasks.compileExamplesScala {
34-
classpath = classpath + files(compileScala.destinationDir) + (configurations.compile + configurations.provided)
19+
testCompile 'junit:junit-dep:4.10'
20+
testCompile 'org.mockito:mockito-core:1.8.5'
21+
testCompile 'org.scalatest:scalatest_2.10:1.9.1'
3522
}
3623

3724
// Add RxJava core to Scaladoc input:

0 commit comments

Comments
 (0)