Skip to content

Commit

Permalink
Merge pull request #1 from fulcrumgenomics/update_skeleton_fix_deprec…
Browse files Browse the repository at this point in the history
…ations

Update mill and fix up all deprecations.
  • Loading branch information
Jay Carey authored Jun 17, 2022
2 parents 269b2f8 + d2a3be4 commit e93414a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.idea_modules
out
jars
.bsp
51 changes: 27 additions & 24 deletions build.sc
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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`. */
Expand All @@ -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",
Expand All @@ -77,25 +81,24 @@ 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 {
super.runMain("org.scalatest.run", args: _*)
}
}

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") }
}
11 changes: 6 additions & 5 deletions mill
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:/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:/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"
Expand Down

0 comments on commit e93414a

Please sign in to comment.