Skip to content

Commit b01a91f

Browse files
committed
use --cli-version launcher option on windows
1 parent 709e91f commit b01a91f

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
#!/usr/bin/env bash
22

3-
SCALA_CLI_CMD_BASH=("\"$PROG_HOME/bin/scala-cli\"")
3+
if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
4+
SCALA_CLI_VERSION=""
5+
# iterate through lines in VERSION_SRC
6+
while IFS= read -r line; do
7+
# if line starts with "version:=" then extract the version
8+
if [[ "$line" == cli_version:=* ]]; then
9+
SCALA_CLI_VERSION="${line#cli_version:=}"
10+
break
11+
fi
12+
done < "$PROG_HOME/EXTRA_PROPERTIES"
13+
SCALA_CLI_CMD_BASH=("\"$PROG_HOME/bin/scala-cli\"" "--cli-version \"$SCALA_CLI_VERSION\"")
14+
else
15+
SCALA_CLI_CMD_BASH=("\"$PROG_HOME/bin/scala-cli\"")
16+
fi
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
@echo off
22

3-
set SCALA_CLI_CMD_WIN="%_PROG_HOME%\bin\scala-cli.exe"
3+
setlocal enabledelayedexpansion
4+
5+
set "_SCALA_CLI_VERSION="
6+
@rem read for cli_version:=_SCALA_CLI_VERSION in EXTRA_PROPERTIES file
7+
FOR /F "usebackq delims=" %%G IN ("%_PROG_HOME%\EXTRA_PROPERTIES") DO (
8+
SET "line=%%G"
9+
IF "!line:~0,13!"=="cli_version:=" (
10+
SET "_SCALA_CLI_VERSION=!line:~13!"
11+
GOTO :foundCliVersion
12+
)
13+
)
14+
15+
:foundCliVersion
16+
endlocal & set "SCALA_CLI_VERSION=%_SCALA_CLI_VERSION%"
17+
18+
set SCALA_CLI_CMD_WIN="%_PROG_HOME%\bin\scala-cli.exe" "--cli-version" "%SCALA_CLI_VERSION%"

project/Build.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ object Build {
119119

120120
/** Version of Scala CLI to download */
121121
val scalaCliLauncherVersion = "1.3.2"
122+
/** Version of Scala CLI to download (on Windows - last known validated version) */
123+
val scalaCliLauncherVersionWindows = "1.3.2"
122124
/** Version of Coursier to download for initializing the local maven repo of Scala command */
123125
val coursierJarVersion = "2.1.10"
124126

@@ -2164,8 +2166,10 @@ object Build {
21642166
packArchiveName := (dist / packArchiveName).value + "-x86_64-pc-win32",
21652167
republishBinOverrides += (dist / baseDirectory).value / "bin-native-overrides",
21662168
republishFetchCoursier := (dist / republishFetchCoursier).value,
2169+
republishExtraProps += ("cli_version" -> scalaCliLauncherVersion),
2170+
mappings += (republishRepo.value / "etc" / "EXTRA_PROPERTIES" -> "EXTRA_PROPERTIES"),
21672171
republishLaunchers +=
2168-
("scala-cli.exe" -> s"zip+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersion/scala-cli-x86_64-pc-win32.zip!/scala-cli.exe")
2172+
("scala-cli.exe" -> s"zip+https://github.com/VirtusLab/scala-cli/releases/download/v$scalaCliLauncherVersionWindows/scala-cli-x86_64-pc-win32.zip!/scala-cli.exe")
21692173
)
21702174

21712175
lazy val `dist-linux-x86_64` = project.in(file("dist/linux-x86_64")).asDist(Bootstrapped)

project/RepublishPlugin.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@ object RepublishPlugin extends AutoPlugin {
6262
val republishFetchLaunchers = taskKey[Set[File]]("cache the launcher deps for the distribution")
6363
val republishFetchCoursier = taskKey[File]("cache the coursier.jar for resolving the local maven repo.")
6464
val republishPrepareBin = taskKey[File]("prepare the bin directory, including launchers and scripts.")
65+
val republishWriteExtraProps = taskKey[Option[File]]("write extra properties for the launchers.")
6566
val republishBinDir = settingKey[File]("where to find static files for the bin dir.")
6667
val republishCoursierDir = settingKey[File]("where to download the coursier launcher jar.")
6768
val republishBinOverrides = settingKey[Seq[File]]("files to override those in bin-dir.")
6869
val republish = taskKey[File]("cache the dependencies and download launchers for the distribution")
6970
val republishRepo = settingKey[File]("the location to store the republished artifacts.")
7071
val republishLaunchers = settingKey[Seq[(String, String)]]("launchers to download. Sequence of (name, URL).")
7172
val republishCoursier = settingKey[Seq[(String, String)]]("coursier launcher to download. Sequence of (name, URL).")
73+
val republishExtraProps = settingKey[Seq[(String, String)]]("extra properties for launchers.")
7274
}
7375

7476
import autoImport._
@@ -276,6 +278,7 @@ object RepublishPlugin extends AutoPlugin {
276278
republishLaunchers := Seq.empty,
277279
republishCoursier := Seq.empty,
278280
republishBinOverrides := Seq.empty,
281+
republishExtraProps := Seq.empty,
279282
republishLocalResolved / republishProjectRefs := {
280283
val proj = thisProjectRef.value
281284
val deps = buildDependencies.value
@@ -366,10 +369,31 @@ object RepublishPlugin extends AutoPlugin {
366369
}
367370
targetBin
368371
},
372+
republishWriteExtraProps := {
373+
val s = streams.value
374+
val log = s.log
375+
val extraProps = republishExtraProps.value
376+
if (extraProps.isEmpty) {
377+
log.info("[republish] No extra properties to write.")
378+
None
379+
}
380+
else {
381+
val repoDir = republishRepo.value
382+
val propsFile = repoDir / "etc" / "EXTRA_PROPERTIES"
383+
log.info(s"[republish] Writing extra properties to $propsFile...")
384+
Using.fileWriter()(propsFile) { writer =>
385+
extraProps.foreach { case (k, v) =>
386+
writer.write(s"$k:=$v\n")
387+
}
388+
}
389+
Some(propsFile)
390+
}
391+
},
369392
republish := {
370393
val cacheDir = republishRepo.value
371394
val artifacts = republishClasspath.value
372395
val launchers = republishFetchLaunchers.value
396+
val extraProps = republishWriteExtraProps.value
373397
cacheDir
374398
}
375399
)

0 commit comments

Comments
 (0)