Skip to content

Commit 8a445e3

Browse files
committed
Fixed bug with absolute paths
1 parent 3cac9e5 commit 8a445e3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scalac-scoverage-plugin/src/main/scala/scoverage/report/ScoverageHtmlWriter.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,23 @@ class ScoverageHtmlWriter(sourceDirectory: File, outputDir: File) {
2929
// package overview files are written out using a directory structure that respects the directory name
3030
// that means package com.example declared in a class at src/main/scala/mystuff/MyClass.scala will be written
3131
// to com/example/package.html
32-
val file = new File(outputDir.getAbsolutePath, pkg.name.replace("<empty>", "(empty)").replace('.', '/') + "/package.html")
32+
// this is because a single class may have multiple packages so we cannot use original/path/package.html as
33+
// they might clash
34+
val packageFile = new File(pkg.name.replace("<empty>", "(empty)").replace(".", File.separator), "package.html")
35+
val file = new File(outputDir, packageFile.getPath)
3336
file.getParentFile.mkdirs()
3437
IOUtils.writeToFile(file, packageOverview(pkg).toString)
3538
pkg.files.foreach(write(_, file.getParentFile))
3639
}
3740

3841
private def write(mfile: MeasuredFile, dir: File): Unit = {
3942
// each highlighted file is written out using the same structure as the original file.
40-
val file = new File(relativeSource(mfile.source))
43+
val file = new File(outputDir, relativeSource(mfile.source))
4144
file.getParentFile.mkdirs()
42-
IOUtils.writeToFile(file, _file(mfile).toString)
45+
IOUtils.writeToFile(file, filePage(mfile).toString)
4346
}
4447

45-
private def _file(mfile: MeasuredFile): Node = {
48+
private def filePage(mfile: MeasuredFile): Node = {
4649
val filename = relativeSource(mfile.source) + ".html"
4750
val css =
4851
"table.codegrid { font-family: monospace; font-size: 12px; width: auto!important; }" +

0 commit comments

Comments
 (0)