Skip to content

Commit

Permalink
Merge pull request #3243 from scala-steward-org/topic/refactorings-bs…
Browse files Browse the repository at this point in the history
…p-branch

Minimize diff to BSP branch
  • Loading branch information
fthomas authored Dec 13, 2023
2 parents e1c2ccd + f749ac1 commit 29dcd58
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 29dcd58

Please sign in to comment.