From e2b6c7b608b82fca5343f6d09236c2b48b5d824d Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Fri, 22 Jul 2016 18:19:45 +0200 Subject: Switch remaining uses of ant over to sbt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modify `tools/scaladoc-diff` to use sbt instead of ant. - Move `stability-test.sh` from `tools` to `scripts`. With the new build process without separate `locker` and `strap` stages, it doesn’t make sense to call this script without first setting up the proper test environment in a CI build. - Replace the use of `build.number` in `bootstrap` with a new `SHA-NIGHTLY` mode for `baseVersionSuffix`. - Make `partest` call sbt instead of ant for initializing the classpath and use the new classpath location (`quick` instead of `pack`). --- build.sbt | 10 ++++----- project/VersionUtil.scala | 45 +++++++++++++++++++++++----------------- scripts/jobs/integrate/bootstrap | 9 ++++---- scripts/stability-test.sh | 29 ++++++++++++++++++++++++++ test/partest | 12 +++++------ tools/scaladoc-diff | 4 ++-- tools/stability-test.sh | 29 -------------------------- 7 files changed, 72 insertions(+), 66 deletions(-) create mode 100644 scripts/stability-test.sh delete mode 100755 tools/stability-test.sh diff --git a/build.sbt b/build.sbt index d9a9f43db2..3ceff35b45 100644 --- a/build.sbt +++ b/build.sbt @@ -102,12 +102,10 @@ lazy val publishSettings : Seq[Setting[_]] = Seq( publishMavenStyle := true ) -// Set the version number: The ANT build uses the file "build.number" to get the base version. Overriding versions or -// suffixes for certain builds is done by directly setting variables from the shell scripts. For example, in -// publish-core this requires computing the commit SHA first and then passing it to ANT. In the sbt build we use -// the two settings `baseVersion` and `baseVersionSuffix` to compute all versions (canonical, Maven, OSGi). See -// VersionUtil.versionPropertiesImpl for details. The standard sbt `version` setting should not be set directly. It -// is the same as the Maven version and derived automatically from `baseVersion` and `baseVersionSuffix`. +// Set the version number: We use the two settings `baseVersion` and `baseVersionSuffix` to compute all versions +// (canonical, Maven, OSGi). See VersionUtil.versionPropertiesImpl for details. The standard sbt `version` setting +// should not be set directly. It is the same as the Maven version and derived automatically from `baseVersion` and +// `baseVersionSuffix`. globalVersionSettings baseVersion in Global := "2.12.0" baseVersionSuffix in Global := "SNAPSHOT" diff --git a/project/VersionUtil.scala b/project/VersionUtil.scala index 6fe2b004f7..1c2fff27b7 100644 --- a/project/VersionUtil.scala +++ b/project/VersionUtil.scala @@ -27,12 +27,13 @@ object VersionUtil { generateBuildCharacterPropertiesFile := generateBuildCharacterPropertiesFileImpl.value ) - case class Versions(canonicalVersion: String, mavenVersion: String, osgiVersion: String, commitSha: String, commitDate: String, isRelease: Boolean) { + case class Versions(canonicalVersion: String, mavenBase: String, mavenSuffix: String, osgiVersion: String, commitSha: String, commitDate: String, isRelease: Boolean) { val githubTree = if(isRelease) "v" + mavenVersion else if(commitSha != "unknown") commitSha else "master" + def mavenVersion: String = mavenBase + mavenSuffix override def toString = s"Canonical: $canonicalVersion, Maven: $mavenVersion, OSGi: $osgiVersion, github: $githubTree" def toMap: Map[String, String] = Map( @@ -45,17 +46,18 @@ object VersionUtil { /** Compute the canonical, Maven and OSGi version number from `baseVersion` and `baseVersionSuffix`. * Examples of the generated versions: * - * ("2.11.8", "SNAPSHOT" ) -> ("2.11.8-20151215-133023-7559aed3c5", "2.11.8-SNAPSHOT", "2.11.8.v20151215-133023-7559aed3c5") - * ("2.11.8", "SHA-SNAPSHOT") -> ("2.11.8-20151215-133023-7559aed3c5", "2.11.8-7559aed3c5-SNAPSHOT", "2.11.8.v20151215-133023-7559aed3c5") - * ("2.11.8", "" ) -> ("2.11.8", "2.11.8", "2.11.8.v20151215-133023-VFINAL-7559aed3c5") - * ("2.11.8", "M3" ) -> ("2.11.8-M3", "2.11.8-M3", "2.11.8.v20151215-133023-M3-7559aed3c5") - * ("2.11.8", "RC4" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed3c5") - * ("2.11.8-RC4", "SPLIT" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed3c5") + * ("2.11.8", "SNAPSHOT" ) -> ("2.11.8-20151215-133023-7559aed", "2.11.8-SNAPSHOT", "2.11.8.v20151215-133023-7559aed") + * ("2.11.8", "SHA-SNAPSHOT") -> ("2.11.8-20151215-133023-7559aed", "2.11.8-7559aed-SNAPSHOT", "2.11.8.v20151215-133023-7559aed") + * ("2.11.8", "SHA-NIGHTLY" ) -> ("2.11.8-7559aed-nightly", "2.11.8-7559aed-nightly", "2.11.8.v20151215-133023-NIGHTLY-7559aed") + * ("2.11.8", "" ) -> ("2.11.8", "2.11.8", "2.11.8.v20151215-133023-VFINAL-7559aed") + * ("2.11.8", "M3" ) -> ("2.11.8-M3", "2.11.8-M3", "2.11.8.v20151215-133023-M3-7559aed") + * ("2.11.8", "RC4" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed") + * ("2.11.8-RC4", "SPLIT" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed") * * A `baseVersionSuffix` of "SNAPSHOT" is the default, which is used for local snapshot builds. The PR validation - * job uses "SHA-SNAPSHOT". An empty suffix is used for releases. All other suffix values are treated as RC / - * milestone builds. The special suffix value "SPLIT" is used to split the real suffix off from `baseVersion` - * instead and then apply the usual logic. */ + * job uses "SHA-SNAPSHOT". A proper version number for a nightly build can be computed with "SHA-nightly". An empty + * suffix is used for releases. All other suffix values are treated as RC / milestone builds. The special suffix + * value "SPLIT" is used to split the real suffix off from `baseVersion` instead and then apply the usual logic. */ private lazy val versionPropertiesImpl: Def.Initialize[Versions] = Def.setting { val (base, suffix) = { @@ -76,16 +78,17 @@ object VersionUtil { } val date = executeTool("get-scala-commit-date") - val sha = executeTool("get-scala-commit-sha").substring(0, 7) // The script produces 10 digits at the moment - - val (canonicalV, mavenV, osgiV, release) = suffix match { - case "SNAPSHOT" => (s"$base-$date-$sha", s"$base-SNAPSHOT", s"$base.v$date-$sha", false) - case "SHA-SNAPSHOT" => (s"$base-$date-$sha", s"$base-$sha-SNAPSHOT", s"$base.v$date-$sha", false) - case "" => (s"$base", s"$base", s"$base.v$date-VFINAL-$sha", true) - case suffix => (s"$base-$suffix", s"$base-$suffix", s"$base.v$date-$suffix-$sha", true) + val sha = executeTool("get-scala-commit-sha").substring(0, 7) + + val (canonicalV, mavenSuffix, osgiV, release) = suffix match { + case "SNAPSHOT" => (s"$base-$date-$sha", s"-SNAPSHOT", s"$base.v$date-$sha", false) + case "SHA-SNAPSHOT" => (s"$base-$date-$sha", s"-$sha-SNAPSHOT", s"$base.v$date-$sha", false) + case "SHA-NIGHTLY" => (s"$base-$sha-nightly", s"-$sha-nightly", s"$base.v$date-NIGHTLY-$sha", true) + case "" => (s"$base", "", s"$base.v$date-VFINAL-$sha", true) + case suffix => (s"$base-$suffix", s"-$suffix", s"$base.v$date-$suffix-$sha", true) } - Versions(canonicalV, mavenV, osgiV, sha, date, release) + Versions(canonicalV, base, mavenSuffix, osgiV, sha, date, release) } private lazy val generateVersionPropertiesFileImpl: Def.Initialize[Task[File]] = Def.task { @@ -94,7 +97,11 @@ object VersionUtil { } private lazy val generateBuildCharacterPropertiesFileImpl: Def.Initialize[Task[File]] = Def.task { - writeProps(versionProperties.value.toMap ++ versionProps, (baseDirectory in ThisBuild).value / "buildcharacter.properties") + val v = versionProperties.value + writeProps(v.toMap ++ versionProps ++ Map( + "maven.version.base" -> v.mavenBase, + "maven.version.suffix" -> v.mavenSuffix + ), (baseDirectory in ThisBuild).value / "buildcharacter.properties") } private def writeProps(m: Map[String, String], propFile: File): File = { diff --git a/scripts/jobs/integrate/bootstrap b/scripts/jobs/integrate/bootstrap index 86ba67bd8b..bd509061b7 100644 --- a/scripts/jobs/integrate/bootstrap +++ b/scripts/jobs/integrate/bootstrap @@ -327,9 +327,10 @@ determineScalaVersion() { if [ -z "$scalaTag" ] then echo "No tag found, building nightly snapshot." - parseScalaProperties "build.number" - SCALA_VER_BASE="$version_major.$version_minor.$version_patch" - SCALA_VER_SUFFIX="-$(git rev-parse --short HEAD)-nightly" + $SBT_CMD $sbtArgs 'set baseVersionSuffix in Global := "SHA-NIGHTLY"' generateBuildCharacterPropertiesFile + parseScalaProperties "buildcharacter.properties" + SCALA_VER_BASE="$maven_version_base" + SCALA_VER_SUFFIX="$maven_version_suffix" SCALADOC_SOURCE_LINKS_VER=$(git rev-parse HEAD) # TODO: publish nightly snapshot using this script - currently it's a separate jenkins job still running at EPFL. @@ -540,7 +541,7 @@ bootstrap() { dist/mkQuick mv build/quick build/strap mv quick1 build/quick - tools/stability-test.sh + $scriptsDir/stability-test.sh # TODO: create PR with following commit (note that release will have been tagged already) # git commit versions.properties -m"Bump versions.properties for $SCALA_VER." diff --git a/scripts/stability-test.sh b/scripts/stability-test.sh new file mode 100644 index 0000000000..f017ac0842 --- /dev/null +++ b/scripts/stability-test.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# + +declare failed + +echo "Comparing build/quick/classes and build/strap/classes" +for dir in library reflect compiler; do + # feel free to replace by a more elegant approach -- don't know how + if diff -rw -x '*.css' \ + -x '*.custom' \ + -x '*.gif' \ + -x '*.js' \ + -x '*.layout' \ + -x '*.png' \ + -x '*.properties' \ + -x '*.tmpl' \ + -x '*.tooltip' \ + -x '*.txt' \ + -x '*.xml' \ + build/{quick,strap}/classes/$dir + then + classes=$(find build/quick/classes/$dir -name '*.class' | wc -l) + printf "%8s: %5d classfiles verified identical\n" $dir $classes + else + failed=true + fi +done + +[[ -z $failed ]] || exit 127 diff --git a/test/partest b/test/partest index 07a5de12af..d74176aa8a 100755 --- a/test/partest +++ b/test/partest @@ -28,7 +28,7 @@ findScalaHome () { # that runs this script. I don't know why. it may have to do with # which bash flags are set (-e? -x?) and with bash flags propagating # from one script to another? not sure. anyway, normally in a CI -# context we run partest through ant, not through this script, so I'm +# context we run partest through sbt, not through this script, so I'm # not investigating further for now.) term_colors=$(tput colors 2>/dev/null) if [[ $? == 0 ]] && [[ $term_colors -gt 2 ]]; then @@ -54,14 +54,14 @@ if $cygwin; then SCALA_HOME=`cygpath --unix "$SCALA_HOME"` fi -# Let ant construct the classpath used to run partest (downloading partest from maven if necessary) +# Let sbt construct the classpath used to run partest (downloading partest from maven if necessary) # PARTEST_CLASSPATH="" if [ -z "$PARTEST_CLASSPATH" ] ; then - if [ ! -f "$SCALA_HOME/build/pack/partest.properties" ] ; then - (cd "$SCALA_HOME" && ant -q test.suite.init) # builds pack, downloads partest and writes classpath to build/pack/partest.properties + if [ ! -f "$SCALA_HOME/build/quick/partest.properties" ] ; then + (cd "$SCALA_HOME" && sbt dist/mkQuick) # builds quick, downloads partest and writes classpath to build/quick/partest.properties fi - PARTEST_CLASSPATH=$( cat "$SCALA_HOME/build/pack/partest.properties" | grep partest.classpath | sed -e 's/\\:/:/g' | cut -f2- -d= ) + PARTEST_CLASSPATH=$( cat "$SCALA_HOME/build/quick/partest.properties" | grep partest.classpath | sed -e 's/\\:/:/g' | cut -f2- -d= ) # sanity check, disabled to save time # $( javap -classpath $PARTEST_CLASSPATH scala.tools.partest.nest.NestRunner &> /dev/null ) || unset PARTEST_CLASSPATH @@ -126,7 +126,7 @@ fi # supplied argument will be used. JAVA_OPTS="-Xmx1024M -Xms64M $JAVA_OPTS" -# the ant task doesn't supply any options by default, +# the sbt task doesn't supply any options by default, # so don't do that here either -- note that you may want to pass -optimise # to mimic what happens during nightlies. # [ -n "$SCALAC_OPTS" ] || SCALAC_OPTS="-deprecation" diff --git a/tools/scaladoc-diff b/tools/scaladoc-diff index df0d1f3335..1003b3dc02 100755 --- a/tools/scaladoc-diff +++ b/tools/scaladoc-diff @@ -49,7 +49,7 @@ if [ ! -f "build/scaladoc-output-$oldsha.txt" ] then echo "making scaladoc for parent commit ($oldsha)" git checkout -q $oldsha - ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$oldsha.txt + sbt 'set scalacOptions in Compile in doc in library += "-raw-output"' library/doc > build/scaladoc-output-$oldsha.txt rm -rf build/scaladoc-${oldsha} mv build/scaladoc build/scaladoc-${oldsha} git checkout -q $sha @@ -57,7 +57,7 @@ fi # create scaladoc for current commit echo "making scaladoc for current commit ($sha)" -ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$sha.txt +sbt 'set scalacOptions in Compile in doc in library += "-raw-output"' library/doc > build/scaladoc-output-$sha.txt rm -rf build/scaladoc-${sha} mv build/scaladoc build/scaladoc-${sha} diff --git a/tools/stability-test.sh b/tools/stability-test.sh deleted file mode 100755 index f017ac0842..0000000000 --- a/tools/stability-test.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash -# - -declare failed - -echo "Comparing build/quick/classes and build/strap/classes" -for dir in library reflect compiler; do - # feel free to replace by a more elegant approach -- don't know how - if diff -rw -x '*.css' \ - -x '*.custom' \ - -x '*.gif' \ - -x '*.js' \ - -x '*.layout' \ - -x '*.png' \ - -x '*.properties' \ - -x '*.tmpl' \ - -x '*.tooltip' \ - -x '*.txt' \ - -x '*.xml' \ - build/{quick,strap}/classes/$dir - then - classes=$(find build/quick/classes/$dir -name '*.class' | wc -l) - printf "%8s: %5d classfiles verified identical\n" $dir $classes - else - failed=true - fi -done - -[[ -z $failed ]] || exit 127 -- cgit v1.2.3