Skip to content

Commit fe21a51

Browse files
authored
Merge pull request #324 from domizei385/updates
2 parents aaff04c + eb9fba9 commit fe21a51

File tree

21 files changed

+118
-147
lines changed

21 files changed

+118
-147
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@ jobs:
1515
java: [ '11' ]
1616
scala: [
1717
{ version: '2.12.13' },
18-
{ version: '2.12.12' },
19-
{ version: '2.12.11' },
20-
{ version: '2.12.10' },
21-
{ version: '2.13.4' },
22-
{ version: '2.13.3' },
23-
{ version: '2.13.2' },
24-
{ version: '2.13.1' },
25-
{ version: '2.13.0' }
18+
{ version: '2.12.10' }
2619
]
2720
steps:
2821
- name: checkout the repo

README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@ discussion on scoverage.
1515

1616
Make sure your SBT version in project/build.properties:
1717
```
18-
sbt.version = 0.13.17
19-
```
20-
or
21-
```
22-
sbt.version = 1.1.1
18+
sbt.version = 1.2.8
2319
```
2420

2521
Add the plugin in project/plugins.sbt:
2622
```scala
27-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
23+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.2")
2824
```
2925

3026
Run the tests with enabled coverage:
@@ -54,6 +50,10 @@ turn it back off when you're done running reports, use the `coverageOff` command
5450

5551
Sample project with scoverage in both sbt and maven - [the scoverage samples project](https://github.com/scoverage/sbt-scoverage-samples).
5652

53+
## Notes on upgrading to version 1.6.x
54+
* ´coverageCleanSubprojectFiles´ key has been removed
55+
* scala version 2.12+ is required as a minimum (due to scoverage suppport)
56+
5757
## Notes on upgrading to version 1.6.0
5858

5959
* `coverageAggregate` aggregates raw coverage data, not coverage xml reports for modules.
@@ -117,14 +117,6 @@ coverageFailOnMinimum := true
117117
These settings will be enforced when the reports are generated.
118118
If you generate an aggregate report using `coverageAggregate` then these settings will apply to that report.
119119

120-
## Highlighting
121-
122-
If you are using Scala 2.11.1 or less, then highlighting will not work (due to this bug which was fixed in 2.11.2 https://github.com/scala/scala/pull/3799). In that case you must disable highlighting by adding the following to your build:
123-
124-
```scala
125-
coverageHighlighting := false
126-
```
127-
128120
## Failing tests
129121
Scoverage does a lot of file writing behind the scenes in order to track which statements have been executed.
130122
If you are running into a scenario where your tests normally pass, but fail when scoverage is enabled, then the culprit can be one of the following:

build.sbt

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
11
name := "sbt-scoverage"
2-
32
organization := "org.scoverage"
43

5-
enablePlugins(SbtPlugin)
6-
7-
scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8")
8-
9-
resolvers ++= {
10-
if (isSnapshot.value) Seq(Resolver.sonatypeRepo("snapshots")) else Nil
11-
}
12-
13-
libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.0"
14-
15-
publishMavenStyle := true
16-
17-
publishArtifact in Test := false
4+
import sbt.ScriptedPlugin.autoImport.scriptedLaunchOpts
5+
import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._
186

19-
scriptedLaunchOpts ++= Seq(
20-
"-Xmx1024M",
21-
"-Dplugin.version=" + version.value
22-
)
23-
24-
import ReleaseTransformations._
257
releaseProcess := Seq[ReleaseStep](
268
checkSnapshotDependencies,
279
inquireVersions,
@@ -30,48 +12,67 @@ releaseProcess := Seq[ReleaseStep](
3012
setReleaseVersion,
3113
commitReleaseVersion,
3214
tagRelease,
33-
releaseStepCommandAndRemaining("^ publishSigned"),
15+
releaseStepCommandAndRemaining("publishSigned"),
3416
setNextVersion,
3517
commitNextVersion,
3618
pushChanges
3719
)
3820

39-
releaseCrossBuild := false
40-
41-
publishTo := {
42-
if (isSnapshot.value)
43-
Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
44-
else
45-
Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
46-
}
47-
48-
pomExtra := {
49-
<url>https://github.com/scoverage/sbt-scoverage</url>
50-
<licenses>
51-
<license>
52-
<name>Apache 2</name>
53-
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
54-
<distribution>repo</distribution>
55-
</license>
56-
</licenses>
57-
<scm>
58-
<url>git@github.com:scoverage/sbt-scoverage.git</url>
59-
<connection>scm:git@github.com:scoverage/sbt-scoverage.git</connection>
60-
</scm>
61-
<developers>
62-
<developer>
63-
<id>sksamuel</id>
64-
<name>sksamuel</name>
65-
<url>http://github.com/sksamuel</url>
66-
</developer>
67-
<developer>
68-
<id>gslowikowski</id>
69-
<name>Grzegorz Slowikowski</name>
70-
<url>http://github.com/gslowikowski</url>
71-
</developer>
72-
</developers>
73-
}
74-
75-
crossSbtVersions := Vector("0.13.18", "1.2.8")
21+
lazy val root = Project("sbt-scoverage", file("."))
22+
.enablePlugins(SbtPlugin)
23+
.settings(
24+
libraryDependencies ++= Seq(
25+
"org.scala-lang" % "scala-compiler" % scalaVersion.value % Compile
26+
),
27+
libraryDependencies += "org.scoverage" %% "scalac-scoverage-plugin" % "1.4.3" cross(CrossVersion.full),
28+
scalaVersion := "2.12.13",
29+
publishMavenStyle := true,
30+
publishConfiguration := publishConfiguration.value.withOverwrite(true),
31+
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true),
32+
releasePublishArtifactsAction := PgpKeys.publishSigned.value,
33+
Test / fork := false,
34+
Test / publishArtifact := false,
35+
Test / parallelExecution := false,
36+
scalacOptions := Seq("-unchecked", "-deprecation", "-feature", "-encoding", "utf8"),
37+
publishTo := {
38+
if (isSnapshot.value)
39+
Some("snapshots" at "https://oss.sonatype.org/content/repositories/snapshots")
40+
else
41+
Some("releases" at "https://oss.sonatype.org/service/local/staging/deploy/maven2")
42+
},
43+
resolvers ++= {
44+
if (isSnapshot.value) Seq(Resolver.sonatypeRepo("snapshots")) else Nil
45+
},
46+
scriptedLaunchOpts ++= Seq(
47+
"-Xmx1024M",
48+
"-Dplugin.version=" + version.value
49+
),
50+
pomExtra := {
51+
<url>https://github.com/scoverage/sbt-scoverage</url>
52+
<licenses>
53+
<license>
54+
<name>Apache 2</name>
55+
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
56+
<distribution>repo</distribution>
57+
</license>
58+
</licenses>
59+
<scm>
60+
<url>git@github.com:scoverage/sbt-scoverage.git</url>
61+
<connection>scm:git@github.com:scoverage/sbt-scoverage.git</connection>
62+
</scm>
63+
<developers>
64+
<developer>
65+
<id>sksamuel</id>
66+
<name>sksamuel</name>
67+
<url>http://github.com/sksamuel</url>
68+
</developer>
69+
<developer>
70+
<id>gslowikowski</id>
71+
<name>Grzegorz Slowikowski</name>
72+
<url>http://github.com/gslowikowski</url>
73+
</developer>
74+
</developers>
75+
}
76+
)
7677

7778
scalariformAutoformat := false

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.8
1+
sbt.version=1.5.1

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
44

55
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.1")
66

7-
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.7")
7+
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")

src/main/scala/scoverage/ScoverageKeys.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ object ScoverageKeys {
1515
lazy val coverageOutputXML = settingKey[Boolean]("enables xml report generation")
1616
lazy val coverageOutputHTML = settingKey[Boolean]("enables html report generation")
1717
lazy val coverageOutputDebug = settingKey[Boolean]("turn on the debug report")
18-
@deprecated("", "1.6.0")
19-
lazy val coverageCleanSubprojectFiles = settingKey[Boolean]("removes subproject data after an aggregation")
2018
lazy val coverageOutputTeamCity = settingKey[Boolean]("turn on teamcity reporting")
2119
lazy val coverageScalacPluginVersion = settingKey[String]("version of scalac-scoverage-plugin to use")
2220
}

src/main/scala/scoverage/ScoverageSbtPlugin.scala

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object ScoverageSbtPlugin extends AutoPlugin {
1111
val ScalacRuntimeArtifact = "scalac-scoverage-runtime"
1212
val ScalacPluginArtifact = "scalac-scoverage-plugin"
1313
// this should match the version defined in build.sbt
14-
val DefaultScoverageVersion = "1.4.1"
14+
val DefaultScoverageVersion = "1.4.3"
1515
val autoImport = ScoverageKeys
1616
lazy val ScoveragePluginConfig = config("scoveragePlugin").hide
1717

@@ -34,40 +34,39 @@ object ScoverageSbtPlugin extends AutoPlugin {
3434
coverageOutputHTML := true,
3535
coverageOutputCobertura := true,
3636
coverageOutputDebug := false,
37-
coverageCleanSubprojectFiles := true,
3837
coverageOutputTeamCity := false,
3938
coverageScalacPluginVersion := DefaultScoverageVersion
4039
)
4140

4241
override def buildSettings: Seq[Setting[_]] = super.buildSettings ++
43-
addCommandAlias("coverage", ";set coverageEnabled in ThisBuild := true") ++
44-
addCommandAlias("coverageOn", ";set coverageEnabled in ThisBuild := true") ++
45-
addCommandAlias("coverageOff", ";set coverageEnabled in ThisBuild := false")
42+
addCommandAlias("coverage", ";set ThisBuild / coverageEnabled := true") ++
43+
addCommandAlias("coverageOn", ";set ThisBuild / coverageEnabled := true") ++
44+
addCommandAlias("coverageOff", ";set ThisBuild / coverageEnabled := false")
4645

4746
override def projectSettings: Seq[Setting[_]] = Seq(
4847
ivyConfigurations += ScoveragePluginConfig,
4948
coverageReport := coverageReport0.value,
5049
coverageAggregate := coverageAggregate0.value,
51-
aggregate in coverageAggregate := false
50+
coverageAggregate / aggregate := false
5251
) ++ coverageSettings ++ scalacSettings
5352

5453
private lazy val coverageSettings = Seq(
55-
libraryDependencies ++= {
56-
if (coverageEnabled.value)
54+
libraryDependencies ++= {
55+
if (coverageEnabled.value) {
5756
Seq(
5857
// We only add for "compile" because of macros. This setting could be optimed to just "test" if the handling
5958
// of macro coverage was improved.
6059
(OrgScoverage %% (scalacRuntime(libraryDependencies.value)) % coverageScalacPluginVersion.value).cross(CrossVersion.full),
6160
// We don't want to instrument the test code itself, nor add to a pom when published with coverage enabled.
6261
(OrgScoverage %% ScalacPluginArtifact % coverageScalacPluginVersion.value % ScoveragePluginConfig.name).cross(CrossVersion.full)
6362
)
64-
else
63+
} else
6564
Nil
6665
}
6766
)
6867

6968
private lazy val scalacSettings = Seq(
70-
scalacOptions in(Compile, compile) ++= {
69+
Compile / compile / scalacOptions ++= {
7170
val updateReport = update.value
7271
if (coverageEnabled.value) {
7372
val scoverageDeps: Seq[File] = updateReport matching configurationFilter(ScoveragePluginConfig.name)
@@ -97,7 +96,7 @@ object ScoverageSbtPlugin extends AutoPlugin {
9796
private def optionalScalaJsSuffix(deps: Seq[ModuleID]): String = {
9897
val sjsClassifier = deps.collectFirst {
9998
case moduleId if moduleId.organization == "org.scala-js" && moduleId.name == "scalajs-library" => moduleId.revision
100-
}.map(_.take(3)).map(sjsVersion => "_sjs" + sjsVersion)
99+
}.map(_.take(1)).map(sjsVersion => "_sjs" + sjsVersion)
101100

102101
sjsClassifier getOrElse ""
103102
}
@@ -113,14 +112,14 @@ object ScoverageSbtPlugin extends AutoPlugin {
113112
case Some(cov) =>
114113
writeReports(
115114
target,
116-
(sourceDirectories in Compile).value,
115+
(Compile / sourceDirectories).value,
117116
cov,
118117
coverageOutputCobertura.value,
119118
coverageOutputXML.value,
120119
coverageOutputHTML.value,
121120
coverageOutputDebug.value,
122121
coverageOutputTeamCity.value,
123-
sourceEncoding((scalacOptions in (Compile)).value),
122+
sourceEncoding((Compile / scalacOptions).value),
124123
log)
125124

126125
checkCoverage(cov, log, coverageMinimum.value, coverageFailOnMinimum.value)
@@ -144,7 +143,7 @@ object ScoverageSbtPlugin extends AutoPlugin {
144143
coverageOutputHTML.value,
145144
coverageOutputDebug.value,
146145
coverageOutputTeamCity.value,
147-
sourceEncoding((scalacOptions in (Compile)).value),
146+
sourceEncoding((Compile / scalacOptions).value),
148147
log)
149148
val cfmt = cov.statementCoverageFormatted
150149
log.info(s"Aggregation complete. Coverage was [$cfmt]")

src/sbt-test/scoverage/aggregate-only/build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
lazy val commonSettings = Seq(
77
organization := "org.scoverage",
88
version := "0.1.0",
9-
scalaVersion := "2.12.8"
9+
scalaVersion := "2.12.13"
1010
)
1111

1212
lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test"
@@ -34,7 +34,7 @@ lazy val root = (project in file("."))
3434
partB
3535
)
3636

37-
resolvers in ThisBuild ++= {
38-
if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
37+
ThisBuild / resolvers ++= {
38+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
3939
else Seq.empty
4040
}

src/sbt-test/scoverage/aggregate/build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
lazy val commonSettings = Seq(
77
organization := "org.scoverage",
88
version := "0.1.0",
9-
scalaVersion := "2.12.8"
9+
scalaVersion := "2.12.13"
1010
)
1111

1212
lazy val specs2Lib = "org.specs2" %% "specs2" % "2.5" % "test"
@@ -34,7 +34,7 @@ lazy val root = (project in file("."))
3434
partB
3535
)
3636

37-
resolvers in ThisBuild ++= {
38-
if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
37+
ThisBuild / resolvers ++= {
38+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
3939
else Seq.empty
4040
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version := "0.1"
22

3-
scalaVersion := "2.12.8"
3+
scalaVersion := "2.12.13"
44

55
libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
66

@@ -9,6 +9,6 @@ coverageMinimum := 80
99
coverageFailOnMinimum := true
1010

1111
resolvers ++= {
12-
if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
12+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
1313
else Seq.empty
1414
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version := "0.1"
22

3-
scalaVersion := "2.12.8"
3+
scalaVersion := "2.12.13"
44

55
libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
66

@@ -9,6 +9,6 @@ coverageMinimum := 80
99
coverageFailOnMinimum := true
1010

1111
resolvers ++= {
12-
if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
12+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
1313
else Seq.empty
1414
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version := "0.1"
22

3-
scalaVersion := "2.12.8"
3+
scalaVersion := "2.12.13"
44

55
libraryDependencies += "org.specs2" %% "specs2" % "2.5" % "test"
66

@@ -9,6 +9,6 @@ coverageMinimum := 80
99
coverageFailOnMinimum := true
1010

1111
resolvers ++= {
12-
if (sys.props.get("plugin.version").map(_.endsWith("-SNAPSHOT")).getOrElse(false)) Seq(Resolver.sonatypeRepo("snapshots"))
12+
if (sys.props.get("plugin.version").exists(_.endsWith("-SNAPSHOT"))) Seq(Resolver.sonatypeRepo("snapshots"))
1313
else Seq.empty
1414
}

0 commit comments

Comments
 (0)