From d2a3be40ab33a4bb4a45821ade607e8277754ef0 Mon Sep 17 00:00:00 2001 From: jay Carey Date: Fri, 17 Jun 2022 09:19:57 -0400 Subject: [PATCH] Update mill and fix up all deprecations. --- .gitignore | 1 + build.sc | 51 +++++++++++++++++++++++++++------------------------ mill | 11 ++++++----- 3 files changed, 34 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 5379c67..57638c2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .idea_modules out jars +.bsp diff --git a/build.sc b/build.sc index 65b9ea8..0db8aed 100644 --- a/build.sc +++ b/build.sc @@ -1,31 +1,35 @@ +import coursier.maven.MavenRepository +import mill._ +import mill.scalalib._ +import mill.scalalib.publish._ + import java.text.SimpleDateFormat import java.util.Date import java.util.jar.Attributes.Name.{IMPLEMENTATION_VERSION => ImplementationVersion} import scala.sys.process.Process -import scala.util.{Failure, Success, Try} -import mill._, scalalib._, publish._ -import coursier.maven.MavenRepository /** Base trait for build modules. */ trait CommonModule extends SbtModule { - def deployLocal(assembly: PathRef, jarName:String) = { - os.makeDir.all(os.pwd / 'jars) + def deployLocal(assembly: PathRef, jarName: String): Unit = { + os.makeDir.all(os.pwd / Symbol("jars")) println(s"Copying artifact ${assembly.path} to jars / $jarName") - os.copy(assembly.path, os.pwd / 'jars / jarName, replaceExisting=true) + os.copy(assembly.path, os.pwd / Symbol("jars") / jarName, replaceExisting=true) } - override def repositories: Seq[coursier.Repository] = super.repositories ++ Seq( - MavenRepository("https://oss.sonatype.org/content/repositories/public"), - MavenRepository("https://oss.sonatype.org/content/repositories/snapshots"), - MavenRepository("https://jcenter.bintray.com/"), - MavenRepository("https://artifactory.broadinstitute.org/artifactory/libs-snapshot/") - ) + override def repositoriesTask = T.task { + super.repositoriesTask() ++ Seq( + MavenRepository("https://oss.sonatype.org/content/repositories/public"), + MavenRepository("https://oss.sonatype.org/content/repositories/snapshots"), + MavenRepository("https://jcenter.bintray.com/"), + MavenRepository("https://artifactory.broadinstitute.org/artifactory/libs-snapshot/") + ) + } } /** A base trait for versioning modules. */ trait ReleaseModule extends JavaModule { /** Execute Git arguments and return the standard output. */ - private def git(args: String*): String = os.proc("git", args).call().out.string.trim + private def git(args: String*): String = os.proc("git", args).call().out.text().trim /** Get the commit hash at the HEAD of this branch. */ private def gitHead: String = git("rev-parse", "HEAD") @@ -40,8 +44,8 @@ trait ReleaseModule extends JavaModule { /** The implementation version. */ private def implementationVersion = T input { - val prefix = s"${today}-${shortHash}" - if (dirty) s"${prefix}-dirty" else prefix + val prefix = s"$today-$shortHash" + if (dirty) s"$prefix-dirty" else prefix } /** The version string `Target`. */ @@ -54,10 +58,10 @@ trait ReleaseModule extends JavaModule { object tools extends CommonModule with PublishModule with ReleaseModule { def scalaVersion = "2.13.8" - def mainClass = Some("com.client.cmdline.ClientMain") - def artifactName = "client-tools" - def gitHash = Process("git rev-parse --short HEAD").lineStream.head - def publishVersion = s"0.0.1-${gitHash}-SNAPSHOT" + override def mainClass = Some("com.client.cmdline.ClientMain") + override def artifactName = "client-tools" + def gitHash = Process("git rev-parse --short HEAD").lazyLines.head + def publishVersion = s"0.0.1-$gitHash-SNAPSHOT" def pomSettings = PomSettings( description = artifactName(), organization = "com.client", @@ -77,17 +81,16 @@ object tools extends CommonModule with PublishModule with ReleaseModule { "com.google.cloud.genomics" ) - def ivyDeps = Agg( + override def ivyDeps = Agg( ivy"org.scala-lang:scala-compiler:${scalaVersion()}", - ivy"mysql:mysql-connector-java:5.1.24", ivy"com.fulcrumgenomics:commons_2.13:1.1.0", ivy"com.fulcrumgenomics:sopt_2.13:1.1.0", ivy"com.fulcrumgenomics:fgbio_2.13:1.4.0-61dde53-SNAPSHOT".excludeOrg(orgsToExclude:_*), ) object test extends Tests { - def ivyDeps = Agg(ivy"org.scalatest::scalatest:3.1.0") - def testFrameworks = Seq("org.scalatest.tools.Framework") + override def ivyDeps = Agg(ivy"org.scalatest::scalatest:3.1.0") + override def testFramework = "org.scalatest.tools.Framework" // run mill tools.test.singleTest com.client.x.y.x.TestClassName def singleTest(args: String*) = T.command { @@ -95,7 +98,7 @@ object tools extends CommonModule with PublishModule with ReleaseModule { } } - def javacOptions = Seq("-source", "1.8", "-target", "1.8") + override def javacOptions = Seq("-source", "1.8", "-target", "1.8") def deployLocal = T { super.deployLocal(assembly(), "client-tools.jar") } } diff --git a/mill b/mill index 539c865..c04905e 100755 --- a/mill +++ b/mill @@ -3,14 +3,14 @@ # This is a wrapper script, that automatically download mill from GitHub release pages # You can give the required mill version with MILL_VERSION env variable # If no version is given, it falls back to the value of DEFAULT_MILL_VERSION -DEFAULT_MILL_VERSION=0.10.1 +DEFAULT_MILL_VERSION=0.10.4 set -e if [ -z "$MILL_VERSION" ] ; then if [ -f ".mill-version" ] ; then MILL_VERSION="$(head -n 1 .mill-version 2> /dev/null)" - elif [ -f "mill" ] && [ "$BASH_SOURCE" != "mill" ] ; then + elif [ -f "mill" ] && [ "$0" != "mill" ] ; then MILL_VERSION=$(grep -F "DEFAULT_MILL_VERSION=" "mill" | head -n 1 | cut -d= -f2) else MILL_VERSION=$DEFAULT_MILL_VERSION @@ -28,13 +28,14 @@ version_remainder="$MILL_VERSION" MILL_MAJOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" MILL_MINOR_VERSION="${version_remainder%%.*}"; version_remainder="${version_remainder#*.}" -if [ ! -x "$MILL_EXEC_PATH" ] ; then - mkdir -p $MILL_DOWNLOAD_PATH +if [ ! -s "$MILL_EXEC_PATH" ] ; then + mkdir -p "$MILL_DOWNLOAD_PATH" if [ "$MILL_MAJOR_VERSION" -gt 0 ] || [ "$MILL_MINOR_VERSION" -ge 5 ] ; then ASSEMBLY="-assembly" fi DOWNLOAD_FILE=$MILL_EXEC_PATH-tmp-download - MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION%%-*}/$MILL_VERSION${ASSEMBLY}" + MILL_VERSION_TAG=$(echo $MILL_VERSION | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/') + MILL_DOWNLOAD_URL="https://github.com/lihaoyi/mill/releases/download/${MILL_VERSION_TAG}/$MILL_VERSION${ASSEMBLY}" curl --fail -L -o "$DOWNLOAD_FILE" "$MILL_DOWNLOAD_URL" chmod +x "$DOWNLOAD_FILE" mv "$DOWNLOAD_FILE" "$MILL_EXEC_PATH"