Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

cross build against scala versions 2.10.3 and 2.8.1 #22

Merged
merged 2 commits into from

3 participants

@cdfreeman

This pull request contains the changes necessary to support Scala cross-building with Gradle using versions 2.8.1 and 2.10.3. Gradle will suffix all Scala modules with the appropriate Scala version suffix (e.g. cluster becomes cluster_2.8.1 and cluster_2.10). Clients that consume Norbert artifacts will have to update the names used in their dependencies to include the suffix. To produce _2.10 artifacts, the crossBuild property needs to be set to true (e.g. gradle -PcrossBuild=true build) otherwise only tasks for the default Scala version (2.8.1) will be executed. Cross-building should be enabled when publishing artifacts but otherwise you may wish to keep it disabled (e.g. if generating an IDE project or if you are iterating on code and don't want the build to take 2x as long)

@sungjuc
Collaborator

Please increment the version to 0.6.60. Current head may have 0.6.59 version.

@sungjuc
Collaborator

Seems fine to me.

@apurvam apurvam merged commit f03d09f into linkedin:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 3, 2014
  1. cross build against scala versions 2.10.3 and 2.8.1

    Christopher Freeman authored
Commits on Mar 4, 2014
  1. incremented gradle version number to 0.6.60

    Christopher Freeman authored
This page is out of date. Refresh to see the latest.
View
45 build.gradle
@@ -9,27 +9,40 @@ File getEnvironmentScript()
apply from: environmentScript
-project.ext.externalDependency = [
- 'zookeeper':'org.apache.zookeeper:zookeeper:3.3.4',
- 'protobuf':'com.google.protobuf:protobuf-java:2.4.0a',
- 'log4j':'log4j:log4j:1.2.17',
- 'netty':'io.netty:netty:3.7.0.Final',
- 'slf4jApi':'org.slf4j:slf4j-api:1.7.5',
- 'slf4jLog4j':'org.slf4j:slf4j-log4j12:1.7.5',
- 'specs':'org.scala-tools.testing:specs_2.8.1:1.6.8',
- 'mockitoAll':'org.mockito:mockito-all:1.8.4',
- 'cglib':'cglib:cglib:2.1_3',
- 'objenesis':'org.objenesis:objenesis:1.2',
- 'scalaCompiler': 'org.scala-lang:scala-compiler:2.8.1',
- 'scalaLibrary': 'org.scala-lang:scala-library:2.8.1',
- 'scalatest': 'org.scalatest:scalatest:1.2',
- 'junit':'junit:junit:4.8.1'
-];
+def getScalaSuffix(scalaVersion) {
+ return scalaVersion.startsWith('2.10') ? '_2.10' : "_$scalaVersion"
+}
subprojects {
+
+ // the cross built scala modules share the same source directories so we need to make their output directories unique
+ buildDir = "${rootProject.buildDir}/$name"
+
plugins.withType(JavaPlugin) {
project.dependencies {
testCompile externalDependency.junit
}
}
+
+ def projectScalaVersion = properties.targetScalaVersions.split(',').find { name.contains(getScalaSuffix(it)) }
+ ext.scalaVersion = projectScalaVersion ? projectScalaVersion : properties.defaultScalaVersion
+ ext.scalaSuffix = getScalaSuffix(ext.scalaVersion)
+
+ ext.externalDependency = [
+ 'zookeeper':'org.apache.zookeeper:zookeeper:3.3.4',
+ 'protobuf':'com.google.protobuf:protobuf-java:2.4.0a',
+ 'log4j':'log4j:log4j:1.2.17',
+ 'netty':'io.netty:netty:3.7.0.Final',
+ 'slf4jApi':'org.slf4j:slf4j-api:1.7.5',
+ 'slf4jLog4j':'org.slf4j:slf4j-log4j12:1.7.5',
+ 'specs':"org.scala-tools.testing:specs${ext.scalaSuffix}:${ext.scalaSuffix == '_2.10' ? '1.6.9' : '1.6.8'}",
+ 'mockitoAll':'org.mockito:mockito-all:1.8.4',
+ 'cglib':'cglib:cglib:2.1_3',
+ 'objenesis':'org.objenesis:objenesis:1.2',
+ 'scalaCompiler': "org.scala-lang:scala-compiler:${ext.scalaVersion}",
+ 'scalaLibrary': "org.scala-lang:scala-library:${ext.scalaVersion}",
+ 'scalaActors': "org.scala-lang:scala-actors:${ext.scalaVersion}",
+ 'junit':'junit:junit:4.8.1'
+ ];
+
}
View
3  cluster/build.gradle
@@ -6,6 +6,9 @@ dependencies {
compile externalDependency.zookeeper
compile externalDependency.protobuf
compile externalDependency.log4j
+ if (scalaVersion.startsWith('2.10')) {
+ compile externalDependency.scalaActors
+ }
testCompile externalDependency.specs
testCompile externalDependency.mockitoAll
View
5 gradle.properties
@@ -1 +1,4 @@
-version=0.6.58
+version=0.6.60
+defaultScalaVersion=2.8.1
+targetScalaVersions=2.8.1,2.10.3
+crossBuild=false
View
2  java-cluster/build.gradle
@@ -2,7 +2,7 @@ apply plugin: 'java'
apply plugin: 'scala'
dependencies {
- compile project(':cluster')
+ compile project(":cluster$scalaSuffix")
compile externalDependency.scalaLibrary
}
View
4 java-network/build.gradle
@@ -2,8 +2,8 @@ apply plugin: 'java'
apply plugin: 'scala'
dependencies {
- compile project(':network')
- compile project(':java-cluster')
+ compile project(":network$scalaSuffix")
+ compile project(":java-cluster$scalaSuffix")
compile externalDependency.scalaLibrary
}
View
5 network/build.gradle
@@ -2,11 +2,14 @@ apply plugin: 'java'
apply plugin: 'scala'
dependencies {
- compile project(':cluster')
+ compile project(":cluster$scalaSuffix")
compile externalDependency.scalaLibrary
compile externalDependency.netty
compile externalDependency.slf4jApi
compile externalDependency.slf4jLog4j
+ if (scalaVersion.startsWith('2.10')) {
+ compile externalDependency.scalaActors
+ }
testCompile externalDependency.specs
testCompile externalDependency.mockitoAll
View
8 norbert/build.gradle
@@ -7,10 +7,10 @@ configurations {
}
dependencies {
- compile project(':cluster')
- compile project(':network')
- compile project(':java-cluster')
- compile project(':java-network')
+ compile project(":cluster$scalaSuffix")
+ compile project(":network$scalaSuffix")
+ compile project(":java-cluster$scalaSuffix")
+ compile project(":java-network$scalaSuffix")
}
jar {
View
34 settings.gradle
@@ -1,6 +1,28 @@
-include "cluster"
-include "network"
-include "java-cluster"
-include "java-network"
-include "norbert"
-include "examples"
+def modules = ['cluster', 'network', 'java-cluster', 'java-network', 'norbert', 'examples']
+def modulesToCrossBuild = ['cluster', 'network', 'java-cluster', 'java-network', 'norbert']
+
+def getScalaSuffix(scalaVersion) {
+ return scalaVersion.startsWith('2.10') ? '_2.10' : '_' + scalaVersion
+}
+
+modules.each {
+ if (modulesToCrossBuild.contains(it)) {
+ if (properties.crossBuild.toBoolean()) {
+ properties.targetScalaVersions.split(',').each { v -> include it + getScalaSuffix(v) }
+ }
+ else {
+ include it + getScalaSuffix(properties.defaultScalaVersion)
+ }
+ }
+ else {
+ include it
+ }
+}
+
+// each cross-built scala modules needs to be suffixed with the scala version
+rootProject.children.each {
+ def scalaPattern = it.name =~ /(.+)_2(\.[0-9]{1,2}){1,2}/
+ if (scalaPattern.matches() && modulesToCrossBuild.contains(scalaPattern.group(1))) {
+ it.projectDir = new File(settingsDir, scalaPattern.group(1))
+ }
+}
Something went wrong with that request. Please try again.