Skip to content

Commit

Permalink
Merge pull request #35 from eed3si9n/wip/cache
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n authored Feb 2, 2021
2 parents 45b860f + fe4bd89 commit c3b5721
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import scala.concurrent.ExecutionContext
import scala.util.Try

import coursier.cache.ArtifactError
import coursier.cache.CacheDefaults
import coursier.cache.CachePolicy
import coursier.cache.FileCache
import coursier.core.Dependency
Expand Down Expand Up @@ -46,6 +47,7 @@ import multiversion.resolvers.Sha256
case class ExportCommand(
lint: Boolean = true,
outputPath: Path = Paths.get("3rdparty", "jvm_deps.bzl"),
cache: Option[Path] = None,
@Inline
lintCommand: LintCommand = LintCommand()
) extends Command {
Expand All @@ -58,7 +60,7 @@ case class ExportCommand(
}
def runResult(thirdparty: ThirdpartyConfig): Result[Unit] = {
withThreadPool[Result[Unit]] { threads =>
val cache: FileCache[Task] = FileCache().noCredentials
val coursierCache: FileCache[Task] = FileCache().noCredentials
.withCachePolicies(
List(
// first, use what's available locally
Expand All @@ -67,16 +69,20 @@ case class ExportCommand(
CachePolicy.Update
)
)
.withLocation(cache match {
case Some(c) => c.toFile
case _ => CacheDefaults.location
})
.withTtl(scala.concurrent.duration.Duration.Inf)
.withPool(threads.downloadPool)
.withChecksums(Nil)
for {
index <- resolveDependencies(thirdparty, cache)
index <- resolveDependencies(thirdparty, coursierCache)
_ <- {
if (lint) lintPostResolution(index)
else ValueResult(())
}
output <- generateBzlFile(index, cache)
output <- generateBzlFile(index, coursierCache)
_ = app.err.println(Docs.successMessage(s"Generated '$output'"))
lint <-
if (lint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ final case class PantsExportCommand(
@PositionalArguments()
pantsTargets: List[String] = List("3rdparty/jvm::"),
cwd: Option[Path] = None,
lint: Boolean = false,
@Inline
save: ExportCommand = ExportCommand.default
) extends Command {
Expand All @@ -47,7 +46,6 @@ final case class PantsExportCommand(
save <-
save
.copy(
lint = lint,
lintCommand = save.lintCommand.copy(
app = app
.withEnv(app.env.withWorkingDirectory(workingDirectory))
Expand Down

0 comments on commit c3b5721

Please sign in to comment.