aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Kirillov <darthorimar@users.noreply.github.com>2017-06-24 19:00:29 +0300
committerIlya Kirillov <darthorimar@users.noreply.github.com>2017-06-24 19:00:29 +0300
commit76c5cd2135cf78e503f40cf9192d0302cd4cec90 (patch)
treed0a49803f5c14a1ac59a6171dae13fe92f7f2a61
parentb3d5c8a0230d7068a7d8c60063b08fed16783e5f (diff)
downloadcbt-76c5cd2135cf78e503f40cf9192d0302cd4cec90.tar.gz
cbt-76c5cd2135cf78e503f40cf9192d0302cd4cec90.tar.bz2
cbt-76c5cd2135cf78e503f40cf9192d0302cd4cec90.zip
Filter common childs in dirs
-rw-r--r--stage2/plugins/ExportBuildInformation.scala20
1 files changed, 17 insertions, 3 deletions
diff --git a/stage2/plugins/ExportBuildInformation.scala b/stage2/plugins/ExportBuildInformation.scala
index 6a22363..be61609 100644
--- a/stage2/plugins/ExportBuildInformation.scala
+++ b/stage2/plugins/ExportBuildInformation.scala
@@ -2,6 +2,7 @@ package cbt
import cbt._
import java.io._
+import java.nio.file._
import scala.xml._
trait ExportBuildInformation { self: BaseBuild =>
@@ -100,10 +101,8 @@ object BuildInformation {
val s = build.sources
.filter(_.exists)
.map(handleSource)
- .filter(_.getName != "target") //Dirty hack for cbt's sources
- .distinct
if (s.nonEmpty)
- s
+ commonParents(s)
else
Seq(build.projectDirectory)
}
@@ -122,6 +121,21 @@ object BuildInformation {
)
}
+ private def commonParents(paths: Seq[File]): Seq[File] = { //Too slow O(n^2)
+ val buffer = scala.collection.mutable.ListBuffer.empty[Path]
+ val sorted = paths
+ .map(_.toPath.toAbsolutePath)
+ .sortWith(_.getNameCount < _.getNameCount)
+ for (x <- sorted) {
+ if (!buffer.exists(x.startsWith)) {
+ buffer += x
+ }
+ }
+ buffer
+ .toList
+ .map(_.toFile)
+ }
+
private def collectLazyBuilds(dependency: Dependency): Option[BaseBuild] =
dependency match {
case l: LazyDependency =>