Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: VirtusLab/scala-cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.7
Choose a base ref
...
head repository: VirtusLab/scala-cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.1.8
Choose a head ref

Commits on Jun 6, 2022

  1. Scripts guide refactor

      - Use ChainedSnippets component rather than commented outputs in `bash` code blocks
      - fix formatting
    Gedochao committed Jun 6, 2022
    Copy the full SHA
    c3652b3 View commit details
  2. Copy the full SHA
    d5a9090 View commit details
  3. Copy the full SHA
    88a5e05 View commit details
  4. Add "config" command

    Allowing to persist some configuration values in a secured file under the
    user home directory, to be used by other Scala CLI commands.
    alexarchambault committed Jun 6, 2022
    Copy the full SHA
    25149ba View commit details
  5. Update scala-cli.sh launcher for 0.1.7 (#1076)

    Co-authored-by: gh-actions <actions@github.com>
    github-actions[bot] and actions-user authored Jun 6, 2022
    Copy the full SHA
    4b77472 View commit details
  6. Add suffix to project name which contains a virtual files (#1070)

    * Add suffix to project name which contains a virtual files
    
    * Add regressions test
    lwronski authored Jun 6, 2022
    Copy the full SHA
    a8cfa75 View commit details

Commits on Jun 7, 2022

  1. Merge pull request #1074 from Gedochao/improve-scripts-guide

    Improve scripts guide
    Gedochao authored Jun 7, 2022
    Copy the full SHA
    0bf3147 View commit details
  2. Copy the full SHA
    fbb1d30 View commit details
  3. Copy the full SHA
    866c78b View commit details
  4. Copy the full SHA
    d9edadc View commit details
  5. Copy the full SHA
    fea851a View commit details
  6. Tweak cli option helpers

    - have the implicit classes extend AnyVal
    - fix cached stuff
    alexarchambault committed Jun 7, 2022
    Copy the full SHA
    625bc3b View commit details
  7. Copy the full SHA
    30bb736 View commit details
  8. Tweak default workflow content

    As of now, it's using a custom Scala CLI launcher, via './scala-cli'.
    As we don't install that custom launcher in users' projects, we use just
    'scala-cli' instead.
    alexarchambault committed Jun 7, 2022
    Copy the full SHA
    e851078 View commit details
  9. Remove stale comment

    alexarchambault committed Jun 7, 2022
    Copy the full SHA
    a64275d View commit details
  10. Copy the full SHA
    71db469 View commit details
  11. Copy the full SHA
    3767939 View commit details

Commits on Jun 8, 2022

  1. Copy the full SHA
    d1de64e View commit details
  2. Copy the full SHA
    b00f5f7 View commit details
  3. Copy the full SHA
    45d61e5 View commit details
  4. Copy the full SHA
    980bba6 View commit details
  5. Move special imports down in configuration page

    As these are somewhat less important (and may possibly be removed at
    some point), better put them more down in this page
    alexarchambault committed Jun 8, 2022
    Copy the full SHA
    9778931 View commit details
  6. Copy the full SHA
    6ac4f57 View commit details
  7. Copy the full SHA
    b98ea7c View commit details
  8. Copy the full SHA
    ae13ae6 View commit details
  9. Some typos & rewording on the single-module projects use case page (#…

    …1089)
    
    PR raised via github so I reviewed a single page, but I needed to scratch that itch
    Baccata authored Jun 8, 2022
    Copy the full SHA
    e46b73b View commit details

Commits on Jun 9, 2022

  1. Copy the full SHA
    18ac25d View commit details

Commits on Jun 13, 2022

  1. Copy the full SHA
    a5cdf7a View commit details
  2. Convert relative path to absolute for coverage options (#1080)

    * Convert relative path to absolute for coverage options
    lwronski authored Jun 13, 2022
    Copy the full SHA
    c24e37c View commit details

Commits on Jun 14, 2022

  1. Copy the full SHA
    b3f9fa5 View commit details
  2. Add integration tests for running the appropriate main class if both …

    …scripts and other sources are present
    Gedochao committed Jun 14, 2022
    Copy the full SHA
    efa5ef1 View commit details
  3. Copy the full SHA
    98abe22 View commit details
  4. Copy the full SHA
    0934316 View commit details
  5. Copy the full SHA
    407f480 View commit details
  6. Add docs on referring to piped scripts' code, default main classes & …

    …listing available main classes
    Gedochao committed Jun 14, 2022
    Copy the full SHA
    f9e8bf1 View commit details
  7. Copy the full SHA
    c52f7f6 View commit details
  8. Copy the full SHA
    78c31b3 View commit details
  9. Copy the full SHA
    ec5f9a6 View commit details
  10. Copy the full SHA
    d1dd0dc View commit details
  11. Copy the full SHA
    726d3e2 View commit details
  12. Copy the full SHA
    cd4ca47 View commit details
  13. Copy the full SHA
    bd4c68d View commit details
  14. Copy the full SHA
    1f466b6 View commit details
  15. Copy the full SHA
    b2a03a9 View commit details
  16. Copy the full SHA
    6ed7823 View commit details
  17. Merge pull request #1095 from Gedochao/favor-non-script-main-class

    Favor non-script main classes & add an option for listing main classes in context
    Gedochao authored Jun 14, 2022
    Copy the full SHA
    3c38733 View commit details
  18. Add release notes for v0.1.8 (#1103)

    * Add release notes for v0.1.8
    
    Co-authored-by: Alexandre Archambault <alexarchambault@users.noreply.github.com>
    Gedochao and alexarchambault authored Jun 14, 2022
    Copy the full SHA
    ddd4202 View commit details
  19. Merge pull request #1099 from alexarchambault/scala-2.12.16

    Update Scala to 2.12.16
    alexarchambault authored Jun 14, 2022
    Copy the full SHA
    05de912 View commit details
Showing with 1,779 additions and 292 deletions.
  1. +88 −0 .github/release/release_notes.md
  2. +25 −16 build.sc
  3. +58 −21 modules/build/src/main/scala/scala/build/Build.scala
  4. +1 −1 modules/build/src/main/scala/scala/build/CrossSources.scala
  5. +5 −0 modules/build/src/main/scala/scala/build/Directories.scala
  6. +4 −4 modules/build/src/main/scala/scala/build/Inputs.scala
  7. +17 −2 modules/build/src/main/scala/scala/build/Project.scala
  8. +5 −0 modules/build/src/test/scala/scala/build/tests/BuildOptionsTests.scala
  9. +1 −4 modules/build/src/test/scala/scala/build/tests/TestUtil.scala
  10. +8 −1 modules/cli-options/src/main/scala/scala/cli/commands/MainClassOptions.scala
  11. +1 −1 modules/cli-options/src/main/scala/scala/cli/commands/SharedCompilationServerOptions.scala
  12. +1 −1 modules/cli-options/src/main/scala/scala/cli/commands/UpdateOptions.scala
  13. +38 −0 modules/cli-options/src/main/scala/scala/cli/commands/config/ConfigOptions.scala
  14. +7 −1 modules/cli-options/src/main/scala/scala/cli/commands/publish/PublishOptions.scala
  15. +2 −2 modules/cli-options/src/main/scala/scala/cli/commands/publish/PublishParamsOptions.scala
  16. +8 −1 modules/cli/src/main/scala/scala/cli/ScalaCli.scala
  17. +2 −0 modules/cli/src/main/scala/scala/cli/ScalaCliCommands.scala
  18. +1 −0 modules/cli/src/main/scala/scala/cli/commands/Directories.scala
  19. +1 −1 modules/cli/src/main/scala/scala/cli/commands/InstallHome.scala
  20. +4 −2 modules/cli/src/main/scala/scala/cli/commands/Package.scala
  21. +41 −26 modules/cli/src/main/scala/scala/cli/commands/Run.scala
  22. +115 −0 modules/cli/src/main/scala/scala/cli/commands/config/Config.scala
  23. +70 −0 modules/cli/src/main/scala/scala/cli/commands/config/ThrowawayPgpSecret.scala
  24. +33 −1 modules/cli/src/main/scala/scala/cli/commands/pgp/PgpProxy.scala
  25. +26 −1 modules/cli/src/main/scala/scala/cli/commands/pgp/PgpProxyJvm.scala
  26. +70 −32 modules/cli/src/main/scala/scala/cli/commands/publish/Publish.scala
  27. +3 −1 modules/cli/src/main/scala/scala/cli/commands/publish/PublishLocal.scala
  28. +9 −7 modules/cli/src/main/scala/scala/cli/commands/util/CommonOps.scala
  29. +21 −0 modules/cli/src/main/scala/scala/cli/commands/util/MainClassOptionsUtil.scala
  30. +1 −1 modules/cli/src/main/scala/scala/cli/commands/util/PackageOptionsUtil.scala
  31. +4 −3 modules/cli/src/main/scala/scala/cli/commands/util/SharedCompilationServerOptionsUtil.scala
  32. +1 −1 modules/cli/src/main/scala/scala/cli/commands/util/SharedOptionsUtil.scala
  33. +230 −0 modules/cli/src/main/scala/scala/cli/config/ConfigDb.scala
  34. +139 −0 modules/cli/src/main/scala/scala/cli/config/Key.scala
  35. +32 −0 modules/cli/src/main/scala/scala/cli/config/Keys.scala
  36. +23 −0 modules/integration/src/test/scala/scala/cli/integration/CompileTestDefinitions.scala
  37. +84 −0 modules/integration/src/test/scala/scala/cli/integration/ConfigTests.scala
  38. +1 −1 modules/integration/src/test/scala/scala/cli/integration/NativePackagerTests.scala
  39. +144 −0 modules/integration/src/test/scala/scala/cli/integration/RunTestDefinitions.scala
  40. +3 −6 modules/integration/src/test/scala/scala/cli/integration/TestUtil.scala
  41. +0 −3 modules/options/src/main/scala/scala/build/internals/Util.scala
  42. +46 −20 modules/options/src/main/scala/scala/build/options/BuildOptions.scala
  43. +10 −4 modules/options/src/main/scala/scala/build/options/ScalaVersionUtil.scala
  44. +3 −3 project/deps.sc
  45. +1 −1 scala-cli.bat
  46. +1 −1 scala-cli.sh
  47. +2 −2 website/docs/_advanced_install.mdx
  48. +4 −4 website/docs/commands/basics.md
  49. +1 −1 website/docs/commands/clean.md
  50. +8 −8 website/docs/commands/compile.md
  51. +3 −3 website/docs/commands/doc.md
  52. +5 −5 website/docs/commands/fmt.md
  53. +1 −1 website/docs/commands/misc/_category_.json
  54. +82 −0 website/docs/commands/misc/config.md
  55. +1 −1 website/docs/commands/misc/default-file.md
  56. +2 −0 website/docs/commands/{ → misc}/pgp.md
  57. +7 −7 website/docs/commands/package.md
  58. +1 −1 website/docs/commands/repl.md
  59. +4 −2 website/docs/commands/run.md
  60. +1 −1 website/docs/commands/setup-ide.md
  61. +5 −5 website/docs/commands/test.md
  62. +9 −9 website/docs/getting_started.md
  63. +15 −13 website/docs/guides/configuration.md
  64. +6 −11 website/docs/guides/ide.md
  65. +11 −13 website/docs/guides/internals.md
  66. +69 −5 website/docs/guides/piping.md
  67. +83 −9 website/docs/guides/scripts.md
  68. +3 −3 website/docs/guides/using-directives.md
  69. +42 −3 website/docs/reference/cli-options.md
  70. +10 −1 website/docs/reference/commands.md
  71. +4 −2 website/docs/reference/scala-versions.md
  72. +2 −2 website/docs/reference/working-dir.md
  73. +1 −1 website/src/pages/education.js
  74. +3 −3 website/src/pages/projects.js
  75. +6 −6 website/src/pages/scripting.js
88 changes: 88 additions & 0 deletions .github/release/release_notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# v0.1.8

## `--list-main-classes` option for the `run` command

You can pass the option `--list-main-classes` to the `run` command to list all the available main classes, including
scripts.

```
$ scala-cli . --list-main-classes
Hello scripts.AnotherScript_sc scripts.Script_sc
```

Added in [#1095](https://github.com/VirtusLab/scala-cli/pull/1095) by @Gedochao

## Add `config` command

The `config` sub-command allows to get and set various configuration values, intended for use by
other Scala CLI sub-commands.

This feature has been added in preparation for the `publish` command, stay tuned for future announcements.

Added in [#1056](https://github.com/VirtusLab/scala-cli/pull/1056) by @alexarchambault

## Prioritise non-script main classes

When trying to run a directory containing scripts and just a single non-script main class, the non-script main class
will now be prioritised and run by default.

```
$ scala-cli .
Running Hello. Also detected script main classes: scripts.AnotherScript_sc, scripts.Script_sc
You can run any one of them by passing option --main-class, i.e. --main-class scripts.AnotherScript_sc
All available main classes can always be listed by passing option --list-main-classes
Hello world
```

Changed in [#1095](https://github.com/VirtusLab/scala-cli/pull/1095) by @Gedochao

## Important bugfixes

### Accept latest Scala versions despite stale Scala version listings in cache

Scala CLI uses version listings from Maven Central to check if a Scala version is valid. When new Scala versions are
released, users could sometimes have stale version listings in their Coursier cache for a short period of time (the
Coursier cache TTL, which is 24 hours by default). This prevented these users to use new Scala versions during that
time.
To work around that, Scala CLI now tries to re-download version listings when they don't have the requested Scala
version.
This addresses [#1090](https://github.com/VirtusLab/scala-cli/issues/1090)

Fixed in [#1096](https://github.com/VirtusLab/scala-cli/pull/1096) by @lwronski

### Bloop now uses `JAVA_HOME` by default

Bloop should now pick up the JDK available in `JAVA_HOME`. It was formerly necessary to pass `--bloop-jvm system`
explicitly. This addresses [#1102](https://github.com/VirtusLab/scala-cli/issues/1102)

Fixed in [#1084](https://github.com/VirtusLab/scala-cli/pull/1084) by @lwronski

### The `-coverage-out` option now accepts relative paths

Scala CLI now correctly processes relative paths when passed to the `-coverage-out` option. Formerly,
the `scoverage.coverage` file would not be properly generated when a relative path was passed.
This addresses [#1072](https://github.com/VirtusLab/scala-cli/issues/1072)

Fixed in [#1080](https://github.com/VirtusLab/scala-cli/pull/1080) by @lwronski

## Other changes

### Documentation PRs

* Improve scripts guide by @Gedochao in [#1074](https://github.com/VirtusLab/scala-cli/pull/1074)
* Update installation instructions for Nix by @kubukoz in [#1082](https://github.com/VirtusLab/scala-cli/pull/1082)
* Tweak docs by @alexarchambault in [#1085](https://github.com/VirtusLab/scala-cli/pull/1085)
* Some typos & rewording on the single-module projects use case page by @Baccata
in [#1089](https://github.com/VirtusLab/scala-cli/pull/1089)

### Fixes

* Add suffix to project name which contains virtual files by @lwronski
in [#1070](https://github.com/VirtusLab/scala-cli/pull/1070)

### Build and internal changes

* Update scala-cli.sh launcher for 0.1.7 by @github-actions in [#1076](https://github.com/VirtusLab/scala-cli/pull/1076)
* Tweaking by @alexarchambault in [#1087](https://github.com/VirtusLab/scala-cli/pull/1087)

**Full Changelog**: https://github.com/VirtusLab/scala-cli/compare/v0.1.7...v0.1.8
41 changes: 25 additions & 16 deletions build.sc
Original file line number Diff line number Diff line change
@@ -109,10 +109,9 @@ object integration extends CliIntegration {
PathRef(T.dest / "working-dir")
}
def forkEnv = super.forkEnv() ++ Seq(
"SCALA_CLI_TMP" -> tmpDirBase().path.toString,
"SCALA_CLI_IMAGE" -> "scala-cli",
"CI" -> "1",
"ACTUAL_CI" -> (if (System.getenv("CI") == null) "" else "1")
"SCALA_CLI_TMP" -> tmpDirBase().path.toString,
"SCALA_CLI_IMAGE" -> "scala-cli",
"SCALA_CLI_PRINT_STACK_TRACES" -> "1"
)
}
}
@@ -125,10 +124,9 @@ object integration extends CliIntegration {
PathRef(T.dest / "working-dir")
}
def forkEnv = super.forkEnv() ++ Seq(
"SCALA_CLI_TMP" -> tmpDirBase().path.toString,
"SCALA_CLI_IMAGE" -> "scala-cli-slim",
"CI" -> "1",
"ACTUAL_CI" -> (if (System.getenv("CI") == null) "" else "1")
"SCALA_CLI_TMP" -> tmpDirBase().path.toString,
"SCALA_CLI_IMAGE" -> "scala-cli-slim",
"SCALA_CLI_PRINT_STACK_TRACES" -> "1"
)
}
}
@@ -632,15 +630,27 @@ trait Cli extends SbtModule with ProtoBuildModule with CliLaunchers

def defaultFilesResources = T.persistent {
val dir = T.dest / "resources"
val resources = Seq(
"https://raw.githubusercontent.com/scala-cli/default-workflow/main/.github/workflows/ci.yml" -> (os.sub / "workflows" / "default.yml"),
"https://raw.githubusercontent.com/scala-cli/default-workflow/main/.gitignore" -> (os.sub / "gitignore")
def transformWorkflow(content: Array[Byte]): Array[Byte] =
new String(content, "UTF-8")
.replaceAll(" ./scala-cli", " scala-cli")
.getBytes("UTF-8")
val resources = Seq[(String, os.SubPath, Array[Byte] => Array[Byte])](
(
"https://raw.githubusercontent.com/scala-cli/default-workflow/main/.github/workflows/ci.yml",
os.sub / "workflows" / "default.yml",
transformWorkflow _
),
(
"https://raw.githubusercontent.com/scala-cli/default-workflow/main/.gitignore",
os.sub / "gitignore",
identity
)
)
for ((srcUrl, destRelPath) <- resources) {
for ((srcUrl, destRelPath, transform) <- resources) {
val dest = dir / defaultFilesResourcePath / destRelPath
if (!os.isFile(dest)) {
val content = Using.resource(new URL(srcUrl).openStream())(_.readAllBytes())
os.write(dest, content, createFolders = true)
os.write(dest, transform(content), createFolders = true)
}
}
PathRef(dir)
@@ -766,9 +776,8 @@ trait CliIntegration extends SbtModule with ScalaCliPublishModule with HasTests
Deps.jsoniterMacros
)
def forkEnv = super.forkEnv() ++ Seq(
"SCALA_CLI_TMP" -> tmpDirBase().path.toString,
"CI" -> "1",
"ACTUAL_CI" -> (if (System.getenv("CI") == null) "" else "1")
"SCALA_CLI_TMP" -> tmpDirBase().path.toString,
"SCALA_CLI_PRINT_STACK_TRACES" -> "1"
)
private def updateRef(name: String, ref: PathRef): PathRef = {
val rawPath = ref.path.toString.replace(
79 changes: 58 additions & 21 deletions modules/build/src/main/scala/scala/build/Build.scala
Original file line number Diff line number Diff line change
@@ -49,29 +49,66 @@ object Build {
generatedSources: Seq[GeneratedSource],
isPartial: Boolean
) extends Build {
def success: Boolean = true
def successfulOpt: Some[this.type] = Some(this)
def outputOpt: Some[os.Path] = Some(output)
def fullClassPath: Seq[os.Path] = Seq(output) ++ sources.resourceDirs ++ artifacts.classPath
def foundMainClasses(): Seq[String] =
MainClass.find(output)
def retainedMainClass(logger: Logger): Either[MainClassError, String] = {
lazy val foundMainClasses0 = foundMainClasses()
def success: Boolean = true
def successfulOpt: Some[this.type] = Some(this)
def outputOpt: Some[os.Path] = Some(output)
def fullClassPath: Seq[os.Path] = Seq(output) ++ sources.resourceDirs ++ artifacts.classPath
def foundMainClasses(): Seq[String] = MainClass.find(output)
def retainedMainClass(
mainClasses: Seq[String],
logger: Logger
): Either[MainClassError, String] = {
val defaultMainClassOpt = sources.defaultMainClass
.filter(name => foundMainClasses0.contains(name))
.filter(name => mainClasses.contains(name))
def foundMainClass =
if (foundMainClasses0.isEmpty) Left(new NoMainClassFoundError)
else if (foundMainClasses0.length == 1) Right(foundMainClasses0.head)
else
options.interactive.chooseOne(
"Found several main classes. Which would you like to run?",
foundMainClasses0.toList
).toRight {
new SeveralMainClassesFoundError(
::(foundMainClasses0.head, foundMainClasses0.tail.toList),
Nil
)
}
mainClasses match {
case Seq() => Left(new NoMainClassFoundError)
case Seq(mainClass) => Right(mainClass)
case _ =>
val scriptInferredMainClasses =
sources.inMemory.map(im => im.originalPath.map(_._1))
.flatMap {
case Right(originalRelPath) if originalRelPath.toString.endsWith(".sc") =>
Some {
originalRelPath
.toString
.replace(".", "_")
.replace("/", ".")
}
case Left(stdin @ "stdin") => Some(s"${stdin}_sc")
case _ => None
}
val filteredMainClasses =
mainClasses.filter(!scriptInferredMainClasses.contains(_))
if (filteredMainClasses.length == 1) {
val pickedMainClass = filteredMainClasses.head
if (scriptInferredMainClasses.nonEmpty) {
val firstScript = scriptInferredMainClasses.head
val scriptsString = scriptInferredMainClasses.mkString(", ")
logger.message(
s"Running $pickedMainClass. Also detected script main classes: $scriptsString"
)
logger.message(
s"You can run any one of them by passing option --main-class, i.e. --main-class $firstScript"
)
logger.message(
"All available main classes can always be listed by passing option --list-main-classes"
)
}
Right(pickedMainClass)
}
else options.interactive
.chooseOne(
"Found several main classes. Which would you like to run?",
mainClasses.toList
)
.toRight {
new SeveralMainClassesFoundError(
::(mainClasses.head, mainClasses.tail.toList),
Nil
)
}
}

defaultMainClassOpt match {
case Some(cls) => Right(cls)
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ object CrossSources {
.flatMap(_.valueFor(path).toSeq)
.foldLeft(BuildRequirements())(_ orElse _)

// Scala-cli treats all `.test.scala` files tests as well as
// Scala CLI treats all `.test.scala` files tests as well as
// files from witin `test` subdirectory from provided input directories
// If file has `using target <scope>` directive this take precendeces.
if (
5 changes: 5 additions & 0 deletions modules/build/src/main/scala/scala/build/Directories.scala
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ trait Directories {
def bspSocketDir: os.Path
def bloopDaemonDir: os.Path
def bloopWorkingDir: os.Path
def secretsDir: os.Path
}

object Directories {
@@ -38,6 +39,8 @@ object Directories {
else projDirs.dataLocalDir
os.Path(baseDir, Os.pwd) / "bloop"
}
lazy val secretsDir: os.Path =
os.Path(projDirs.dataLocalDir, Os.pwd) / "secrets"
}

final case class SubDir(dir: os.Path) extends Directories {
@@ -55,6 +58,8 @@ object Directories {
bloopWorkingDir / "daemon"
lazy val bloopWorkingDir: os.Path =
dir / "data-local" / "bloop"
lazy val secretsDir: os.Path =
dir / "data-local" / "secrets"
}

def default(): Directories = {
8 changes: 4 additions & 4 deletions modules/build/src/main/scala/scala/build/Inputs.scala
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@ object Inputs {
}

sealed abstract class VirtualSourceFile extends Virtual {
def isStdin: Boolean = source == "<stdin>"
def isStdin: Boolean = source.contains("<stdin>")
}

sealed trait SingleFile extends OnDisk with SingleElement
@@ -233,7 +233,7 @@ object Inputs {
}
Iterator(prefix, elem.path.toString, "\n").map(bytes)
case v: Inputs.Virtual =>
Iterator(bytes("virtual:"), v.content, bytes("\n"))
Iterator(bytes("virtual:"), v.content, bytes(v.source), bytes("\n"))
}
val md = MessageDigest.getInstance("SHA-1")
it.foreach(md.update)
@@ -339,9 +339,9 @@ object Inputs {
lazy val stdinOpt0 = stdinOpt
val isStdin = (arg == "-.scala" || arg == "_" || arg == "_.scala") &&
stdinOpt0.nonEmpty
if (isStdin) Right(Seq(VirtualScalaFile(stdinOpt0.get, "<stdin>")))
if (isStdin) Right(Seq(VirtualScalaFile(stdinOpt0.get, "<stdin>-scala-file")))
else if ((arg == "-.java" || arg == "_.java") && stdinOpt0.nonEmpty)
Right(Seq(VirtualJavaFile(stdinOpt0.get, "<stdin>")))
Right(Seq(VirtualJavaFile(stdinOpt0.get, "<stdin>-java-file")))
else if ((arg == "-" || arg == "-.sc" || arg == "_.sc") && stdinOpt0.nonEmpty)
Right(Seq(VirtualScript(stdinOpt0.get, "stdin", os.sub / "stdin.sc")))
else if (arg.endsWith(".zip") && os.exists(os.Path(arg, cwd))) {
19 changes: 17 additions & 2 deletions modules/build/src/main/scala/scala/build/Project.scala
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import java.nio.charset.StandardCharsets
import java.nio.file.Path
import java.util.Arrays

import scala.build.options.Scope
import scala.build.options.{ScalacOpt, Scope, ShadowingSeq}

final case class Project(
workspace: os.Path,
@@ -46,7 +46,7 @@ final case class Project(
}
val scalaConfigOpt = scalaCompiler.map { scalaCompiler0 =>
bloopScalaConfig("org.scala-lang", "scala-compiler", scalaCompiler0.scalaVersion).copy(
options = scalaCompiler0.scalacOptions.toList,
options = updateScalacOptions(scalaCompiler0.scalacOptions).map(_.value),
jars = scalaCompiler0.compilerClassPath.map(_.toNIO).toList
)
}
@@ -72,6 +72,21 @@ final case class Project(
def bloopFile: BloopConfig.File =
BloopConfig.File(BloopConfig.File.LatestVersion, bloopProject)

private def updateScalacOptions(scalacOptions: Seq[String]): List[ScalacOpt] =
ShadowingSeq.from(scalacOptions.map(ScalacOpt(_))).values.map { l =>
// only look at the head, the tail is only values passed to it
l.headOption match {
case Some(opt) if opt.value.startsWith("-coverage-out:") =>
// actual -coverage-out: option
val maybeRelativePath = opt.value.stripPrefix("-coverage-out:")
val absolutePath = os.Path(maybeRelativePath, Os.pwd)
ScalacOpt(s"-coverage-out:$absolutePath") +: l.tail
case _ =>
// not a -coverage-out: option
l
}
}.flatten.toList

private def maybeUpdateInputs(logger: Logger): Boolean = {
val dest = directory / ".bloop" / s"$projectName.inputs.txt"
val onDiskOpt =
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package scala.build.tests

import com.eed3si9n.expecty.Expecty.{assert => expect}
import coursier.cache.FileCache
import dependency.ScalaParameters

import scala.build.Ops._
@@ -23,6 +24,7 @@ import scala.build.{Build, BuildThreads, LocalRepo}
import scala.build.Directories
import scala.build.options.ScalacOpt
import scala.build.Positioned
import scala.concurrent.duration.DurationInt

class BuildOptionsTests extends munit.FunSuite {

@@ -258,6 +260,9 @@ class BuildOptionsTests extends munit.FunSuite {
val options = BuildOptions(
scalaOptions = ScalaOptions(
scalaVersion = prefix.map(MaybeScalaVersion(_))
),
internal = InternalOptions(
cache = Some(FileCache().withTtl(0.seconds))
)
)
val scalaParams = options.scalaParams.orThrow.getOrElse(???)
Original file line number Diff line number Diff line change
@@ -6,10 +6,7 @@ import munit.Assertions.assertEquals

object TestUtil {

val isCI = Option(System.getenv("ACTUAL_CI")) match {
case None => System.getenv("CI") != null
case Some(value) => value.nonEmpty
}
val isCI = System.getenv("CI") != null

implicit class TestBuildOps(private val build: Build) extends AnyVal {
private def successfulBuild: Build.Successful =
Loading