Skip to content

Commit

Permalink
Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Mikhaylov committed Aug 6, 2024
1 parent 94f17ac commit 7fcdb82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 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.internal.BuildDependencies.DependencyMap

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
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 7fcdb82

Please sign in to comment.