diff --git a/.travis.yml b/.travis.yml index 3b031ac2a..a6b68b7ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ script: # - bash <(curl -s https://codecov.io/bash) matrix: include: - - env: SCALA_VERSION=2.12.5 NATIVE=1 PUBLISH=1 + - env: SCALA_VERSION=2.12 NATIVE=1 PUBLISH=1 os: linux jdk: oraclejdk8 sudo: required @@ -16,39 +16,39 @@ matrix: - curl https://raw.githubusercontent.com/scala-native/scala-native/master/scripts/travis_setup.sh | bash -x services: - docker - - env: SCALA_VERSION=2.11.12 PUBLISH=1 + - env: SCALA_VERSION=2.11 PUBLISH=1 os: linux jdk: oraclejdk8 sudo: required services: - docker - - env: SCALA_VERSION=2.10.7 PUBLISH=1 + - env: SCALA_VERSION=2.10 PUBLISH=1 os: linux jdk: oraclejdk8 sudo: required services: - docker - - env: SCALA_VERSION=2.12.5 SBT_COURSIER=1 + - env: SCALA_VERSION=2.12 SBT_COURSIER=1 os: linux jdk: oraclejdk8 - - env: SCALA_VERSION=2.12.5 SBT_SHADING=1 + - env: SCALA_VERSION=2.12 SBT_SHADING=1 os: linux jdk: oraclejdk8 - - env: SCALA_VERSION=2.10.7 SBT_COURSIER=1 + - env: SCALA_VERSION=2.10 SBT_COURSIER=1 os: linux jdk: oraclejdk8 services: - docker - - env: SCALA_VERSION=2.10.7 SBT_SHADING=1 + - env: SCALA_VERSION=2.10 SBT_SHADING=1 os: linux jdk: oraclejdk8 - - env: SCALA_VERSION=2.12.5 SCALA_JS=1 + - env: SCALA_VERSION=2.12 SCALA_JS=1 os: linux jdk: oraclejdk8 - - env: SCALA_VERSION=2.11.12 SCALA_JS=1 + - env: SCALA_VERSION=2.11 SCALA_JS=1 os: linux jdk: oraclejdk8 - - env: SCALA_VERSION=2.10.7 SCALA_JS=1 + - env: SCALA_VERSION=2.10 SCALA_JS=1 os: linux jdk: oraclejdk8 - os: linux diff --git a/appveyor.yml b/appveyor.yml index 2d07c224d..18f8990d4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,18 +16,18 @@ install: - cmd: SET SBT_OPTS=-Xmx4g -Xss2m - git submodule update --init --recursive build_script: - - sbt ++2.11.12 clean compile coreJVM/publishLocal - - sbt ++2.10.7 clean compile - - sbt ++2.12.5 coreJVM/publishLocal cacheJVM/publishLocal extra/publishLocal scalazJVM/publishLocal cli/publishLocal + - sbt scala212 coreJVM/publishLocal cacheJVM/publishLocal extra/publishLocal scalazJVM/publishLocal cli/publishLocal + - sbt scala211 compile coreJVM/publishLocal + - sbt scala210 compile test_script: - ps: Start-Job -filepath .\scripts\start-it-auth-server.ps1 -ArgumentList $pwd - ps: Start-Sleep -s 15 # wait for the first server to have downloaded its dependencies - ps: Start-Job -filepath .\scripts\start-it-no-listing-server.ps1 -ArgumentList $pwd - - sbt ++2.12.5 testsJVM/test testsJVM/it:test # Would node be around for testsJS/test? - - sbt ++2.11.12 testsJVM/test testsJVM/it:test - - sbt ++2.10.7 testsJVM/test testsJVM/it:test - - sbt ++2.12.5 "sbt-coursier/scripted sbt-coursier/simple" "sbt-shading/scripted sbt-shading/*" # for sbt 1.0 - - sbt ++2.10.7 "sbt-coursier/scripted sbt-coursier/*" "sbt-coursier/scripted sbt-coursier-0.13/*" "sbt-shading/scripted sbt-shading/*" "sbt-shading/scripted sbt-shading-0.13/*" # for sbt 0.13 + - sbt scala212 testsJVM/test testsJVM/it:test # Would node be around for testsJS/test? + - sbt scala211 testsJVM/test testsJVM/it:test + - sbt scala210 testsJVM/test testsJVM/it:test + - sbt scala212 "sbt-coursier/scripted sbt-coursier/simple" "sbt-shading/scripted sbt-shading/*" # for sbt 1.0 + - sbt scala210 "sbt-coursier/scripted sbt-coursier/*" "sbt-coursier/scripted sbt-coursier-0.13/*" "sbt-shading/scripted sbt-shading/*" "sbt-shading/scripted sbt-shading-0.13/*" # for sbt 0.13 branches: only: - master diff --git a/project/Release.scala b/project/Release.scala index fe847ea7c..c401ae90a 100644 --- a/project/Release.scala +++ b/project/Release.scala @@ -397,7 +397,7 @@ object Release { updateScripts, updateLaunchers, updateTutReadme, - releaseStepCommand(s"++${Settings.scala211}"), + releaseStepCommand(s"++${ScalaVersion.scala211}"), releaseStepCommand("tut"), stageReadme, updatePluginsSbt, diff --git a/project/ScalaVersion.scala b/project/ScalaVersion.scala new file mode 100644 index 000000000..2fa14e7bd --- /dev/null +++ b/project/ScalaVersion.scala @@ -0,0 +1,16 @@ + +object ScalaVersion { + + def scala212 = "2.12.5" + def scala211 = "2.11.12" + def scala210 = "2.10.7" + + val versions = Seq(scala212, scala211, scala210) + + val map = versions + .map { v => + v.split('.').take(2).mkString(".") -> v + } + .toMap + +} diff --git a/project/ScalaVersionPlugin.scala b/project/ScalaVersionPlugin.scala new file mode 100644 index 000000000..18f466c84 --- /dev/null +++ b/project/ScalaVersionPlugin.scala @@ -0,0 +1,44 @@ + +import sbt.complete.Parser +import sbt.Keys.commands +import sbt.{AutoPlugin, Command} + +object ScalaVersionPlugin extends AutoPlugin { + + override def trigger = allRequirements + + override def buildSettings = Seq( + commands ++= ScalaVersion.map.toSeq.map { + case (sbv, sv) => + Command(s"scala${sbv.filter(_ != '.')}")(_ => Parser.success(())) { (st, _) => + val cmd0 = s"++$sv!" + Parser.parse(cmd0, st.combinedParser) match { + case Right(cmd) => cmd() + case Left(msg) => throw sys.error(s"Invalid command: $cmd0\n$msg") + } + } + }, + commands += Command("scalaFromEnv")(_ => Parser.success(())) { (st, _) => + val sv = sys.env.get("SCALA_VERSION") match { + case None => + throw new Exception("SCALA_VERSION not set") + case Some(s) if s.count(_ == '.') == 1 => + ScalaVersion.map.getOrElse( + s, + throw new Exception( + s"No scala version found for binary version $s" + + s" (available scala versions: ${ScalaVersion.versions.mkString(", ")})" + ) + ) + case Some(s) => + s + } + val cmd0 = s"++$sv!" + Parser.parse(cmd0, st.combinedParser) match { + case Right(cmd) => cmd() + case Left(msg) => throw sys.error(s"Invalid command: $cmd0\n$msg") + } + } + ) + +} diff --git a/project/Settings.scala b/project/Settings.scala index 435f46f50..f30ea1ee9 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -10,11 +10,9 @@ import com.typesafe.sbt.pgp._ import coursier.ShadingPlugin.autoImport._ import Aliases._ +import ScalaVersion._ object Settings { - val scala212 = "2.12.5" - val scala211 = "2.11.12" - val scala210 = "2.10.7" lazy val scalazBintrayRepository = { resolvers += "Scalaz Bintray Repo" at "https://dl.bintray.com/scalaz/releases" diff --git a/scripts/travis.sh b/scripts/travis.sh index 357da18d9..107a8e2e7 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -1,28 +1,6 @@ #!/usr/bin/env bash set -evx -SCALA_VERSION="${SCALA_VERSION:-${TRAVIS_SCALA_VERSION:-2.12.5}}" -PULL_REQUEST="${PULL_REQUEST:-${TRAVIS_PULL_REQUEST:-false}}" -BRANCH="${BRANCH:-${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}}" -PUBLISH="${PUBLISH:-0}" -SCALA_JS="${SCALA_JS:-0}" - -VERSION="$(grep -oP '(?<=")[^"]*(?!<")' < version.sbt)" - -JARJAR_VERSION="${JARJAR_VERSION:-1.0.1-coursier-SNAPSHOT}" - -is210() { - echo "$SCALA_VERSION" | grep -q "^2\.10" -} - -is211() { - echo "$SCALA_VERSION" | grep -q "^2\.11" -} - -is212() { - echo "$SCALA_VERSION" | grep -q "^2\.12" -} - setupCoursierBinDir() { mkdir -p bin cp coursier bin/ @@ -41,7 +19,7 @@ launchTestRepo() { integrationTestsRequirements() { # Required for ~/.ivy2/local repo tests - sbt ++2.11.12 coreJVM/publishLocal ++2.12.5 cli/publishLocal + sbt scala211 coreJVM/publishLocal scala212 cli/publishLocal # Required for HTTP authentication tests launchTestRepo --port 8080 --list-pages @@ -65,30 +43,30 @@ sbtShading() { runSbtCoursierTests() { addPgpKeys if [ "$SCALA_VERSION" = "2.10" ]; then - sbt ++$SCALA_VERSION "sbt-coursier/scripted sbt-coursier/*" "sbt-coursier/scripted sbt-coursier-0.13/*" + sbt scalaFromEnv "sbt-coursier/scripted sbt-coursier/*" "sbt-coursier/scripted sbt-coursier-0.13/*" else - sbt ++$SCALA_VERSION "sbt-coursier/scripted sbt-coursier/simple" # full scripted suite currently taking too long on Travis CI... + sbt scalaFromEnv "sbt-coursier/scripted sbt-coursier/simple" # full scripted suite currently taking too long on Travis CI... fi - sbt ++$SCALA_VERSION sbt-pgp-coursier/scripted + sbt scalaFromEnv sbt-pgp-coursier/scripted } runSbtShadingTests() { - sbt ++$SCALA_VERSION "sbt-shading/scripted sbt-shading/*" + sbt scalaFromEnv "sbt-shading/scripted sbt-shading/*" if [ "$SCALA_VERSION" = "2.10" ]; then - sbt ++$SCALA_VERSION "sbt-shading/scripted sbt-shading-0.13/*" + sbt scalaFromEnv "sbt-shading/scripted sbt-shading-0.13/*" fi } jsCompile() { - sbt ++$SCALA_VERSION js/compile js/test:compile coreJS/fastOptJS cacheJS/fastOptJS testsJS/test:fastOptJS js/test:fastOptJS + sbt scalaFromEnv js/compile js/test:compile coreJS/fastOptJS cacheJS/fastOptJS testsJS/test:fastOptJS js/test:fastOptJS } jvmCompile() { - sbt ++$SCALA_VERSION jvm/compile jvm/test:compile + sbt scalaFromEnv jvm/compile jvm/test:compile } runJsTests() { - sbt ++$SCALA_VERSION js/test + sbt scalaFromEnv js/test } runJvmTests() { @@ -98,7 +76,7 @@ runJvmTests() { IT="jvm/it:test" fi - sbt ++$SCALA_VERSION jvm/test $IT + sbt scalaFromEnv jvm/test $IT } validateReadme() { @@ -106,14 +84,13 @@ validateReadme() { mv README.md README.md.orig - if is212; then - TUT_SCALA_VERSION="2.12.1" # Later versions seem to make tut not see the coursier binaries + if [ "$SCALA_VERSION" = 2.12 ]; then + # Later 2.12 versions seem to make tut not see the coursier binaries + sbt '++2.12.1!' tut else - TUT_SCALA_VERSION="$SCALA_VERSION" + sbt scalaFromEnv tut fi - sbt ++${TUT_SCALA_VERSION} tut - if cmp -s README.md.orig README.md; then echo "README.md doesn't change" else @@ -124,16 +101,16 @@ validateReadme() { } checkBinaryCompatibility() { - sbt ++${SCALA_VERSION} coreJVM/mimaReportBinaryIssues cacheJVM/mimaReportBinaryIssues + sbt scalaFromEnv coreJVM/mimaReportBinaryIssues cacheJVM/mimaReportBinaryIssues } publish() { - sbt ++${SCALA_VERSION} publish + sbt scalaFromEnv publish } testBootstrap() { - if is212; then - sbt ++${SCALA_VERSION} "project cli" pack + if [ "$SCALA_VERSION" = 2.12 ]; then + sbt scalaFromEnv "project cli" pack cli/target/pack/bin/coursier bootstrap -o cs-echo io.get-coursier:echo:1.0.0 if [ "$(./cs-echo foo)" != foo ]; then echo "Error: unexpected output from bootstrapped echo command." 1>&2 @@ -143,8 +120,8 @@ testBootstrap() { } testNativeBootstrap() { - if is212 && [ "$NATIVE" = "1" ]; then - sbt ++${SCALA_VERSION} "project cli" pack + if [ "$SCALA_VERSION" = "2.12" -a "$NATIVE" = "1" ]; then + sbt scalaFromEnv "project cli" pack cli/target/pack/bin/coursier bootstrap -S -o native-echo io.get-coursier:echo_native0.3_2.11:1.0.1 if [ "$(./native-echo -n foo a)" != "foo a" ]; then echo "Error: unexpected output from native test bootstrap." 1>&2 @@ -175,11 +152,11 @@ else jvmCompile if sbtCoursier; then - if is210 || is212; then + if [ "$SCALA_VERSION" = "2.10" -o "$SCALA_VERSION" = "2.12" ]; then runSbtCoursierTests fi elif sbtShading; then - if is210 || is212; then + if [ "$SCALA_VERSION" = "2.10" -o "$SCALA_VERSION" = "2.12" ]; then runSbtShadingTests fi else @@ -193,10 +170,14 @@ else fi +PULL_REQUEST="${PULL_REQUEST:-${TRAVIS_PULL_REQUEST:-false}}" +BRANCH="${BRANCH:-${TRAVIS_BRANCH:-$(git rev-parse --abbrev-ref HEAD)}}" +PUBLISH="${PUBLISH:-0}" + if [ "$PUBLISH" = 1 -a "$PULL_REQUEST" = false -a "$BRANCH" = master ]; then publish - if is211 && isScalaJs; then + if [ "$SCALA_VERSION" = "2.11" ] && isScalaJs; then #"$(dirname "$0")/push-gh-pages.sh" "$SCALA_VERSION" : fi