Skip to content

Scala 2.12.0-RC1 support. #177

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
language: scala
jdk: oraclejdk8

scala:
- 2.11.4
- 2.10.6
- 2.11.8
- 2.12.0-RC1

script:
- "sbt clean test"
jdk:
- oraclejdk7
- sbt ++$TRAVIS_SCALA_VERSION test

cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt

before_cache:
- find "$HOME/.sbt/" -name '*.lock' -print0 | xargs -0 rm
- find "$HOME/.ivy2/" -name 'ivydata-*.properties' -print0 | xargs -0 rm
49 changes: 0 additions & 49 deletions project/EnvSupport.scala

This file was deleted.

65 changes: 34 additions & 31 deletions project/Scoverage.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import sbt.Keys._
import sbt._
import sbtrelease.ReleasePlugin
import sbtrelease.ReleasePlugin.ReleaseKeys
import com.typesafe.sbt.pgp.PgpKeys
import org.scalajs.sbtplugin.cross.CrossProject
import org.scalajs.sbtplugin.cross.CrossType
Expand All @@ -11,24 +9,24 @@ import org.scalajs.sbtplugin.ScalaJSPlugin.autoImport._
object Scoverage extends Build {

val Org = "org.scoverage"
val Scala = "2.11.7"
val MockitoVersion = "1.9.5"
val ScalatestVersion = "3.0.0-M15"
val MockitoVersion = "1.10.19"
val ScalatestVersion = "3.0.0"

lazy val LocalTest = config("local") extend Test

val appSettings = Seq(
organization := Org,
scalaVersion := Scala,
crossScalaVersions := Seq("2.10.6", "2.11.7"),
scalaVersion := "2.11.8",
crossScalaVersions := Seq("2.10.6", scalaVersion.value, "2.12.0-RC1"),
fork in Test := false,
publishMavenStyle := true,
publishArtifact in Test := false,
parallelExecution in Test := false,
sbtrelease.ReleasePlugin.autoImport.releasePublishArtifactsAction := PgpKeys.publishSigned.value,
sbtrelease.ReleasePlugin.autoImport.releaseCrossBuild := true,
scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8"),
resolvers := ("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2") +: resolvers.value,
concurrentRestrictions in Global += Tags.limit(Tags.Test, 1),
javacOptions := Seq("-source", "1.6", "-target", "1.6"),
publishTo <<= version {
(v: String) =>
val nexus = "https://oss.sonatype.org/"
Expand Down Expand Up @@ -61,27 +59,22 @@ object Scoverage extends Build {
pomIncludeRepository := {
_ => false
}
) ++ ReleasePlugin.releaseSettings ++ Seq(
ReleaseKeys.crossBuild := true,
ReleaseKeys.publishArtifactsAction := PgpKeys.publishSigned.value
)

lazy val root = Project("scalac-scoverage", file("."))
.settings(name := "scalac-scoverage")
.settings(appSettings: _*)
.settings(publishArtifact := false)
.settings(javaOptions += "-XX:MaxMetaspaceSize=2048m")
.aggregate(plugin, runtime.jvm, runtime.js)

lazy val runtime = CrossProject("scalac-scoverage-runtime", file("scalac-scoverage-runtime"), CrossType.Full)
.settings(name := "scalac-scoverage-runtime")
.settings(appSettings: _*)
.jvmSettings(
libraryDependencies ++= Seq(
"org.mockito" % "mockito-all" % MockitoVersion % "test",
"org.scalatest" %% "scalatest" % ScalatestVersion % "test"
),
javaOptions += "-XX:MaxMetaspaceSize=2048m"
"org.mockito" % "mockito-all" % MockitoVersion % Test,
"org.scalatest" %% "scalatest" % ScalatestVersion % Test
)
)
.jsSettings(
libraryDependencies += "org.scalatest" %%% "scalatest" % ScalatestVersion,
Expand All @@ -92,26 +85,36 @@ object Scoverage extends Build {
lazy val `scalac-scoverage-runtimeJS` = runtime.js

lazy val plugin = Project("scalac-scoverage-plugin", file("scalac-scoverage-plugin"))
.dependsOn(`scalac-scoverage-runtimeJVM` % "test")
.dependsOn(`scalac-scoverage-runtimeJVM` % Test)
.settings(name := "scalac-scoverage-plugin")
.settings(appSettings: _*)
.settings(javaOptions += "-XX:MaxMetaspaceSize=2048m")
.settings(crossVersionSharedSources)
.settings(libraryDependencies ++= Seq(
"org.mockito" % "mockito-all" % MockitoVersion % "test",
"org.scalatest" %% "scalatest" % ScalatestVersion % "test",
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
"org.joda" % "joda-convert" % "1.6" % "test",
"joda-time" % "joda-time" % "2.3" % "test",
"com.typesafe.scala-logging" %% "scala-logging-slf4j" % "2.1.2" % "test"
)).settings(libraryDependencies ++= {
"org.mockito" % "mockito-all" % MockitoVersion % Test,
"org.scalatest" %% "scalatest" % ScalatestVersion % Test,
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
"org.joda" % "joda-convert" % "1.8.1" % Test,
"joda-time" % "joda-time" % "2.9.4" % Test
)).settings(libraryDependencies ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, scalaMajor)) if scalaMajor == 11 =>
EnvSupport.setEnv("CrossBuildScalaVersion", "2.11.7")
Seq("org.scala-lang.modules" %% "scala-xml" % "1.0.4")
case Some((2, scalaMajor)) if scalaMajor > 10 =>
Seq("org.scala-lang.modules" %% "scala-xml" % "1.0.5")
case _ =>
EnvSupport.setEnv("CrossBuildScalaVersion", "2.10.6")
Nil
Seq()
}
})

lazy val crossVersionSharedSources: Seq[Setting[_]] =
Seq(Compile, Test).map { sc =>
(unmanagedSourceDirectories in sc) ++= {
(unmanagedSourceDirectories in sc ).value.map { dir: File =>
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, y)) if y == 10 => new File(dir.getPath + "_2.10")
case Some((2, y)) if y >= 11 => new File(dir.getPath + "_2.11+")
}
}
}
}

}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.11
sbt.version=0.13.13-M1
11 changes: 4 additions & 7 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.3.2")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.5")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.9")
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.3")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.12")
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ class CoberturaXmlWriterTest extends FunSuite with BeforeAndAfter with OneInstan
writer.write(coverage)

val xml = XML.loadFile(fileIn(dir))
import XmlCompat._

assert(xml \\ "coverage" \@ "line-rate" === "0.33", "line-rate")
assert(xml \\ "coverage" \@ "branch-rate" === "0.50", "branch-rate")

assert((xml \\ "coverage" \@ "line-rate") === "0.33", "line-rate")
assert((xml \\ "coverage" \@ "branch-rate") === "0.50", "branch-rate")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scoverage
import java.io.{File, FileWriter}
import java.util.UUID

import org.scalatest.mock.MockitoSugar
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{FreeSpec, Matchers, OneInstancePerTest}

/** @author Stephen Samuel */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ class LocationCompiler(settings: scala.tools.nsc.Settings, reporter: scala.tools
class LocationSetter(val global: Global) extends PluginComponent with TypingTransformers with Transform {

override val phaseName: String = "location-setter"
override val runsAfter: List[String] = List("typer")
override val runsBefore = List[String]("patmat")
override val runsRightAfter = Some("typer")
override val runsAfter = List("typer")
override val runsBefore = List[String]("patmat")

override protected def newTransformer(unit: global.CompilationUnit): global.Transformer = new Transformer(unit)
class Transformer(unit: global.CompilationUnit) extends TypingTransformer(unit) {
Expand All @@ -44,35 +45,7 @@ class LocationCompiler(settings: scala.tools.nsc.Settings, reporter: scala.tools
}

override def computeInternalPhases() {
val phs = List(
syntaxAnalyzer -> "parse source into ASTs, perform simple desugaring",
analyzer.namerFactory -> "resolve names, attach symbols to named trees",
analyzer.packageObjects -> "load package objects",
analyzer.typerFactory -> "the meat and potatoes: type the trees",
locationSetter -> "sets locations",
patmat -> "translate match expressions",
superAccessors -> "add super accessors in traits and nested classes",
extensionMethods -> "add extension methods for inline classes",
pickler -> "serialize symbol tables",
refChecks -> "reference/override checking, translate nested objects",
uncurry -> "uncurry, translate function values to anonymous classes",
tailCalls -> "replace tail calls by jumps",
specializeTypes -> "@specialized-driven class and method specialization",
explicitOuter -> "this refs to outer pointers, translate patterns",
erasure -> "erase types, add interfaces for traits",
postErasure -> "clean up erased inline classes",
lazyVals -> "allocate bitmaps, translate lazy vals into lazified defs",
lambdaLift -> "move nested functions to top level",
constructors -> "move field definitions into constructors",
mixer -> "mixin composition",
cleanup -> "platform-specific cleanups, generate reflective calls",
genicode -> "generate portable intermediate code",
inliner -> "optimization: do inlining",
inlineExceptionHandlers -> "optimization: inline exception handlers",
closureElimination -> "optimization: eliminate uncalled closures",
deadCode -> "optimization: eliminate dead code",
terminal -> "The last phase in the compiler chain"
)
phs foreach (addToPhasesSet _).tupled
super.computeInternalPhases()
addToPhasesSet(locationSetter, "sets locations")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scoverage

import org.scalatest.mock.MockitoSugar
import org.scalatest.mockito.MockitoSugar
import org.scalatest._

/** @author Stephen Samuel */
Expand Down Expand Up @@ -76,29 +76,13 @@ class PluginASTSupportTest
assert(!compiler.reporter.hasWarnings)
}

// https://github.com/skinny-framework/skinny-framework/issues/97
test("macro range positions should not break plugin") {
val compiler = ScoverageCompiler.default
compiler.addToClassPath("org.slf4j", "slf4j-api", "1.7.7")
compiler.addToClassPath("com.typesafe.scala-logging", "scala-logging-api_" + ScoverageCompiler.ShortScalaVersion, "2.1.2")
compiler.addToClassPath("com.typesafe.scala-logging", "scala-logging-slf4j_" + ScoverageCompiler.ShortScalaVersion, "2.1.2")
compiler.compileCodeSnippet( """import com.typesafe.scalalogging.slf4j.StrictLogging
|
|object MacroTest extends StrictLogging {
| println("Hello")
| logger.info("will break")
|} """.stripMargin)
assert(!compiler.reporter.hasErrors)
assert(!compiler.reporter.hasWarnings)
}

// https://github.com/scoverage/scalac-scoverage-plugin/issues/45
test("compile final vals in annotations") {
val compiler = ScoverageCompiler.default
compiler.compileCodeSnippet( """object Foo {
| final val foo = 1L
|}
|@SerialVersionUID(value = Foo.foo)
|@SerialVersionUID(Foo.foo)
|class Bar
|""".stripMargin)
assert(!compiler.reporter.hasErrors)
Expand Down
Loading