Skip to content

Commit

Permalink
Refactor to opacity instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Mikhaylov committed Aug 6, 2024
1 parent 4305612 commit 7234eb4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/main/scala/com/elarib/PartialSbtPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import sbt._

object BuildKeys {
val partialSbtExcludedFiles = sbt.settingKey[Seq[sbt.File]]("Files that should be excluded from analysis.")
val partialSbtExcludedProject: SettingKey[Unit] = sbt.settingKey[Unit]("Exclude project from analysis.")
val partialSbtOpaqueProject: SettingKey[Unit] = sbt.settingKey[Unit]("Changes in this project will not contribute to invalidation of its dependent projects.")
}

object PartialSbtPlugin extends AutoPlugin {
Expand Down Expand Up @@ -84,8 +84,8 @@ object PartialSbtPlugin extends AutoPlugin {
projectMap.values.toSeq
.sortBy(_.id)
case Nil =>
def isIncludedInAnalysis(resolvedProject: ResolvedProject): Boolean =
!resolvedProject.settings.exists(_.key.key == BuildKeys.partialSbtExcludedProject.key)
def isTransparentProject(resolvedProject: ResolvedProject): Boolean =
!resolvedProject.settings.exists(_.key.key == BuildKeys.partialSbtOpaqueProject.key)

val reverseDependencyMap: DependencyMap[ResolvedProject] = buildDeps
.foldLeft[DependencyMap[ResolvedProject]](Map.empty) { (acc, dependency) =>
Expand All @@ -101,12 +101,12 @@ object PartialSbtPlugin extends AutoPlugin {
}
}
.filterKeys { projectRef =>
projectMap.get(projectRef).exists(isIncludedInAnalysis)
projectMap.get(projectRef).exists(isTransparentProject)
}

val modulesWithPath: Seq[(ProjectRef, ResolvedProject)] =
allProjectRefs.filter { case (_, resolvedProject) =>
isIncludedInAnalysis(resolvedProject) && resolvedProject.base != baseDir
resolvedProject.base != baseDir
}

val diffsFiles: Seq[sbt.File] = changeGetter.changes.filterNot(f => isFileExcluded(baseDir)(f, excludedFiles))
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/test-projects/multi-module-project/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ lazy val firstLib = sbt
lazy val secondLib = sbt
.Project("lib-2", libs / "lib-2")
.settings(settings("lib-2"))
.settings(com.elarib.BuildKeys.partialSbtExcludedProject := ())
.settings(com.elarib.BuildKeys.partialSbtOpaqueProject := ())

//Tools
lazy val firstTool = sbt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
6 projects have been changed
7 projects have been changed
lib-1
lib-2
service-1
service-3
service-4
Expand Down

0 comments on commit 7234eb4

Please sign in to comment.