Skip to content

Commit 075f20e

Browse files
authored
Merge pull request #226 from romanowski/docs/update
Docs/update
2 parents 3c29ed7 + e41a69c commit 075f20e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1230
-849
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
Scala CLI is an experimental tool to run/compile/test Scala that aims at being a better `scala` command. It shares some similarities with build tools, but doesn't aim at supporting multi-module projects, nor to be extended via a task system.
88

9+
User-facing documentation can be found on our website: [scala-cli.virtuslab.org](https://scala-cli.virtuslab.org/).
10+
911
## Developer docs
1012

1113
### Requirements

build.sc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,11 @@ class Build(val crossScalaVersion: String)
261261
def runClasspath = T {
262262
super.runClasspath() ++ Seq(localRepoJar())
263263
}
264+
265+
// uncomment below to debug tests in attach mode on 5005 port
266+
// def forkArgs = T {
267+
// super.forkArgs() ++ Seq("-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=y")
268+
// }
264269
}
265270
}
266271

docs

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs_checker/check.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// using scala 3.0.2
2-
// using com.lihaoyi::os-lib:0.7.8
2+
// using lib com.lihaoyi::os-lib:0.7.8
33

44
import scala.util.matching.Regex
55

examples/index/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55

66
# Cookbook
77

8-
This part contains a set of recipes how to use scala-cli within given situations.
8+
This part contains a set of recipes how to use scala-cli within given situations. The cookbooks are intended to provide a solution to task at hand without providing too many details.
9+
10+
For more in-depth analysis please check out provided [Guides](../guides/ide.md)

examples/scala-scripts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ All the features from non-scripts are working with Scala Scripts, such as waitin
7676

7777
### Package
7878

79-
Run `package` to the Scala CLI to package your script to Leighweight JAR file.
79+
Run `package` to the Scala CLI to package your script to lightweight executable JAR file.
8080

8181
```bash
8282
scala-cli package HelloScript.sc

examples/scripting/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ print all files located in path passed as the first argument
1212
Create a file name `ls.sc`
1313
```scala
1414
#!/usr/bin/env scala-cli
15-
using "com.lihaoyi::os-lib:0.7.8"
15+
// using lib "com.lihaoyi::os-lib:0.7.8"
1616
val cwd = if(args.nonEmpty) os.Path(args(0), os.pwd) else os.pwd
1717
println(os.list(cwd).map(_.last).mkString("\n"))
1818
```

gifs/scenarios/demo.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
99
if [[ -z "${ASCIINEMA_REC}" ]]; then
1010
# Warm up scala-cli
1111
echo "println(1)" | scala-cli -
12-
echo "// using \"org.scalameta::munit:0.7.29\"" | scala-cli test -
12+
echo "// using lib \"org.scalameta::munit:0.7.29\"" | scala-cli test -
1313
# or do other preparation (e.g. create code)
1414
else
1515
. $SCRIPT_DIR/../demo-magic.sh
@@ -34,7 +34,7 @@ EOF
3434
clear
3535

3636
cat <<EOF | updateFile demo.test.scala
37-
// using "org.scalameta::munit:0.7.29"
37+
// using lib "org.scalameta::munit:0.7.29"
3838
3939
class demoTest extends munit.FunSuite {
4040
test("test nice args") {

gifs/scenarios/sc-files-support.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.

modules/build/src/main/scala/scala/build/CrossSources.scala

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ final case class CrossSources(
6565

6666
object CrossSources {
6767

68+
private def withinTestSubDirectory(p: ScopePath, inputs: Inputs): Boolean =
69+
p.root.exists { path =>
70+
val fullPath = path / p.path
71+
inputs.elements.exists {
72+
case Inputs.Directory(path) =>
73+
// Is this file subdirectory of given dir and if we have a subdiretory 'test' on the way
74+
fullPath.startsWith(path) &&
75+
fullPath.relativeTo(path).segments.contains("test")
76+
case _ => false
77+
}
78+
}
79+
6880
def forInputs(
6981
inputs: Inputs,
7082
preprocessors: Seq[Preprocessor]
@@ -88,11 +100,23 @@ object CrossSources {
88100

89101
val scopedRequirements = preprocessedSources.flatMap(_.scopedRequirements)
90102
val scopedRequirementsByRoot = scopedRequirements.groupBy(_.path.root)
91-
def baseReqs(path: ScopePath): BuildRequirements =
92-
scopedRequirementsByRoot
93-
.getOrElse(path.root, Nil)
94-
.flatMap(_.valueFor(path).toSeq)
95-
.foldLeft(BuildRequirements())(_ orElse _)
103+
def baseReqs(path: ScopePath): BuildRequirements = {
104+
val fromDirectives =
105+
scopedRequirementsByRoot
106+
.getOrElse(path.root, Nil)
107+
.flatMap(_.valueFor(path).toSeq)
108+
.foldLeft(BuildRequirements())(_ orElse _)
109+
110+
// Scala-cli treats all `.test.scala` files tests as well as
111+
// files from witin `test` subdirectory from provided input directories
112+
// If file has `using target <scope>` directive this take precendeces.
113+
if (
114+
fromDirectives.scope.isEmpty &&
115+
(path.path.last.endsWith(".test.scala") || withinTestSubDirectory(path, inputs))
116+
)
117+
fromDirectives.copy(scope = Some(BuildRequirements.ScopeRequirement(Scope.Test)))
118+
else fromDirectives
119+
}
96120

97121
val buildOptions = for {
98122
s <- preprocessedSources

0 commit comments

Comments
 (0)