diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..e52be19 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[html] +directory = out/commons/scoverage/htmlReport diff --git a/.gitignore b/.gitignore index ee44a96..a133b2c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea target +out diff --git a/.travis.yml b/.travis.yml index 4fdf7b0..c27abd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,25 @@ sudo: required language: scala scala: -- 2.12.2 + - 2.12.2 jdk: -- oraclejdk8 + - oraclejdk8 script: -- sbt +clean coverage +test && sbt coverageReport coverageAggregate -- find $HOME/.sbt -name "*.lock" | xargs rm -- find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm + - curl -L -o ~/bin/mill https://github.com/lihaoyi/mill/releases/download/0.2.6/0.2.6 && chmod +x ~/bin/mill + - export PATH=~/bin/mill:$PATH + - mill __.clean && mill __.test && mill __.scoverage.htmlReport + - find $HOME/.ivy2 -name "ivydata-*.properties" | xargs rm cache: directories: - - "$HOME/.ivy2/cache" - - "$HOME/.sbt/boot/" + - "$HOME/.ivy2/cache" + - "$HOME/bin/mill" before_install: -- pip install --user codecov -- sudo chmod +x /usr/local/bin/sbt + - pip install --user codecov + - sudo chmod +x /usr/local/bin/sbt after_success: - codecov - test "$TRAVIS_REPO_SLUG" == 'fulcrumgenomics/commons' && test "$TRAVIS_PULL_REQUEST" - == 'false' && test "$TRAVIS_BRANCH" == 'master' && sbt +publish + == 'false' && test "$TRAVIS_BRANCH" == 'master' && mill __.publish --release true env: global: - secure: erKEtyVxyTgRQIrzva785xST9EhsYY+40SKhaHumIvXgfHtL6SppXCd213LXdwrKms23v/BZ43I5gOfEuX405FV1a8B7e+IGj1sG118MtlcVEyqSfuwGWtmsjhyWkvfHdyXzC8Aej5FpT9il74IdYJYVWW18UOh/q7cBI3duV5p9iooJG6IZ8zc1042+uKq4sfM9EnZEyCiffpVmqknRWZ47vlDEOiURYqccvJ0VN2P2mWSHTRMlXPGHuhy5KVMC/DIsZFbX2MaKMIT73hGMA8l6RS98ZSk7DkgrNr3hKy7P4YU9VyLRiz7S4MhCmS2L/NUEGI6V5Gouxpol+IX93IcpLp0ZgzYMfpnWfZyjTIx627cKKAsSOqoGteRFRArKwbag15u9lHltAu911PVa2bICZy0snr/CQx18++3hIPrKXLk5MnU4jQGOtZ1FbScPgEJBP2M6bUKHKPx2EJfQ5KtJgQtpv26LwLhrlJ+lRRQrirL0N3PAcciRtjGubAlB4ai9Qx6dVdJ84tlWMcgvZA2HExnK8uU6MK1biWBZevMrJ8qeb55CCaK5R7fZZJvAYKH9LIxt2YO2C8tVDEmPxjiZBp6jr9Ib+oiHU27PhUxzG1xK264tzp1LoBIewcUunbicDzqBPsQ60ByCaBhgin76E6+H+uxUY3tEnuIWX7c= diff --git a/build.sbt b/build.sbt deleted file mode 100644 index 87c216a..0000000 --- a/build.sbt +++ /dev/null @@ -1,122 +0,0 @@ -import com.typesafe.sbt.SbtGit.GitCommand -import sbt.Keys._ -import sbt._ -import sbtassembly.AssemblyKeys.assembly -import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._ -import scoverage.ScoverageKeys._ - -//////////////////////////////////////////////////////////////////////////////////////////////// -// We have the following "settings" in this build.sbt: -// - versioning with sbt-release -// - custom JAR name for the root project -// - settings to publish to Sonatype -// - exclude the root, tasks, and pipelines project from code coverage -// - scaladoc settings -// - custom merge strategy for assembly -//////////////////////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////////////////////// -// Use sbt-release to bump the version numbers. -// -// see: http://blog.byjean.eu/2015/07/10/painless-release-with-sbt.html -//////////////////////////////////////////////////////////////////////////////////////////////// - -// Release settings -releaseVersionBump := sbtrelease.Version.Bump.Next -releasePublishArtifactsAction := PgpKeys.publishSigned.value -releaseProcess := Seq[ReleaseStep]( - checkSnapshotDependencies, - inquireVersions, - runClean, - runTest, - setReleaseVersion, - commitReleaseVersion, - tagRelease, - releaseStepCommand("publishSigned"), - setNextVersion, - commitNextVersion, - releaseStepCommand("sonatypeReleaseAll"), - pushChanges -) - -//////////////////////////////////////////////////////////////////////////////////////////////// -// For the aggregate (root) jar, override the name. For the sub-projects, -// see the build.sbt in each project folder. -//////////////////////////////////////////////////////////////////////////////////////////////// -assemblyJarName in assembly := "commons-" + version.value + ".jar" - -//////////////////////////////////////////////////////////////////////////////////////////////// -// Sonatype settings -//////////////////////////////////////////////////////////////////////////////////////////////// -publishMavenStyle := true -publishTo := { - val nexus = "https://oss.sonatype.org/" - if (isSnapshot.value) - Some("snapshots" at nexus + "content/repositories/snapshots") - else - Some("releases" at nexus + "service/local/staging/deploy/maven2") -} -publishArtifact in Test := false -pomIncludeRepository := { _ => false } -// For Travis CI - see http://www.cakesolutions.net/teamblogs/publishing-artefacts-to-oss-sonatype-nexus-using-sbt-and-travis-ci -credentials ++= (for { - username <- Option(System.getenv().get("SONATYPE_USER")) - password <- Option(System.getenv().get("SONATYPE_PASS")) -} yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", username, password)).toSeq - -//////////////////////////////////////////////////////////////////////////////////////////////// -// Coverage settings: include all sources -//////////////////////////////////////////////////////////////////////////////////////////////// -val htmlReportsDirectory: String = "target/test-reports" - -//////////////////////////////////////////////////////////////////////////////////////////////// -// scaladoc options -//////////////////////////////////////////////////////////////////////////////////////////////// -val docScalacOptions = Seq("-groups", "-implicits") - -//////////////////////////////////////////////////////////////////////////////////////////////// -// Common settings for all projects -//////////////////////////////////////////////////////////////////////////////////////////////// - -lazy val commonSettings = Seq( - organization := "com.fulcrumgenomics", - organizationName := "Fulcrum Genomics LLC", - organizationHomepage := Some(url("http://www.fulcrumgenomics.com")), - homepage := Some(url("http://github.com/fulcrumgenomics/commons")), - startYear := Some(2015), - scalaVersion := "2.12.2", - crossScalaVersions := Seq("2.11.11", "2.12.2"), - scalacOptions ++= Seq("-target:jvm-1.8", "-deprecation", "-unchecked"), - scalacOptions in (Compile, doc) ++= docScalacOptions, - scalacOptions in (Test, doc) ++= docScalacOptions, - autoAPIMappings := true, - testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-h", Option(System.getenv("TEST_HTML_REPORTS")).getOrElse(htmlReportsDirectory)), - testOptions in Test += Tests.Argument("-l", "LongRunningTest"), // ignores long running tests - // uncomment for full stack traces - //testOptions in Test += Tests.Argument("-oD"), - fork in Test := true, - resolvers += Resolver.jcenterRepo, - shellPrompt := { state => "%s| %s> ".format(GitCommand.prompt.apply(state), version.value) }, - updateOptions := updateOptions.value.withCachedResolution(true) -) ++ Defaults.coreDefaultSettings - -//////////////////////////////////////////////////////////////////////////////////////////////// -// commons project -//////////////////////////////////////////////////////////////////////////////////////////////// -lazy val assemblySettings = Seq( - test in assembly := {}, - logLevel in assembly := Level.Info -) - -lazy val root = Project(id="commons", base=file(".")) - .settings(commonSettings: _*) - .settings(assemblySettings: _*) - .settings(description := "Scala commons for Fulcrum Genomics.") - .settings( - libraryDependencies ++= Seq( - "com.typesafe" % "config" % "1.3.2", - "org.scala-lang" % "scala-reflect" % scalaVersion.value, - //---------- Test libraries -------------------// - "org.scalatest" %% "scalatest" % "3.0.1" % "test->*" excludeAll ExclusionRule(organization="org.junit", name="junit") - ) - ) diff --git a/build.sc b/build.sc new file mode 100644 index 0000000..1726fc5 --- /dev/null +++ b/build.sc @@ -0,0 +1,70 @@ +import $ivy.`com.lihaoyi::mill-contrib-buildinfo:0.4.0` +import mill.contrib.scoverage.ScoverageModule + +import mill.Cross +import mill.scalalib.{SbtModule, PublishModule, Dep, CrossSbtModule, DepSyntax} +import mill.scalalib.publish.{PomSettings, License, Developer, SCM} +import ammonite.ops._ + +import scala.sys.process.Process + +object commons extends SbtModule with ScoverageModule with PublishModule { outer => + def millSourcePath = super.millSourcePath / ammonite.ops.up + def artifactName = "commons" + def gitHash = Process("git rev-parse --short HEAD").lineStream.head + def publishVersion = s"0.6.0-${gitHash}-SNAPSHOT" + def scalaVersion = "2.12.8" + def scoverageVersion = "1.3.1" + def scalacOptions = Seq("-target:jvm-1.8", "-deprecation", "-unchecked") + + // TODO: start year (2015) + // TODO: organization homepage ("http://www.fulcrumgenomics.com") + def pomSettings = PomSettings( + description = artifactName(), + organization = "com.fulcrumgenomics", + url = "https://github.com/fulcrumgenomics/commons", + licenses = Seq(License("MIT license", "http://www.opensource.org/licenses/mit-license.php")), + scm = SCM( + "git://github.com/fulcrumgenomics/commons.git", + "scm:git://github.com/fulcrumgenomics/commons.git" + ), + developers = Seq( + Developer("nh13", "Nils Homer", "https://github.com/nh13"), + Developer("tfenne", "Tim Fennell", "https://github.com/tfenne") + ) + ) + + def ivyDeps = Agg( + ivy"org.scala-lang:scala-compiler:${scalaVersion()}", + ivy"com.typesafe:config:1.3.2", + ) + + // TODO: ignore long running tests with "-l LongRunningTest" + object test extends Tests { + def ivyDeps = Agg(ivy"org.scalatest::scalatest:3.0.5") + def testFrameworks = Seq("org.scalatest.tools.Framework") + } + + object coverage extends ScoverageTests { + def ivyDeps = Agg(ivy"org.scalatest::scalatest:3.0.5") + def testFrameworks = Seq("org.scalatest.tools.Framework") + + // See: https://github.com/lihaoyi/mill/blob/master/scalalib/src/MiscModule.scala#L66-L77 + override def millSourcePath = outer.millSourcePath + override def intellijModulePath = outer.millSourcePath / 'src / 'test + override def sources = T.sources( + millSourcePath / 'src / 'test / 'scala, + millSourcePath / 'src / 'test / 'java + ) + override def resources = T.sources{ millSourcePath / 'src / 'test / 'resources } + + } + + private def deployJar(assembly: PathRef, jarName:String) = { + mkdir(pwd / 'jars) + println(s"Copying artifact ${assembly.path} to jars / $jarName") + cp.over(assembly.path, pwd / 'jars / jarName) + } + + def assemblyJar = T { deployJar(assembly(), s"commons-${publishVersion()}.jar") } +} diff --git a/project/build.properties b/project/build.properties deleted file mode 100644 index 0531343..0000000 --- a/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=1.1.2 diff --git a/project/plugins.sbt b/project/plugins.sbt deleted file mode 100644 index 6d47c12..0000000 --- a/project/plugins.sbt +++ /dev/null @@ -1,9 +0,0 @@ -resolvers += Resolver.url("fix-sbt-plugin-releases", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns) - -addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3") -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.6") -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.2") -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") -addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0") diff --git a/sonatype.sbt b/sonatype.sbt deleted file mode 100644 index 5a3ea39..0000000 --- a/sonatype.sbt +++ /dev/null @@ -1,22 +0,0 @@ -sonatypeProfileName := "com.fulcrumgenomics" - -pomExtra in Global := { - - - MIT License - http://www.opensource.org/licenses/mit-license.html - - - - - nh13 - Nils Homer - http://github.com/nh13 - - - tfenne - Tim Fennell - http://github.com/tfenne - - -} diff --git a/version.sbt b/version.sbt deleted file mode 100644 index 6b73974..0000000 --- a/version.sbt +++ /dev/null @@ -1,7 +0,0 @@ -val gitHeadCommitSha = settingKey[String]("current git commit SHA") -gitHeadCommitSha in ThisBuild := scala.sys.process.Process("git rev-parse --short HEAD").lineStream.head - -// *** IMPORTANT *** -// One of the two "version" lines below needs to be uncommented. -// version in ThisBuild := "0.6.0" // the release version -version in ThisBuild := s"0.6.0-${gitHeadCommitSha.value}-SNAPSHOT" // the snapshot version