Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set COURSIER_REPOSITORIES env variable when building with scala-cli #333

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions project-builder/scala-cli/build.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//> using toolkit latest
//> using scala 3
//> using toolkit 0.2.1
//> using scala 3.3
//> using file ../shared/CommunityBuildCore.scala

import Scala3CommunityBuild.*
Expand Down Expand Up @@ -107,7 +107,7 @@ import os.CommandResult
case class CliCommand[T](
command: Seq[String],
errHandler: (CommandResult, EvalResult.Failure) => EvalResult[T]
){
) {
override def toString(): String = s"${command.mkString(" ")}"
}
def cmd(args: String*) = CliCommand[Unit](args, (_, failure) => failure)
Expand All @@ -127,9 +127,9 @@ class CliTaskEvaluator(scalaVersion: String, repositoryDir: String, mavenRepoURL
}

def eval[T](task: CliCommand[T]): EvalResult[T] = {
val extraLibraryDependencies = Utils.extraLibraryDependencies(scalaVersion).map{
case Utils.LibraryDependency(org, artifact, version, scalaCrossVersion) =>
if(scalaCrossVersion) s"--dependency=$org::$artifact:$version"
val extraLibraryDependencies = Utils.extraLibraryDependencies(scalaVersion).map {
case Utils.LibraryDependency(org, artifact, version, scalaCrossVersion) =>
if (scalaCrossVersion) s"--dependency=$org::$artifact:$version"
else s"--dependency=$org:$artifact:$version"
}
val evalStart = System.currentTimeMillis()
Expand All @@ -146,7 +146,14 @@ class CliTaskEvaluator(scalaVersion: String, repositoryDir: String, mavenRepoURL
mavenRepoURL.map(s"--repository=" + _).toList,
extraLibraryDependencies
)
.call(check = false, stdout = os.Inherit, stderr = os.Pipe)
.call(
check = false,
stdout = os.Inherit,
stderr = os.Pipe,
env = Map(
"COURSIER_REPOSITORIES" -> s"central|sonatype:releases|${mavenRepoURL.getOrElse("")}"
)
)
val result = proc.exitCode
val tookMillis = (System.currentTimeMillis() - evalStart).toInt
def nullT = null.asInstanceOf[T]
Expand Down