Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing to the mill build system #48

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[html]
directory = out/commons/scoverage/htmlReport
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.idea
target
out
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
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.4.0/0.4.0-9-1db2ee && chmod +x ~/bin/mill
- export PATH=~/bin/mill:$PATH
- mill __.clean && mill __.test && mill __.scoverage.xmlReport
cache:
directories:
- "$HOME/.ivy2/cache"
- "$HOME/.sbt/boot/"
- "$HOME/.ivy2/cache"
- "$HOME/.coursier"

before_install:
- pip install --user codecov
- sudo chmod +x /usr/local/bin/sbt
- pip install --user codecov
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 mill.scalalib.PublishModule/publishAll "${SONATYPE_USERNAME}:${SONATYPE_PASSWORD}" __.publishArtifacts --release true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little cumbersome. Is there a way to put some of this line into the build file so that the command is closer to mill publishAll? Thinking about when we're doing official releases and doing this by hand.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is this doing cross-builds?

env:
global:
- secure: erKEtyVxyTgRQIrzva785xST9EhsYY+40SKhaHumIvXgfHtL6SppXCd213LXdwrKms23v/BZ43I5gOfEuX405FV1a8B7e+IGj1sG118MtlcVEyqSfuwGWtmsjhyWkvfHdyXzC8Aej5FpT9il74IdYJYVWW18UOh/q7cBI3duV5p9iooJG6IZ8zc1042+uKq4sfM9EnZEyCiffpVmqknRWZ47vlDEOiURYqccvJ0VN2P2mWSHTRMlXPGHuhy5KVMC/DIsZFbX2MaKMIT73hGMA8l6RS98ZSk7DkgrNr3hKy7P4YU9VyLRiz7S4MhCmS2L/NUEGI6V5Gouxpol+IX93IcpLp0ZgzYMfpnWfZyjTIx627cKKAsSOqoGteRFRArKwbag15u9lHltAu911PVa2bICZy0snr/CQx18++3hIPrKXLk5MnU4jQGOtZ1FbScPgEJBP2M6bUKHKPx2EJfQ5KtJgQtpv26LwLhrlJ+lRRQrirL0N3PAcciRtjGubAlB4ai9Qx6dVdJ84tlWMcgvZA2HExnK8uU6MK1biWBZevMrJ8qeb55CCaK5R7fZZJvAYKH9LIxt2YO2C8tVDEmPxjiZBp6jr9Ib+oiHU27PhUxzG1xK264tzp1LoBIewcUunbicDzqBPsQ60ByCaBhgin76E6+H+uxUY3tEnuIWX7c=
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![Code Review](https://api.codacy.com/project/badge/grade/52e1d786d9784c7192fae2f8e853fa34)](https://www.codacy.com/app/contact_32/commons)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.fulcrumgenomics/commons_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.fulcrumgenomics/commons_2.11)
[![Javadocs](http://javadoc.io/badge/com.fulcrumgenomics/commons_2.12.svg)](http://javadoc.io/doc/com.fulcrumgenomics/commons_2.12)
[![Dependency Status](https://www.versioneye.com/user/projects/56b2d2d593b95a003c714340/badge.svg)](https://www.versioneye.com/user/projects/56b2d2d593b95a003c714340#dialog_dependency_badge)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also add a little to the README about how to build the project, so how to get the minimum version of mill and what the command is to compile/test/build jar? Perhaps how to publish locally?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also think about how one gets setup in IntelliJ since IntelliJ doesn't (yet) understand mill build files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mill mill.scalalib.GenIdea/idea;

[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/fulcrumgenomics/commons/blob/master/LICENSE)
[![Language](http://img.shields.io/badge/language-scala-brightgreen.svg)](http://www.scala-lang.org/)

Expand Down
121 changes: 0 additions & 121 deletions build.sbt

This file was deleted.

56 changes: 56 additions & 0 deletions build.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// IMPORTANT: the version of the contrib modules must be 0.4.0-9-1db2ee or later.
// IMPORTANT: if you change this version to a release, please update the .travis.yml
// FIXME: change to a release version after 0.4.0-9-1db2ee
import $ivy.`com.lihaoyi::mill-contrib-buildinfo:0.4.0-9-1db2ee`
import mill.contrib.scoverage.ScoverageModule

import mill.scalalib.{PublishModule, Dep, DepSyntax, ScalaModule}
import mill.scalalib.publish.{PomSettings, License, Developer, SCM}
import ammonite.ops._

import scala.sys.process.Process

object commons extends ScalaModule with ScoverageModule with PublishModule {
def artifactName = "commons"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we do something like getClass.getSimpleName here to standardize object == artifact name? Or do we want to embed the version name here?

def gitHash = Process("git rev-parse --short HEAD").lineStream.head
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can avoid using Process and instead use ammonite os.proc

def publishVersion = s"0.6.0-${gitHash}-SNAPSHOT"
def scalaVersion = "2.12.8"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So do we lose cross-building? That seems less than ideal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I'll want to do add that support. Mill has facilities to do this http://www.lihaoyi.com/mill/page/cross-builds.html

def scoverageVersion = "1.3.1"
def scalacOptions = Seq("-target:jvm-1.8", "-deprecation", "-unchecked")

// TODO: start year (2015)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we resolve these TODOs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could use some help 👍

// 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 ScoverageTests {
def ivyDeps = Agg(ivy"org.scalatest::scalatest:3.0.5")
def testFrameworks = Seq("org.scalatest.tools.Framework")
}

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") }
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import scala.collection.mutable
*/
class AsyncStreamSinkTest extends UnitSpec {
"AsyncStreamSink" should "capture all the output" in {
val file = Paths.get("src/test/resources/com/fulcrumgenomics/commons/io/async-stream-sink-test.txt")
val file = Paths.get("commons/test/resources/com/fulcrumgenomics/commons/io/async-stream-sink-test.txt")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit surprised by this. Does mill require even for single-module builds that the main and test sources are within a module directory?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val expected = Io.toSource(file).getLines().toList

val proc = new ProcessBuilder("cat", file.toString).start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class IoTest extends UnitSpec {
}

// The expected lines from the file loaded as a resource
private val ResourceLines = Io.readLines(Paths.get("src/test/resources/com/fulcrumgenomics/commons/io/to-lines-from-resource-test.txt")).toList
private val ResourceLines = Io.readLines(Paths.get("commons/test/resources/com/fulcrumgenomics/commons/io/to-lines-from-resource-test.txt")).toList

"Io.readLinesFromResource" should "read lines from a resource" in {
val actual = Io.readLinesFromResource("/com/fulcrumgenomics/commons/io/to-lines-from-resource-test.txt").toList
Expand Down
1 change: 0 additions & 1 deletion project/build.properties

This file was deleted.

9 changes: 0 additions & 9 deletions project/plugins.sbt

This file was deleted.

22 changes: 0 additions & 22 deletions sonatype.sbt

This file was deleted.

7 changes: 0 additions & 7 deletions version.sbt

This file was deleted.