Skip to content

Commit

Permalink
Added Scala version selection via build parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jverbus committed May 26, 2020
1 parent a3ba367 commit 5fb4333
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 20 deletions.
30 changes: 22 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
# More details on how to configure the Travis build
# https://docs.travis-ci.com/user/customizing-the-build/

dist: trusty

language: scala
scala:
- 2.11.8

jdk:
- oraclejdk8

#Skipping install step to avoid having Travis run arbitrary './gradlew assemble' task
jobs:
include:
- scala: 2.11.8
env: SPARK_VERSION=2.3.0 PERFORM_RELEASE=true # Only one build should have PERFORM_RELEASE=true.
- scala: 2.11.8
env: SPARK_VERSION=2.4.3 PERFORM_RELEASE=false
- scala: 2.12.11
env: SPARK_VERSION=2.4.3 PERFORM_RELEASE=false

# Skipping install step to avoid having Travis run arbitrary './gradlew assemble' task
# https://docs.travis-ci.com/user/customizing-the-build/#Skipping-the-Installation-Step
install:
- true

#Don't build tags
# Don't build tags
branches:
except:
- /^v\d/

#Build and perform release (if needed)
# Build and perform release (if needed).
# Currently, only one build is released using Shipkit. Once Shipkit supports releasing multiple builds under the same
# version, we will automatically publish the artifacts from all builds.
# https://github.com/mockito/shipkit/issues/858
script:
- ./gradlew build -s && ./gradlew ciPerformRelease

dist: trusty
- if [ $PERFORM_RELEASE == true ]; then
./gradlew build -s -PscalaVersion=$TRAVIS_SCALA_VERSION -PsparkVersion=$SPARK_VERSION && ./gradlew ciPerformRelease;
else
./gradlew build -s -PscalaVersion=$TRAVIS_SCALA_VERSION -PsparkVersion=$SPARK_VERSION;
fi
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ It is recommended to use Scala 2.11.8 and Spark 2.3.0. To build, run the followi
```
This will produce a jar file in the ``./isolation-forest/build/libs/`` directory.

If you want to use the library with Spark 2.4, you can specify this when running the build command.
If you want to use the library with Spark 2.4 (and the Scala 2.11.8 default), you can specify this when running the
build command.

```bash
./gradlew build -PsparkVersion=2.4.3
```

You can also build an artifact with Spark 2.4 and Scala 2.12.

```bash
./gradlew build -PsparkVersion=2.4.3 -PscalaVersion=2.12.11
```

### Add an isolation-forest dependency to your project

Please check [Bintray](https://bintray.com/beta/#/linkedin/maven/isolation-forest) for the latest
Expand Down
26 changes: 15 additions & 11 deletions isolation-forest/build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
import org.gradle.util.VersionNumber

plugins {
// Apply the scala plugin to add support for Scala
id 'scala'
}

def sparkVersion = findProperty("sparkVersion") ?: "2.3.0"
def scalaVersion = findProperty("scalaVersion") ?: "2.11.8" // Scala 2.11.8 is the default Scala build version.
println "Scala version: " + scalaVersion
// If scalaVersion == "2.11.8", then scalaVersionShort == "2.11".
def scalaVersionShort = VersionNumber.parse(scalaVersion).getMajor() + "." + VersionNumber.parse(scalaVersion).getMinor()

def sparkVersion = findProperty("sparkVersion") ?: "2.3.0" // Spark 2.3.0 is the default Spark build version.
println "Spark version: " + sparkVersion

dependencies {
compile("com.chuusai:shapeless_2.11:2.3.2")
compile("com.chuusai:shapeless_" + scalaVersionShort + ":2.3.2")
if(VersionNumber.parse(sparkVersion) >= VersionNumber.parse("2.4.0")) {
compile("org.apache.spark:spark-avro_2.11:" + sparkVersion)
} else {
compile("com.databricks:spark-avro_2.11:4.0.0")
compile("org.apache.spark:spark-avro_" + scalaVersionShort + ":" + sparkVersion)
} else {
compile("com.databricks:spark-avro_" + scalaVersionShort + ":4.0.0")
}
compile("org.apache.spark:spark-core_2.11:" + sparkVersion)
compile("org.apache.spark:spark-mllib_2.11:" + sparkVersion)
compile("org.apache.spark:spark-sql_2.11:" + sparkVersion)
compile("org.scalatest:scalatest_2.11:2.2.6")
compile("org.apache.spark:spark-core_" + scalaVersionShort + ":" + sparkVersion)
compile("org.apache.spark:spark-mllib_" + scalaVersionShort + ":" + sparkVersion)
compile("org.apache.spark:spark-sql_" + scalaVersionShort + ":" + sparkVersion)
compile("org.scala-lang:scala-library:" + scalaVersion)
compile("org.scalatest:scalatest_" + scalaVersionShort + ":3.1.0")
compile("org.testng:testng:6.8.8")
}

test {
useTestNG()
}

archivesBaseName = "${project.name}_${sparkVersion}_2.11"
archivesBaseName = "${project.name}_${sparkVersion}_${scalaVersionShort}"

0 comments on commit 5fb4333

Please sign in to comment.