Skip to content

Commit

Permalink
Minimize diff to BSP branch
Browse files Browse the repository at this point in the history
This contains two small refactorings which minimizes the diff of the BSP
branch (#3236).
  • Loading branch information
fthomas committed Dec 13, 2023
1 parent e1c2ccd commit f749ac1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,7 @@ final class MillAlg[F[_]](defaultResolver: Resolver)(implicit
for {
buildRootDir <- workspaceAlg.buildRootDir(buildRoot)
millBuildVersion <- getMillVersion(buildRootDir)
extracted <-
if (isMillVersionGreaterOrEqual011(millBuildVersion)) runMill(buildRootDir)
else runMillUnder011(buildRootDir, millBuildVersion)
parsed <- F.fromEither(
parser.parseModules(extracted.dropWhile(!_.startsWith("{")).mkString("\n"))
)
dependencies = parsed.map(module => Scope(module.dependencies, module.repositories))
dependencies <- getProjectDependencies(buildRootDir, millBuildVersion)
millBuildDeps = millBuildVersion.toSeq.map(version =>
Scope(List(millMainArtifact(version)), List(defaultResolver))
)
Expand All @@ -74,6 +68,20 @@ final class MillAlg[F[_]](defaultResolver: Resolver)(implicit
}
} yield dependencies ++ millBuildDeps ++ millPluginDeps

private def getProjectDependencies(
buildRootDir: File,
millBuildVersion: Option[Version]
): F[List[Scope.Dependencies]] =
for {
extracted <-
if (isMillVersionGreaterOrEqual011(millBuildVersion)) runMill(buildRootDir)
else runMillUnder011(buildRootDir, millBuildVersion)
parsed <- F.fromEither(
parser.parseModules(extracted.dropWhile(!_.startsWith("{")).mkString("\n"))
)
dependencies = parsed.map(module => Scope(module.dependencies, module.repositories))
} yield dependencies

override def runMigration(buildRoot: BuildRoot, migration: ScalafixMigration): F[Unit] =
logger.warn(
s"Scalafix migrations are currently not supported in $name projects, see https://github.com/scala-steward-org/scala-steward/issues/2838 for details"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ final class ScalaCliAlg[F[_]](implicit
}

override def getDependencies(buildRoot: BuildRoot): F[List[Scope.Dependencies]] =
getDependenciesViaSbtExport(buildRoot)

private def getDependenciesViaSbtExport(buildRoot: BuildRoot): F[List[Scope.Dependencies]] =
for {
buildRootDir <- workspaceAlg.buildRootDir(buildRoot)
exportDir = "tmp-sbt-build-for-scala-steward"
Expand Down

0 comments on commit f749ac1

Please sign in to comment.