Skip to content

Commit bf5ebc2

Browse files
authored
Merge pull request #1560 from wleczny/change-settings-filename
Change project settings filename
2 parents f470e88 + 9a32078 commit bf5ebc2

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ object CrossSources {
236236
lazy val subPath = sourcePath.subRelativeTo(dir)
237237
if (os.isDir(sourcePath))
238238
Right(Inputs.singleFilesFromDirectory(Inputs.Directory(sourcePath), enableMarkdown))
239-
else if (sourcePath == os.sub / "project.settings.scala")
240-
Right(Seq(Inputs.SettingsScalaFile(dir, subPath)))
239+
else if (sourcePath == os.sub / "project.scala")
240+
Right(Seq(Inputs.ProjectScalaFile(dir, subPath)))
241241
else if (sourcePath.ext == "scala") Right(Seq(Inputs.SourceScalaFile(dir, subPath)))
242242
else if (sourcePath.ext == "sc") Right(Seq(Inputs.Script(dir, subPath)))
243243
else if (sourcePath.ext == "java") Right(Seq(Inputs.JavaFile(dir, subPath)))

modules/build/src/main/scala/scala/build/Inputs.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ object Inputs {
194194
}
195195
final case class SourceScalaFile(base: os.Path, subPath: os.SubPath)
196196
extends OnDisk with SourceFile with ScalaFile
197-
final case class SettingsScalaFile(base: os.Path, subPath: os.SubPath)
197+
final case class ProjectScalaFile(base: os.Path, subPath: os.SubPath)
198198
extends OnDisk with SourceFile with ScalaFile
199199
final case class JavaFile(base: os.Path, subPath: os.SubPath)
200200
extends OnDisk with SourceFile with Compiled {
@@ -237,8 +237,8 @@ object Inputs {
237237
.collect {
238238
case p if p.last.endsWith(".java") =>
239239
Inputs.JavaFile(d.path, p.subRelativeTo(d.path))
240-
case p if p.last == "project.settings.scala" =>
241-
Inputs.SettingsScalaFile(d.path, p.subRelativeTo(d.path))
240+
case p if p.last == "project.scala" =>
241+
Inputs.ProjectScalaFile(d.path, p.subRelativeTo(d.path))
242242
case p if p.last.endsWith(".scala") =>
243243
Inputs.SourceScalaFile(d.path, p.subRelativeTo(d.path))
244244
case p if p.last.endsWith(".sc") =>
@@ -252,16 +252,16 @@ object Inputs {
252252
.sortBy(_.subPath.segments)
253253
}
254254

255-
def projectSettingsFiles(elements: Seq[Inputs.Element]): Seq[Inputs.SettingsScalaFile] =
255+
def projectSettingsFiles(elements: Seq[Inputs.Element]): Seq[Inputs.ProjectScalaFile] =
256256
elements.flatMap {
257-
case f: SettingsScalaFile => Seq(f)
258-
case d: Directory => Inputs.configFileFromDirectory(d)
259-
case _ => Nil
257+
case f: ProjectScalaFile => Seq(f)
258+
case d: Directory => Inputs.configFileFromDirectory(d)
259+
case _ => Nil
260260
}.distinct
261261

262-
def configFileFromDirectory(d: Inputs.Directory): Seq[Inputs.SettingsScalaFile] =
263-
if (os.exists(d.path / "project.settings.scala"))
264-
Seq(Inputs.SettingsScalaFile(d.path, os.sub / "project.settings.scala"))
262+
def configFileFromDirectory(d: Inputs.Directory): Seq[Inputs.ProjectScalaFile] =
263+
if (os.exists(d.path / "project.scala"))
264+
Seq(Inputs.ProjectScalaFile(d.path, os.sub / "project.scala"))
265265
else Nil
266266

267267
private def inputsHash(elements: Seq[Element]): String = {
@@ -272,7 +272,7 @@ object Inputs {
272272
case _: Inputs.Directory => "dir:"
273273
case _: Inputs.ResourceDirectory => "resource-dir:"
274274
case _: Inputs.JavaFile => "java:"
275-
case _: Inputs.SettingsScalaFile => "config:"
275+
case _: Inputs.ProjectScalaFile => "config:"
276276
case _: Inputs.SourceScalaFile => "scala:"
277277
case _: Inputs.CFile => "c:"
278278
case _: Inputs.Script => "sc:"
@@ -318,7 +318,7 @@ object Inputs {
318318
settingsFiles.headOption.map { s =>
319319
if (settingsFiles.length > 1)
320320
System.err.println(
321-
s"Warning: more than one project.settings.scala file has been found. Setting ${s.base} as the project root directory for this run."
321+
s"Warning: more than one project.scala file has been found. Setting ${s.base} as the project root directory for this run."
322322
)
323323
(s.base, true, WorkspaceOrigin.SourcePaths)
324324
}.orElse {
@@ -458,7 +458,7 @@ object Inputs {
458458
List(resolve(url, content))
459459
}
460460
}
461-
else if (path.last == "project.settings.scala") Right(Seq(SettingsScalaFile(dir, subPath)))
461+
else if (path.last == "project.scala") Right(Seq(ProjectScalaFile(dir, subPath)))
462462
else if (arg.endsWith(".sc")) Right(Seq(Script(dir, subPath)))
463463
else if (arg.endsWith(".scala")) Right(Seq(SourceScalaFile(dir, subPath)))
464464
else if (arg.endsWith(".java")) Right(Seq(JavaFile(dir, subPath)))

modules/build/src/test/scala/scala/build/tests/InputsTests.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ class InputsTests extends munit.FunSuite {
3737
}
3838
}
3939

40-
test("project settings file") {
40+
test("project.scala file") {
4141
val testInputs = TestInputs(
4242
files = Seq(
43-
os.rel / "custom-dir" / "project.settings.scala" -> "",
44-
os.rel / "project.settings.scala" -> s"//> using javaProp \"foo=bar\"".stripMargin,
43+
os.rel / "custom-dir" / "project.scala" -> "",
44+
os.rel / "project.scala" -> s"//> using javaProp \"foo=bar\"".stripMargin,
4545
os.rel / "foo.scala" ->
4646
s"""object Foo {
4747
| def main(args: Array[String]): Unit =
4848
| println("Foo")
4949
|}
5050
|""".stripMargin
5151
),
52-
inputArgs = Seq("custom-dir", "foo.scala", "project.settings.scala")
52+
inputArgs = Seq("foo.scala", "custom-dir", "project.scala")
5353
)
5454
testInputs.withBuild(buildOptions, buildThreads, bloopConfigOpt) {
5555
(root, _, buildMaybe) =>
@@ -84,7 +84,7 @@ class InputsTests extends munit.FunSuite {
8484
}
8585
}
8686

87-
test("passing project settings file and its parent directory") {
87+
test("passing project.scala and its parent directory") {
8888
val testInputs = TestInputs(
8989
files = Seq(
9090
os.rel / "foo.scala" ->
@@ -93,9 +93,9 @@ class InputsTests extends munit.FunSuite {
9393
| println("Foo")
9494
|}
9595
|""".stripMargin,
96-
os.rel / "project.settings.scala" -> ""
96+
os.rel / "project.scala" -> ""
9797
),
98-
inputArgs = Seq(".", "project.settings.scala")
98+
inputArgs = Seq(".", "project.scala")
9999
)
100100
testInputs.withBuild(buildOptions, buildThreads, bloopConfigOpt) {
101101
(root, inputs, _) =>

website/docs/reference/root-dir.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,49 @@ Scala CLI needs a root directory:
1212

1313
## Setting root directory
1414

15-
First of all, Scala CLI checks every passed input (in the same order in which inputs were passed) for the `project.settings.scala` file:
16-
- If the `project.settings.scala` file is passed explicitly as a **source**, Scala CLI sets its parent directory as the root directory.
17-
- If the input is a **directory**, Scala CLI looks for the `project.settings.scala` inside this directory. If the file is found, Scala CLI sets the passed directory as the root directory.
15+
First of all, Scala CLI checks every passed input (in the same order in which inputs were passed) for the `project.scala` file:
16+
- If the `project.scala` file is passed explicitly as a **source**, Scala CLI sets its parent directory as the root directory.
17+
- If the input is a **directory**, Scala CLI looks for the `project.scala` inside this directory. If the file is found, Scala CLI sets the passed directory as the root directory.
1818

19-
If more than one `project.settings.scala` file is found, Scala CLI uses only **the first one** to set the root directory and raises **warning** saying which one was used.
19+
If more than one `project.scala` file is found, Scala CLI uses only **the first one** to set the root directory and raises **warning** saying which one was used.
2020

21-
If no `project.settings.scala` files are found, Scala CLI sets the root directory based on the first file/directory input:
21+
If no `project.scala` files are found, Scala CLI sets the root directory based on the first file/directory input:
2222
- If the input is a **directory**, it is set as the root directory.
2323
- If the input is a **file**, Scala CLI sets its parent directory as the root directory.
2424

2525
If more then one file/directory input has ben passed Scala CLI raises the warning saying which directory has been set as the project root directory.
2626

27-
If no `project.settings.scala` files are found and no file/directory inputs have ben passed, Scala CLI sets the current working directory (where Scala CLI was invoked from) as the project root directory.
27+
If no `project.scala` files are found and no file/directory inputs have ben passed, Scala CLI sets the current working directory (where Scala CLI was invoked from) as the project root directory.
2828

2929
#### Example
3030

3131
Let's say we have the following file structure:
3232

3333
```
3434
project
35-
│ project.settings.scala
35+
│ project.scala
3636
3737
└───dir1
3838
│ │ file1.scala
3939
│ │
4040
│ └───dir2
41-
│ │ project.settings.scala
41+
│ │ project.scala
4242
│ │ file2.scala
4343
4444
└───dir3
45-
│ project.settings.scala
45+
│ project.scala
4646
│ file3.scala
4747
```
4848

4949
And user runs the following command:
5050
```
51-
project> scala-cli dir1/file1.scala dir1/dir2 dir3/project.settings.scala
51+
project> scala-cli dir1/file1.scala dir1/dir2 dir3/project.scala
5252
```
5353

54-
Scala CLI will find 2 `project.settings.scala` files:
55-
- inside `dir2`, since this directory was passed as an input and it has `project.settings.scala` inside.
56-
- inside `dir3`, since `dir3/project.settings.scala` was passed explicitly as a source
54+
Scala CLI will find 2 `project.scala` files:
55+
- inside `dir2`, since this directory was passed as an input and it has `project.scala` inside.
56+
- inside `dir3`, since `dir3/project.scala` was passed explicitly as a source
5757

58-
`dir1/dir2` was passed before `dir3/project.settings.scala`, so `dir2` will be set as the **root** directory for this build.
58+
`dir1/dir2` was passed before `dir3/project.scala`, so `dir2` will be set as the **root** directory for this build.
5959

60-
Since more than one `project.settings.scala` has been found, Scala CLI will raise the warning saying that more than one `project.settings.scala` file has been found and `dir1/dir2` has been set as the project root directory.
60+
Since more than one `project.scala` has been found, Scala CLI will raise the warning saying that more than one `project.scala` file has been found and `dir1/dir2` has been set as the project root directory.

0 commit comments

Comments
 (0)