Skip to content

Commit

Permalink
Allow to use custom maven repo in Scala CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechMazur committed Jul 14, 2023
1 parent 6c35d47 commit 1eed581
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion project-builder/build-revision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ else
ls -l repo/
scala-cli clean $scriptDir/scala-cli/
scala-cli clean repo
scala-cli $scriptDir/scala-cli/build.scala -- repo "$scalaVersion" "$projectConfig"
scala-cli $scriptDir/scala-cli/build.scala -- repo "$scalaVersion" "$projectConfig" "$mvnRepoUrl"
fi
17 changes: 12 additions & 5 deletions project-builder/scala-cli/build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ import os.CommandResult
@main def buildScalaCliProject(
repositoryDir: String,
scalaVersion: String,
configJson: String
configJson: String,
mavenRepoURL: String
): Unit = {
println(s"Build config: ${configJson}")
val config =
if (configJson.isEmpty()) ProjectBuildConfig()
else read[ProjectBuildConfig](configJson)
println(s"Parsed config: ${config}")

val evaluator = CliTaskEvaluator(scalaVersion, repositoryDir)
val evaluator = CliTaskEvaluator(
scalaVersion = scalaVersion,
repositoryDir = repositoryDir,
mavenRepoURL = Option(mavenRepoURL).filterNot(_.isEmpty)
)
import evaluator.{eval, evalAsDependencyOf, evalWhen}

val compileResult = eval[Unit](cmd("compile"))
Expand Down Expand Up @@ -99,7 +104,7 @@ case class CliCommand[T](
errHandler: (CommandResult, EvalResult.Failure) => EvalResult[T]
)
def cmd(args: String*) = CliCommand[Unit](args, (_, failure) => failure)
class CliTaskEvaluator(scalaVersion: String, repositoryDir: String)
class CliTaskEvaluator(scalaVersion: String, repositoryDir: String, mavenRepoURL: Option[String])
extends TaskEvaluator[CliCommand] {
import TaskEvaluator.*

Expand All @@ -124,9 +129,11 @@ class CliTaskEvaluator(scalaVersion: String, repositoryDir: String)
repositoryDir,
s"--server=false",
s"--scala-version=${scalaVersion}",
"--scalac-option=-J-Xss8M",
"--scalac-option=-J-Xss10M",
"--scalac-option=-J-Xmx=7G",
"--scalac-option=-J-Xms=4G"
"--scalac-option=-J-Xms=4G",
mavenRepoURL.map(s"--repository=" + _).getOrElse(""),
"-v"
)
.call(check = false, stderr = os.Pipe)
val result = proc.exitCode
Expand Down

0 comments on commit 1eed581

Please sign in to comment.