From b1b54751cd4d96c102110bdbb512c729d1f618a5 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Wed, 16 Dec 2015 10:28:03 -0800 Subject: Use sbt for PR validation builds. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Improve version handling in the sbt build: The new settings `baseVersion` and `baseVersionSuffix` make it easier to set version numbers for different kinds of builds in a consistent way without e.g. having to first get a git SHA outside of sbt. The new task `generateBuildCharacterPropertiesFile` writes the file `buildcharacter.properties` to the root dir. The format is compatible with the same file produced by the ANT build but it only contains a subset of the properties, in particular the Maven version, which is needed in publishing scripts and passed around between different Jenkins jobs as `jenkins.properties`. SHAs in version numbers are consistently shortened to 7 digits (as used by git and github). Previously we used 7 digits in Maven snapshot version numbers but 10 digits in canonical and OSGi version numbers. # Add Jenkins script support to the sbt build: The new command `setupPublishCore` takes the PR validation snapshot repository as an argument and changes the required settings for the `publish-core` build (use SHA-SNAPSHOT versioning, compile with optimization enabled, do not publish scaladoc sets) For example, the following command can be used to generate `buildcharacter.properties` with the version numbers needed for PR validation builds: sbt setupPublishCore dummy generateBuildCharacterPropertiesFile The sbt build will now automatically detect and use a “~/.credentials” file with the credentials for publishing to a remote repository. # Call sbt from `publish-core`: The correct`$SBT_CMD` is set directly in `bootstrap` and used by `publish-core` to first generate `buildcharacter.properties` and then build and publish. Parsing the git revision, computing a version number and getting binary dependencies are no longer required in the script. This is all done in the sbt build. --- scripts/common | 3 +++ scripts/jobs/integrate/bootstrap | 20 ++++++++------------ scripts/jobs/validate/publish-core | 13 ++----------- 3 files changed, 13 insertions(+), 23 deletions(-) (limited to 'scripts') diff --git a/scripts/common b/scripts/common index b075469379..35199992bc 100644 --- a/scripts/common +++ b/scripts/common @@ -18,6 +18,9 @@ IVY_CACHE="$WORKSPACE/.ivy2" mkdir -p $IVY_CACHE rm -rf $IVY_CACHE/cache/org.scala-lang +SBT_CMD=${sbtCmd-sbt} +SBT_CMD="$SBT_CMD -sbt-version 0.13.9" + # temp dir where all 'non-build' operation are performed TMP_ROOT_DIR=$(mktemp -d -t pr-scala.XXXX) TMP_DIR="${TMP_ROOT_DIR}/tmp" diff --git a/scripts/jobs/integrate/bootstrap b/scripts/jobs/integrate/bootstrap index 8d04e7fc79..cbb8e1026b 100755 --- a/scripts/jobs/integrate/bootstrap +++ b/scripts/jobs/integrate/bootstrap @@ -22,7 +22,7 @@ # - To prevent staging on sonatype (for testing), set publishToSonatype to anything but "yes" # - Note: After building a release, the jenkins job provides an updated versions.properties file as artifact. # Put this file in the Scala repo and create a pull request, and also update the file build.number. -# +# # - Otherwise, a nightly release is built: # - version number is read from the build.number file, extended with -$sha-nightly @@ -73,7 +73,7 @@ # Requirements -# - sbtCmd must point to sbt from sbt-extras +# - SBT_CMD must point to sbt from sbt-extras # - ~/.sonatype-curl, ~/.m2/settings.xml, ~/.credentials, ~/.credentials-sonatype, ~/.credentials-private-repo # as defined by https://github.com/scala/scala-jenkins-infra/tree/master/templates/default # - ~/.sbt/0.13/plugins/gpg.sbt with: @@ -89,10 +89,6 @@ publishSonatypeTaskCore=${publishSonatypeTaskCore-"publish-signed"} publishSonatypeTaskModules=${publishSonatypeTaskModules-"publish-signed"} publishLockerPrivateTask=${publishLockerPrivateTask-$publishPrivateTask} # set to "init" to speed up testing of the script (if you already built locker before) -sbtCmd=${sbtCmd-sbt} # TESTING (this is a marker for defaults to change when testing locally: should be sbtx on my mac) - -sbtCmd="$sbtCmd -sbt-version 0.13.8" - forceRebuild=${forceRebuild-no} antBuildTask="${antBuildTask-nightly}" # TESTING leave empty to avoid the sanity check (don't set it to "init" because ant will croak) @@ -180,8 +176,8 @@ function st_stagingRepoClose() { sbtArgs="-no-colors -ivy $baseDir/ivy2 -Dsbt.override.build.repos=true -Dsbt.repository.config=$sbtRepositoryConfig -Dsbt.global.base=$HOME/.sbt/0.13 -sbt-dir $HOME/.sbt/0.13" sbtBuild() { - echo "### sbtBuild: "$sbtCmd $sbtArgs "${scalaVersionTasks[@]}" "${publishTasks[@]}" "$@" - $sbtCmd $sbtArgs "${scalaVersionTasks[@]}" "${publishTasks[@]}" "$@" >> $baseDir/logs/builds 2>&1 + echo "### sbtBuild: "$SBT_CMD $sbtArgs "${scalaVersionTasks[@]}" "${publishTasks[@]}" "$@" + $SBT_CMD $sbtArgs "${scalaVersionTasks[@]}" "${publishTasks[@]}" "$@" >> $baseDir/logs/builds 2>&1 } sbtResolve() { @@ -189,8 +185,8 @@ sbtResolve() { touch build.sbt # Can be set to `full` if a module requires cross-versioning against the full Scala version, like the continuations plugin. cross=${4-binary} - echo "### sbtResolve: $sbtCmd $sbtArgs " "${scalaVersionTasks[@]}" "\"$1\" % \"$2\" % \"$3\" cross CrossVersion.$cross" - $sbtCmd $sbtArgs "${scalaVersionTasks[@]}" \ + echo "### sbtResolve: $SBT_CMD $sbtArgs " "${scalaVersionTasks[@]}" "\"$1\" % \"$2\" % \"$3\" cross CrossVersion.$cross" + $SBT_CMD $sbtArgs "${scalaVersionTasks[@]}" \ "set libraryDependencies := Seq(\"$1\" % \"$2\" % \"$3\" cross CrossVersion.$cross)" \ 'show update' >> $baseDir/logs/resolution 2>&1 } @@ -257,7 +253,7 @@ buildContinuations() { else update scala scala-continuations $CONTINUATIONS_REF && gfxd - $sbtCmd $sbtArgs 'project plugin' "${scalaVersionTasks[@]}" "${publishTasks[@]}" \ + $SBT_CMD $sbtArgs 'project plugin' "${scalaVersionTasks[@]}" "${publishTasks[@]}" \ 'set version := "'$CONTINUATIONS_VER'"' $clean "compile:package" test "${buildTasks[@]}" # https://github.com/scala/scala-continuations/pull/4 CONT_PLUG_BUILT="yes" fi @@ -266,7 +262,7 @@ buildContinuations() { then echo "Found scala-continuations-library $CONTINUATIONS_VER; not building." else update scala scala-continuations $CONTINUATIONS_REF && gfxd - $sbtCmd $sbtArgs 'project library' "${scalaVersionTasks[@]}" "${publishTasks[@]}" \ + $SBT_CMD $sbtArgs 'project library' "${scalaVersionTasks[@]}" "${publishTasks[@]}" \ 'set version := "'$CONTINUATIONS_VER'"' $clean test "${buildTasks[@]}" CONT_LIB_BUILT="yes" fi diff --git a/scripts/jobs/validate/publish-core b/scripts/jobs/validate/publish-core index 9dff5a34b0..bb0056722d 100755 --- a/scripts/jobs/validate/publish-core +++ b/scripts/jobs/validate/publish-core @@ -15,17 +15,8 @@ case $prDryRun in mkdir -p build/pack ; mkdir -p dists/maven/latest ;; *) - sha=$(git rev-parse HEAD) # TODO: warn if $repo_ref != $sha (we shouldn't do PR validation using symbolic gitrefs) - echo "sha/repo_ref == $sha/$repo_ref ?" - - parseScalaProperties build.number - - ./pull-binary-libs.sh - # "noyoudont" is there juuuust in case - antDeployArgs="-Dmaven.version.suffix=\"-${sha:0:7}-SNAPSHOT\" -Dremote.snapshot.repository=$prRepoUrl -Drepository.credentials.id=pr-scala -Dremote.release.repository=noyoudont" - echo ">>> Getting Scala version number." - ant -q $antDeployArgs init + $SBT_CMD "setupPublishCore $prRepoUrl" generateBuildCharacterPropertiesFile parseScalaProperties buildcharacter.properties # produce maven_version_number echo ">>> Checking availability of Scala ${maven_version_number} in $prRepoUrl." @@ -36,7 +27,7 @@ case $prDryRun in if $libraryAvailable && $reflectAvailable && $compilerAvailable; then echo "Scala core already built!" else - ant $antDeployArgs $antBuildArgs publish-opt-nodocs + $SBT_CMD "setupPublishCore $prRepoUrl" $antBuildArgs publish fi mv buildcharacter.properties jenkins.properties # parsed by the jenkins job -- cgit v1.2.3