Skip to content

Commit

Permalink
Scoverage: improve classpath override to the minimal (#3122)
Browse files Browse the repository at this point in the history
The previous version the `ScoverageTests.runClasspath` was more modified
and reorganized.
In this version, only the outer complied classes folder is replaced (in
place) by the outer.scoverage complied classes folder.
An additional runtime dependency is also added:
`org.scoverage::scalac-scoverage-runtime`.
All duplicated entries in the classpath are also removed.

Pull request: #3122
---------

Co-authored-by: Tobias Roeser <[email protected]>
  • Loading branch information
romain-gilles-ultra and lefou authored Apr 19, 2024
1 parent 43c192a commit eaacfbc
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions contrib/scoverage/src/mill/contrib/scoverage/ScoverageModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,18 @@ trait ScoverageModule extends ScalaModule { outer: ScalaModule =>
trait ScoverageTests extends ScalaTests {

/**
* Alter classfiles and resources from upstream modules and dependencies
* by removing the ones from outer.localRunClasspath() and replacing them
* with outer.scoverage.localRunClasspath()
* Alter classpath from upstream modules by replacing in-place outer module
* classes folder by the outer.scoverage classes folder and adding the
* scoverage runtime dependency.
*/
override def runClasspath: T[Seq[PathRef]] = T {
val outerLocalRunClasspath = outer.localRunClasspath().toSet
super.runClasspath().filterNot(
outerLocalRunClasspath
) ++
outer.scoverage.localRunClasspath() ++
resolveDeps(T.task {
outer.scoverageRuntimeDeps().map(bindDependency())
})()
val outerClassesPath = outer.compile().classes
val outerScoverageClassesPath = outer.scoverage.compile().classes
(super.runClasspath().map { path =>
if (outerClassesPath == path) outerScoverageClassesPath else path
} ++ resolveDeps(T.task {
outer.scoverageRuntimeDeps().map(bindDependency())
})()).distinct
}
}
}

0 comments on commit eaacfbc

Please sign in to comment.