diff --git a/admin/README.md b/admin/README.md index d84727a..46626b4 100644 --- a/admin/README.md +++ b/admin/README.md @@ -1,7 +1,5 @@ ## Tag Driven Releasing -Copied from https://github.com/scala/scala-java8-compat/commit/4a6cfc97cd95227b86650410e1b632e5ff79335b. - ### Background Reading - http://docs.travis-ci.com/user/environment-variables/ @@ -14,47 +12,61 @@ To configure tag driven releases from Travis CI. 1. Generate a key pair for this repository with `./admin/genKeyPair.sh`. Edit `.travis.yml` and `admin/build.sh` as prompted. - 2. Publish the public key to https://pgp.mit.edu - 3. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`. + 1. Publish the public key to https://pgp.mit.edu + 1. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`. Edit `.travis.yml` as prompted. - 4. Edit `.travis.yml` to use `./admin/build.sh` as the build script, + 1. Edit `.travis.yml` to use `./admin/build.sh` as the build script, and edit that script to use the tasks required for this project. - 5. Edit `build.sbt` to select which JDK will be used for publishing - for which Scala versions. + 1. Edit `build.sbt`'s `scalaVersionsByJvm in ThisBuild` to select Scala and JVM version + combinations that will be used for publishing. -It is important to add comments in .travis.yml to identify the name +It is important to add comments in `.travis.yml` to identify the name of each environment variable encoded in a `:secure` section. -After all of these steps, your .travis.yml should contain config of the -form: +After these steps, your `.travis.yml` should contain config of the form: + +``` +language: scala + +env: + global: + # PGP_PASSPHRASE + - secure: "XXXXXX" + # SONA_USER + - secure: "XXXXXX" + # SONA_PASS + - secure: "XXXXXX" - language: scala - env: - global: - # PGP_PASSPHRASE - - secure: "XXXXXX" - # SONA_USER - - secure: "XXXXXX" - # SONA_PASS - - secure: "XXXXXX" - script: admin/build.sh +script: admin/build.sh + +jdk: + - openjdk6 + - oraclejdk8 + +notifications: + email: + - a@b.com +``` If Sonatype credentials change in the future, step 3 can be repeated without generating a new key. -Be sure to use SBT 0.13.7 or higher to avoid [#1430](https://github.com/sbt/sbt/issues/1430)! - ### Testing - 1. Follow the release process below to create a dummy release (e.g. 0.1.0-TEST1). + 1. Follow the release process below to create a dummy release (e.g., `v0.1.0-TEST1`). Confirm that the release was staged to Sonatype but do not release it to Maven central. Instead, drop the staging repository. ### Performing a release - 1. Create a GitHub "Release" (with a corresponding tag) via the GitHub + 1. Create a GitHub "Release" with a corresponding tag (e.g., `v0.1.1`) via the GitHub web interface. - 2. Travis CI will schedule a build for this release. Review the build logs. - 3. Log into https://oss.sonatype.org/ and identify the staging repository. - 4. Sanity check its contents - 5. Release staging repository to Maven and send out release announcement. + 1. The release will be published using the Scala and JVM version combinations specified + in `scalaVersionsByJvm` in `build.sbt`. + - If you need to release against a different Scala version, include the Scala version + and the JVM version to use in the tag name, separated by `#`s (e.g., `v0.1.1#2.13.0-M1#8`). + Note that the JVM version needs to be listed in `.travis.yml` for the build to run. + 1. Travis CI will schedule a build for this release. Review the build logs. + 1. Log into https://oss.sonatype.org/ and identify the staging repository. + 1. Sanity check its contents. + 1. Release staging repository to Maven and send out release announcement. diff --git a/admin/build.sh b/admin/build.sh index a46d514..bfb8625 100755 --- a/admin/build.sh +++ b/admin/build.sh @@ -2,15 +2,43 @@ set -e -# prep environment for publish to sonatype staging if the HEAD commit is tagged +# Builds of tagged revisions are published to sonatype staging. -# git on travis does not fetch tags, but we have TRAVIS_TAG -# headTag=$(git describe --exact-match ||:) +# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice. +# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds. +# Checking the local git clone would not work because git on travis does not fetch tags. + +# The version number to be published is extracted from the tag, e.g., v1.2.3 publishes +# version 1.2.3 using all Scala versions in build.sbt's `crossScalaVersions`. + +# When a new, binary incompatible Scala version becomes available, a previously released version +# can be released using that new Scala version by creating a new tag containing the Scala and the +# JVM version after hashes, e.g., v1.2.3#2.13.0-M1#8. The JVM version needs to be listed in +# `.travis.yml`, otherwise the required build doesn't run. + +verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?" +tagPat="^v$verPat(#$verPat#[0-9]+)?$" + +if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then + currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//') + + tagVer=$(echo $TRAVIS_TAG | sed s/#.*// | sed s/^v//) + publishVersion='set every version := "'$tagVer'"' + + scalaAndJvmVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//) + if [ "$scalaAndJvmVer" != "" ]; then + scalaVer=$(echo $scalaAndJvmVer | sed s/#.*//) + jvmVer=$(echo $scalaAndJvmVer | sed s/[^#]*// | sed s/^#//) + if [ "$jvmVer" != "$currentJvmVer" ]; then + echo "Not publishing $TRAVIS_TAG on Java version $currentJvmVer." + exit 0 + fi + publishScalaVersion='set every ScalaModulePlugin.scalaVersionsByJvm := Map('$jvmVer' -> List("'$scalaVer'" -> true))' + echo "Releasing $tagVer using Scala $scalaVer on Java version $jvmVer." + else + echo "Releasing $tagVer on Java version $currentJvmVer according to 'scalaVersionsByJvm' in build.sbt." + fi -if [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then - echo "Going to release from tag $TRAVIS_TAG!" - myVer=$(echo $TRAVIS_TAG | sed -e s/^v//) - publishVersion='set every version := "'$myVer'"' extraTarget="+publish-signed" cat admin/gpg.sbt >> project/plugins.sbt cp admin/publish-settings.sbt . @@ -22,4 +50,4 @@ if [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d fi -sbt "$publishVersion" clean update +test +publishLocal $extraTarget +sbt "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget diff --git a/admin/publish-manual-settings.sbt b/admin/publish-manual-settings.sbt deleted file mode 100644 index 1de7268..0000000 --- a/admin/publish-manual-settings.sbt +++ /dev/null @@ -1,3 +0,0 @@ -// additinoal settings when publishing a release using admin/releaseManual.sh, outside travis - -credentials += Credentials(Path.userHome / ".ivy2" / ".credentials") diff --git a/admin/releaseManual.sh b/admin/releaseManual.sh deleted file mode 100755 index e99540b..0000000 --- a/admin/releaseManual.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash - -set -e - -adminDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -cd "$adminDir/.." -repositoryName=$(basename `pwd`) - -if [[ ! -f ~/.ivy2/.credentials ]]; then - echo "In order to publish to sonatype, you need a credentials file ~/.ivy2/.credentials with the following content:" - cat < -password= -EOF - exit 1 -fi - -function checkValidVersion() { - if [[ "$1" == "" ]]; then - echo "⚠️ Empty input, aborting." - exit 0 - elif [[ ! "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then - echo "❌ Invalid version: $1. Aborting" - exit 1 - fi -} - -function confirmContinue() { - local continueConfirmation="n" - read -p "Continue (y/n)? " continueConfirmation - if [[ "$continueConfirmation" != "y" ]]; then - echo "⚠️ Aborting." - exit 0 - fi -} - -if [[ -n $(git status -s) ]]; then - echo "⚠️ There are uncommited changes, make sure this is what you want." - git status - confirmContinue -fi - -headTag=$(git describe --tags --exact-match 2> /dev/null || :) -if [[ "$headTag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then - releaseVersion=$(echo $headTag | sed -e s/^v//) - echo "💡 The current HEAD is at tag $headTag. The release version is set to $releaseVersion." -else - echo "⚠️ The current HEAD does not correspond to a tag." - read -p "Enter a version number to build a release from the current HEAD (leave empty to abort): " releaseVersion - checkValidVersion $releaseVersion -fi - -setVersion='set every version := "'$releaseVersion'"' - -echo "💡 Please specify the Scala version for building the release." -read -p "Enter '+' to cross-build against all versions in build.sbt's 'crossScalaVersions': " scalaVersionInput - -if [[ "$scalaVersionInput" == "+" ]]; then - testTarget="+test" - publishTarget="+publish-signed" -else - checkValidVersion $scalaVersionInput - testTarget="test" - publishTarget="publish-signed" - setScalaVersion='set every scalaVersion := "'$scalaVersionInput'"' -fi - -# ignore non-matching lines according to http://stackoverflow.com/questions/1665549/have-sed-ignore-non-matching-lines#comment19412026_1665662 -javaVersion=`java -version 2>&1 | sed -e 's/java version "\(.*\)"/\1/' -e 'tx' -e 'd' -e ':x'` - -if [[ "$scalaVersionInput" == "+" ]]; then - scalaVersionInfo=" using the Scala versions in build.sbt's 'crossScalaVersions'" -else - echo "💡 The current Java version is $javaVersion. Make sure to use 1.6 for Scala <2.12, 1.8 for Scala >=2.12." - scalaVersionInfo=" using Scala $scalaVersionInput" -fi - -echo "⚠️ About to release $repositoryName version $releaseVersion$scalaVersionInfo on Java $javaVersion." -confirmContinue - -cp admin/gpg.sbt ./project -cp admin/publish-manual-settings.sbt . - -echo "Running: sbt \"$setScalaVersion\" \"$setVersion\" clean update $testTarget $publishTarget" -sbt "$setScalaVersion" "$setVersion" clean update $testTarget $publishTarget - -rm ./project/gpg.sbt -rm ./publish-manual-settings.sbt diff --git a/build.sbt b/build.sbt index e0db6f4..580cb55 100644 --- a/build.sbt +++ b/build.sbt @@ -1,37 +1,35 @@ +import ScalaModulePlugin._ import VersionKeys._ scalaModuleSettings -name := "scala-partest" +name := "scala-partest" +version := "1.1.2-SNAPSHOT" -version := "1.1.2-SNAPSHOT" +scalaVersionsByJvm in ThisBuild := { + val vs = List("2.12.2", "2.13.0-M1") -scalaVersion := crossScalaVersions.value.head + Map( + 8 -> vs.map(_ -> true), + 9 -> vs.map(_ -> false)) +} -crossScalaVersions := Seq("2.12.1") +scalaXmlVersion := "1.0.6" -scalaXmlVersion := "1.0.6" - -// TODO: eliminate "-deprecation:false" for nightlies, -// included by default because we don't want to break scala/scala pr validation -scalacOptions ++= - Seq("-feature", "-deprecation:false", "-unchecked", "-Xlint", "-Xfatal-warnings") +scalacOptions += "-Xfatal-warnings" +enableOptimizer // dependencies // versions involved in integration builds / that change frequently should be keys, set above! libraryDependencies += "org.apache.ant" % "ant" % "1.8.4" % "provided" - libraryDependencies += "com.googlecode.java-diff-utils" % "diffutils" % "1.3.0" - libraryDependencies += "org.scala-sbt" % "test-interface" % "1.0" - // mark all scala dependencies as provided which means one has to explicitly provide them when depending on partest // this allows for easy testing of modules (like scala-xml) that provide tested classes themselves and shouldn't // pull in an older version of itself libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % scalaXmlVersion.value % "provided" intransitive() - libraryDependencies += "org.scala-lang" % "scalap" % scalaVersion.value % "provided" intransitive() - libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided" intransitive() - libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided" intransitive() + +OsgiKeys.exportPackage := Seq(s"scala.tools.partest.*;version=${version.value}") diff --git a/project/keys.scala b/project/keys.scala index 9c3de57..df76edc 100644 --- a/project/keys.scala +++ b/project/keys.scala @@ -1,6 +1,6 @@ object VersionKeys { import sbt.settingKey - // To facilitate scripted build of all modules (while we're working on getting dbuild up and running) + // To facilitate scripted build of all modules, used in scala/scala's bootstrap script val scalaXmlVersion = settingKey[String]("Version to use for the scala-xml dependency.") } diff --git a/project/plugins.sbt b/project/plugins.sbt index 65dea32..293445d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.4") +addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.8") diff --git a/src/main/scala/scala/tools/partest/package.scala b/src/main/scala/scala/tools/partest/package.scala index 5fe7774..7aa60be 100644 --- a/src/main/scala/scala/tools/partest/package.scala +++ b/src/main/scala/scala/tools/partest/package.scala @@ -177,7 +177,7 @@ package object partest { ) def allPropertiesString = { - import scala.collection.JavaConversions._ - System.getProperties.toList.sorted map { case (k, v) => "%s -> %s\n".format(k, v) } mkString "" + import scala.collection.JavaConverters._ + System.getProperties.asScala.toList.sorted map { case (k, v) => "%s -> %s\n".format(k, v) } mkString "" } }