Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Updated build and dependencies: (#402)
Browse files Browse the repository at this point in the history
- Scala 2.13 only (and updated to 2.13.8)
- Updated to sbt 1.6.2
- Updated sbt plugins to match
- Updated various dependencies
  • Loading branch information
tfenne authored Mar 12, 2022
1 parent a27e576 commit 09ca816
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 134 deletions.
46 changes: 24 additions & 22 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ releaseProcess := Seq[ReleaseStep](
// For the aggregate (root) jar, override the name. For the sub-projects,
// see the build.sbt in each project folder.
////////////////////////////////////////////////////////////////////////////////////////////////
assemblyJarName in assembly := "dagr-" + version.value + ".jar"
assembly / assemblyJarName := "dagr-" + version.value + ".jar"

////////////////////////////////////////////////////////////////////////////////////////////////
// Sonatype settings
Expand All @@ -58,7 +58,7 @@ lazy val sonatypeSettings = Seq(
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
},
publishArtifact in Test := false,
Test / publishArtifact := 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 {
Expand Down Expand Up @@ -88,31 +88,32 @@ lazy val commonSettings = Seq(
organizationHomepage := Some(url("http://www.fulcrumgenomics.com")),
homepage := Some(url("http://github.com/fulcrumgenomics/dagr")),
startYear := Some(2015),
scalaVersion := "2.13.0",
crossScalaVersions := Seq("2.12.8", "2.13.0"),
scalaVersion := "2.13.8",
crossScalaVersions := Seq("2.13.8"),
scalacOptions ++= Seq("-target:jvm-1.8", "-deprecation"),
scalacOptions in (Compile, doc) ++= docScalacOptions,
scalacOptions in (Test, doc) ++= docScalacOptions,
Compile / doc / scalacOptions ++= docScalacOptions,
Test / doc/ scalacOptions ++= docScalacOptions,
useCoursier := false,
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
Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-h", Option(System.getenv("TEST_HTML_REPORTS")).getOrElse(htmlReportsDirectory)),
Test / testOptions += Tests.Argument("-l", "LongRunningTest"), // ignores long running tests
// uncomment for full stack traces
//testOptions in Test += Tests.Argument("-oD"),
fork in Test := true,
Test / fork := true,
resolvers += Resolver.jcenterRepo,
resolvers += Resolver.sonatypeRepo("public"),
resolvers += Resolver.mavenLocal,
shellPrompt := { state => "%s| %s> ".format(GitCommand.prompt.apply(state), version.value) },
coverageExcludedPackages := "<empty>;dagr\\.tasks.*;dagr\\.pipelines.*",
updateOptions := updateOptions.value.withCachedResolution(true),
javaOptions in Test += "-Ddagr.color-status=false",
Test / javaOptions += "-Ddagr.color-status=false",
// Needed to avoid "sbt.ForkMain failed with exit code 137"
//in Travis with `sudo: false`.
// See https://github.com/sbt/sbt/issues/653
// and https://github.com/travis-ci/travis-ci/issues/3775
javaOptions in Test += "-Xmx1G",
Test / javaOptions += "-Xmx1G",
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.8" % "test->*" excludeAll ExclusionRule(organization="org.junit", name="junit"),
assemblyJarName in assembly := s"${name.value}-${version.value}.jar"
assembly / assemblyJarName := s"${name.value}-${version.value}.jar"
) ++ Defaults.coreDefaultSettings ++ sonatypeSettings

////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -123,15 +124,15 @@ lazy val core = Project(id="dagr-core", base=file("core"))
.settings(description := "Core methods and classes to execute tasks in dagr.")
.settings(
libraryDependencies ++= Seq(
"com.fulcrumgenomics" %% "commons" % "1.2.0",
"com.fulcrumgenomics" %% "sopt" % "1.0.0",
"com.github.dblock" % "oshi-core" % "3.3",
"com.fulcrumgenomics" %% "commons" % "1.4.0",
"com.fulcrumgenomics" %% "sopt" % "1.1.0",
"com.github.oshi" % "oshi-core" % "6.1.4",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"org.reflections" % "reflections" % "0.9.10",
"com.typesafe" % "config" % "1.3.2",
"com.typesafe" % "config" % "1.4.2",
"javax.servlet" % "javax.servlet-api" % "3.1.0",
"jline" % "jline" % "2.14.2"
"jline" % "jline" % "2.14.6"
)
)
.disablePlugins(sbtassembly.AssemblyPlugin)
Expand All @@ -151,8 +152,8 @@ lazy val tasks = Project(id="dagr-tasks", base=file("tasks"))
.settings(commonSettings: _*)
.settings(
libraryDependencies ++= Seq(
"com.github.samtools" % "htsjdk" % "2.16.1" excludeAll(htsjdkAndPicardExcludes: _*),
"com.github.broadinstitute" % "picard" % "2.18.16" excludeAll(htsjdkAndPicardExcludes: _*)
"com.github.samtools" % "htsjdk" % "2.24.1" excludeAll(htsjdkAndPicardExcludes: _*),
"com.github.broadinstitute" % "picard" % "2.26.11" excludeAll(htsjdkAndPicardExcludes: _*)
)
)
.disablePlugins(sbtassembly.AssemblyPlugin)
Expand All @@ -171,8 +172,8 @@ lazy val pipelines = Project(id="dagr-pipelines", base=file("pipelines"))
// root (dagr) project
////////////////////////////////////////////////////////////////////////////////////////////////
lazy val assemblySettings = Seq(
test in assembly := {},
logLevel in assembly := Level.Info
assembly / test := {},
assembly / logLevel := Level.Info
)
lazy val root = Project(id="dagr", base=file("."))
.settings(commonSettings: _*)
Expand Down Expand Up @@ -216,4 +217,5 @@ val customMergeStrategy: String => MergeStrategy = {
MergeStrategy.first
case _ => MergeStrategy.deduplicate
}
assemblyMergeStrategy in assembly := customMergeStrategy

assembly / assemblyMergeStrategy := customMergeStrategy
3 changes: 1 addition & 2 deletions core/src/main/scala/dagr/core/cmdline/DagrCoreMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ class DagrCoreMain extends LazyLogging {
}
new DagrScriptManager().loadScripts(
scripts,
Files.createTempDirectory(PathUtil.pathTo(System.getProperty("java.io.tmpdir")), "dagrScripts"),
quiet = false
Files.createTempDirectory(PathUtil.pathTo(System.getProperty("java.io.tmpdir")), "dagrScripts")
)
case _ => false
}
Expand Down
132 changes: 31 additions & 101 deletions core/src/main/scala/dagr/core/cmdline/DagrScriptManager.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@

package dagr.core.cmdline

import java.net.{URL, URLClassLoader}
import java.nio.file.Path

import com.fulcrumgenomics.commons.io.Io
import com.fulcrumgenomics.commons.util.{LazyLogging, LogLevel}
import com.fulcrumgenomics.commons.CommonsDef._
import com.fulcrumgenomics.commons.io.Io
import com.fulcrumgenomics.commons.util.LazyLogging
import org.reflections.util.ClasspathHelper

import scala.reflect.internal.util.{FakePos, NoPosition, Position, StringOps}
import java.net.{URL, URLClassLoader}
import java.nio.file.Path
import scala.reflect.internal.util.Position
import scala.tools.nsc.io.PlainFile
import scala.tools.nsc.reporters.AbstractReporter
import scala.reflect.internal.Reporter
import scala.tools.nsc.reporters.{FilteringReporter}
import scala.tools.nsc.{Global, Settings}

object DagrScriptManager {
Expand All @@ -60,89 +60,22 @@ object DagrScriptManager {
* NSC (New Scala Compiler) reporter which logs to Log4J.
* Heavily based on scala/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
*/
private class DagrReporter(val settings: Settings, val quiet: Boolean = false) extends AbstractReporter with LazyLogging {
def displayPrompt(): Unit = {
throw new UnsupportedOperationException("Unable to prompt the user. Prompting should be off.")
}

/**
* Displays the message at position with severity.
* @param posIn Position of the event in the file that generated the message.
* @param msg Message to display.
* @param severity Severity of the event.
*/
def display(posIn: Position, msg: String, severity: Severity): Unit = {
severity.count += 1
val level = severity match {
case INFO => LogLevel.Info
case WARNING => LogLevel.Warning
case ERROR => LogLevel.Error
}

val p2 = Option(posIn) match {
case None => NoPosition
case Some(p) if p.isDefined => p.finalPosition //posIn.inUltimateSource(posIn.source)
case Some(p) => p
}

p2 match {
case FakePos(fmsg) =>
printMessage(level, s"$fmsg $msg")
case NoPosition =>
printMessage(level, msg)
case pos: Position =>
val file = pos.source.file
printMessage(level, file.name + ":" + pos.line + ": " + msg)
printSourceLine(level, pos)
}
}

/**
* Prints the source code line of an event followed by a pointer within the line to the error.
* @param level Severity level.
* @param pos Position in the file of the event.
*/
private def printSourceLine(level: LogLevel, pos: Position): Unit = {
printMessage(level, pos.lineContent.stripLineEnd)
printColumnMarker(level, pos)
}

/**
* Prints the column marker of the given position.
* @param level Severity level.
* @param pos Position in the file of the event.
*/
private def printColumnMarker(level: LogLevel, pos: Position): Unit = {
if (pos.isDefined) {
printMessage(level, " " * (pos.column - 1) + "^")
}
}

/**
* Prints a summary count of warnings and errors.
*/
def printSummary(): Unit = {
if (WARNING.count > 0)
printMessage(LogLevel.Warning, StringOps.countElementsAsString(WARNING.count, "warning") + " found")
if (ERROR.count > 0)
printMessage(LogLevel.Error, StringOps.countElementsAsString(ERROR.count, "error") + " found")
}

/**
* Prints the message at the severity level.
* @param level Severity level.
* @param message Message content.
*/
private def printMessage(level: LogLevel, message: String): Unit = {
if (!quiet) {
level match {
case LogLevel.Debug => logger.debug(message)
case LogLevel.Info => logger.info(message)
case LogLevel.Warning => logger.warning(message)
case LogLevel.Error => logger.error(message)
case LogLevel.Fatal => logger.fatal(message)
case _ => throw new DagrScriptManagerException(s"Could not determine log level: $level")
}
private class DagrReporter(val settings: Settings) extends FilteringReporter with LazyLogging {
var errors: Int = 0
var warnings: Int = 0
var infos: Int = 0

override def doReport(pos: Position, msg: String, severity: Severity): Unit = {
severity match {
case Reporter.INFO =>
infos += 1
logger.info(msg)
case Reporter.WARNING =>
warnings += 1
logger.warning(msg)
case Reporter.ERROR =>
errors += 1
logger.error(msg)
}
}
}
Expand All @@ -156,7 +89,7 @@ private[core] class DagrScriptManager extends LazyLogging {
* Compiles and loads the scripts in the files into the current classloader.
* Heavily based on scala/src/compiler/scala/tools/ant/Scalac.scala
*/
def loadScripts(scripts: Iterable[Path], tempDir: Path, quiet: Boolean = true): Unit = {
def loadScripts(scripts: Iterable[Path], tempDir: Path): Unit = {
// Make sure the scripts actually exist and we can write to the tempDir
Io.assertReadable(scripts)
Io.assertWritableDirectory(tempDir)
Expand All @@ -173,29 +106,26 @@ private[core] class DagrScriptManager extends LazyLogging {
settings.classpath.append(url.getPath)
})

val reporter = new DagrReporter(settings, quiet)
val reporter = new DagrReporter(settings)
val compiler: Global = new Global(settings, reporter)
val run = new compiler.Run

if (!quiet) {
logger.info("Compiling %s Dagr Script%s".format(scripts.size, plural(scripts.size)))
logger.debug("Compilation directory: " + settings.outdir.value)
}
logger.info("Compiling %s Dagr Script%s".format(scripts.size, plural(scripts.size)))
logger.debug("Compilation directory: " + settings.outdir.value)
run.compileFiles(scripts.toList.map(script => new PlainFile(script.toFile)))

// add `tempDir` to the classpath
if (!reporter.hasErrors) addToClasspath(urls = Seq(tempDir.toUri.toURL))

reporter.printSummary()
if (reporter.hasErrors) {
val msg = "Compile of %s failed with %d error%s".format(scripts.mkString(", "), reporter.ERROR.count, plural(reporter.ERROR.count))
val msg = "Compile of %s failed with %d error%s".format(scripts.mkString(", "), reporter.errors, plural(reporter.errors))
throw new DagrScriptManagerException(msg)
}
else if (reporter.WARNING.count > 0) {
if (!quiet) logger.warning("Compile succeeded with %d warning%s".format(reporter.WARNING.count, plural(reporter.WARNING.count)))
else if (reporter.warnings > 0) {
logger.warning("Compile succeeded with %d warning%s".format(reporter.warnings, plural(reporter.warnings)))
}
else {
if (!quiet) logger.info("Compilation complete")
logger.info("Compilation complete")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.1.6
sbt.version=1.6.2
17 changes: 9 additions & 8 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
resolvers += Resolver.url("fix-sbt-plugin-releases", url("http://dl.bintray.com/sbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns)
resolvers += Resolver.url("fix-sbt-plugin-releases", url("https://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.6.0")
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")
addDependencyTreePlugin

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.10")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.4")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")

0 comments on commit 09ca816

Please sign in to comment.