Skip to content

Commit 4ad1182

Browse files
Rename workspace dir from .scala to .scala-build
1 parent 292db3a commit 4ad1182

File tree

14 files changed

+43
-24
lines changed

14 files changed

+43
-24
lines changed

build.sc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import $file.project.settings, settings.{
1313
ScalaCliCrossSbtModule,
1414
ScalaCliScalafixModule,
1515
localRepoResourcePath,
16-
platformExecutableJarExtension
16+
platformExecutableJarExtension,
17+
workspaceDirName
1718
}
1819

1920
import java.io.File
@@ -267,6 +268,8 @@ class Build(val crossScalaVersion: String)
267268
| def defaultScalaVersion = "${Scala.defaultUser}"
268269
| def defaultScala212Version = "${Scala.scala212}"
269270
| def defaultScala213Version = "${Scala.scala213}"
271+
|
272+
| def workspaceDirName = "$workspaceDirName"
270273
|}
271274
|""".stripMargin
272275
if (!os.isFile(dest) || os.read(dest) != code)
@@ -435,6 +438,7 @@ trait CliIntegrationBase extends SbtModule with ScalaCliPublishModule with HasTe
435438
| def dockerAlpineTestImage = "${Docker.alpineTestImage}"
436439
| def mostlyStaticDockerfile = "${mostlyStaticDockerfile.toString.replace("\\", "\\\\")}"
437440
| def cs = "${settings.cs().replace("\\", "\\\\")}"
441+
| def workspaceDirName = "$workspaceDirName"
438442
|}
439443
|""".stripMargin
440444
if (!os.isFile(dest) || os.read(dest) != code)
@@ -445,10 +449,10 @@ trait CliIntegrationBase extends SbtModule with ScalaCliPublishModule with HasTe
445449

446450
def test(args: String*) = T.command {
447451
val res = super.test(args: _*)()
448-
val dotScalaInRoot = os.pwd / ".scala"
452+
val dotScalaInRoot = os.pwd / workspaceDirName
449453
assert(
450454
!os.isDir(dotScalaInRoot),
451-
s"Expected .scala ($dotScalaInRoot) not to have been created"
455+
s"Expected $workspaceDirName ($dotScalaInRoot) not to have been created"
452456
)
453457
res
454458
}

modules/build/src/main/scala/scala/build/Build.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ object Build {
272272
resourceFilePath <- os.walk(resourceDirPath).filter(os.isFile(_))
273273
relativeResourcePath = resourceFilePath.relativeTo(resourceDirPath)
274274
// dismiss files generated by scala-cli
275-
if !relativeResourcePath.startsWith(os.rel / ".scala")
275+
if !relativeResourcePath.startsWith(os.rel / Constants.workspaceDirName)
276276
} {
277277
val destPath = b.output / relativeResourcePath
278278
os.copy(
@@ -335,7 +335,7 @@ object Build {
335335
}
336336

337337
def classesRootDir(root: os.Path, projectName: String): os.Path =
338-
root / ".scala" / projectName / "classes"
338+
root / Constants.workspaceDirName / projectName / "classes"
339339
def classesDir(root: os.Path, projectName: String, scope: Scope): os.Path =
340340
classesRootDir(root, projectName) / scope.name
341341

@@ -380,7 +380,7 @@ object Build {
380380
bloopConfig,
381381
"scala-cli",
382382
Constants.version,
383-
(inputs.workspace / ".scala").toNIO,
383+
(inputs.workspace / Constants.workspaceDirName).toNIO,
384384
classesDir0.toNIO,
385385
buildClient,
386386
threads.bloop,
@@ -443,7 +443,7 @@ object Build {
443443
bloopConfig,
444444
"scala-cli",
445445
Constants.version,
446-
(inputs.workspace / ".scala").toNIO,
446+
(inputs.workspace / Constants.workspaceDirName).toNIO,
447447
classesDir0.toNIO,
448448
buildClient,
449449
threads.bloop,
@@ -610,7 +610,7 @@ object Build {
610610
value(validate(logger, options))
611611

612612
val project = Project(
613-
directory = inputs.workspace / ".scala",
613+
directory = inputs.workspace / Constants.workspaceDirName,
614614
workspace = inputs.workspace,
615615
classesDir = classesDir0,
616616
scalaCompiler = scalaCompiler,
@@ -868,7 +868,7 @@ object Build {
868868
bloopServer: bloop.BloopServer
869869
): Either[BuildException, Option[Build]] = either {
870870
val jmhProjectName = inputs.projectName + "_jmh"
871-
val jmhOutputDir = inputs.workspace / ".scala" / jmhProjectName
871+
val jmhOutputDir = inputs.workspace / Constants.workspaceDirName / jmhProjectName
872872
os.remove.all(jmhOutputDir)
873873
val jmhSourceDir = jmhOutputDir / "sources"
874874
val jmhResourceDir = jmhOutputDir / "resources"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import java.security.MessageDigest
77
import java.util.zip.{ZipEntry, ZipInputStream}
88

99
import scala.annotation.tailrec
10+
import scala.build.internal.Constants
1011
import scala.build.options.Scope
1112
import scala.build.preprocessing.ScopePath
1213
import scala.util.Properties
@@ -104,7 +105,7 @@ final case class Inputs(
104105
else copy(elements = elements ++ extraElements)
105106

106107
def generatedSrcRoot(scope: Scope): os.Path =
107-
workspace / ".scala" / projectName / "src_generated" / scope.name
108+
workspace / Constants.workspaceDirName / projectName / "src_generated" / scope.name
108109

109110
private def inHomeDir(directories: Directories): Inputs =
110111
copy(

modules/build/src/main/scala/scala/build/bsp/BspImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ final class BspImpl(
329329
bloopRifleConfig,
330330
"scala-cli",
331331
Constants.version,
332-
(inputs.workspace / ".scala").toNIO,
332+
(inputs.workspace / Constants.workspaceDirName).toNIO,
333333
classesDir.toNIO,
334334
localClient,
335335
threads.buildThreads.bloop,

modules/build/src/main/scala/scala/build/bsp/HasGeneratedSources.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package scala.build.bsp
33
import ch.epfl.scala.{bsp4j => b}
44

55
import scala.build.GeneratedSource
6+
import scala.build.internal.Constants
67
import scala.build.options.Scope
78

89
trait HasGeneratedSources {
@@ -59,6 +60,13 @@ object HasGeneratedSources {
5960
var targetUriOpt: Option[String] = None
6061
) {
6162
targetUriOpt =
62-
Some((bloopWorkspace / ".scala").toIO.toURI.toASCIIString.stripSuffix("/") + "/?id=" + name)
63+
Some(
64+
(bloopWorkspace / Constants.workspaceDirName)
65+
.toIO
66+
.toURI
67+
.toASCIIString
68+
.stripSuffix("/") +
69+
"/?id=" + name
70+
)
6371
}
6472
}

modules/build/src/main/scala/scala/build/options/ScalaNativeOptions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final case class ScalaNativeOptions(
2121
) {
2222

2323
def nativeWorkDir(root: os.Path, projectName: String): os.Path =
24-
root / ".scala" / projectName / "native"
24+
root / Constants.workspaceDirName / projectName / "native"
2525

2626
def finalVersion = version.map(_.trim).filter(_.nonEmpty).getOrElse(Constants.scalaNativeVersion)
2727

modules/cli/src/main/scala/scala/cli/ScalaCli.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import java.io.{ByteArrayOutputStream, PrintStream}
88
import java.nio.charset.StandardCharsets
99
import java.nio.file.InvalidPathException
1010

11+
import scala.build.internal.Constants
1112
import scala.cli.commands._
1213
import scala.cli.internal.Argv0
1314
import scala.cli.launcher.{LauncherCli, LauncherOptions}
@@ -117,7 +118,7 @@ object ScalaCli extends CommandsEntryPoint {
117118
catch {
118119
case e: Throwable if !isCI =>
119120
val workspace = CurrentParams.workspaceOpt.getOrElse(os.pwd)
120-
val dir = workspace / ".scala" / "stacktraces"
121+
val dir = workspace / Constants.workspaceDirName / "stacktraces"
121122
os.makeDir.all(dir)
122123
import java.time.Instant
123124

modules/cli/src/main/scala/scala/cli/commands/Clean.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scala.cli.commands
22

33
import caseapp._
44

5+
import scala.build.internal.Constants
56
import scala.build.{Inputs, Os}
67
import scala.cli.CurrentParams
78

@@ -21,7 +22,7 @@ object Clean extends ScalaCommand[CleanOptions] {
2122
case Right(i) => i
2223
}
2324
CurrentParams.workspaceOpt = Some(inputs.workspace)
24-
val workDir = inputs.workspace / ".scala"
25+
val workDir = inputs.workspace / Constants.workspaceDirName
2526
val (_, bspEntry) = options.bspFile.bspDetails(inputs.workspace)
2627

2728
val logger = options.logging.logger

modules/cli/src/main/scala/scala/cli/commands/SetupIde.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ object SetupIde extends ScalaCommand[SetupIdeOptions] {
9292
value(downloadDeps(inputs, options.buildOptions, logger))
9393

9494
val (bspName, bspJsonDestination) = options.bspFile.bspDetails(inputs.workspace)
95-
val scalaCliBspJsonDestination = inputs.workspace / ".scala" / "ide-options.json"
95+
val scalaCliBspJsonDestination =
96+
inputs.workspace / Constants.workspaceDirName / "ide-options.json"
9697

9798
// Ensure the path to the CLI is absolute
9899
val absolutePathToScalaCli: String = {

modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
128128
}
129129

130130
def checkTargetUri(root: os.Path, uri: String): Unit = {
131-
val baseUri = TestUtil.normalizeUri((root / ".scala").toNIO.toUri.toASCIIString)
132-
.stripSuffix("/")
131+
val baseUri =
132+
TestUtil.normalizeUri((root / Constants.workspaceDirName).toNIO.toUri.toASCIIString)
133+
.stripSuffix("/")
133134
val expectedPrefixes = Set(
134135
baseUri + "?id=",
135136
baseUri + "/?id="
@@ -177,7 +178,7 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
177178
inputs.fromRoot { root =>
178179
os.proc(TestUtil.cli, command, ".", extraOptions).call(cwd = root, stdout = os.Inherit)
179180
val details = readBspConfig(root)
180-
val expectedIdeOptionsFile = root / ".scala" / "ide-options.json"
181+
val expectedIdeOptionsFile = root / Constants.workspaceDirName / "ide-options.json"
181182
val expectedArgv = Seq(
182183
TestUtil.cliPath,
183184
"bsp",
@@ -225,7 +226,7 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
225226
TestUtil.cliPath,
226227
"bsp",
227228
"--json-options",
228-
(root / "directory" / ".scala" / "ide-options.json").toString,
229+
(root / "directory" / Constants.workspaceDirName / "ide-options.json").toString,
229230
s"${(root / "directory").toString}${File.separator}"
230231
)
231232
expect(details.argv == expectedArgv)

0 commit comments

Comments
 (0)