Skip to content

Commit 4a80f63

Browse files
Merge pull request #143 from alexarchambault/remove-conf-file
Remove conf file
2 parents f798cfd + 527307b commit 4a80f63

File tree

66 files changed

+982
-790
lines changed

Some content is hidden

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

66 files changed

+982
-790
lines changed

build.sc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ class Build(val crossScalaVersion: String)
156156
Deps.nativeTools,
157157
Deps.osLib,
158158
Deps.pprint,
159-
Deps.pureconfig,
160159
Deps.scalaJsEnvNodeJs,
161160
Deps.scalaJsLinkerInterface,
162161
Deps.scalaJsTestAdapter,

modules/build-macros/src/main/scala/scala/build/EitherAwait.scala renamed to modules/build-macros/src/main/scala/scala/build/EitherCps.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import scala.annotation.compileTimeOnly
66
import scala.language.experimental.macros
77
import scala.reflect.macros.blackbox
88

9-
object EitherAwait {
9+
object EitherCps {
1010
final case class Helper[E]() {
1111
def apply[T](body: T): Either[E, T] = macro impl
1212
}
1313
def either[E]: Helper[E] = Helper[E]()
14-
@compileTimeOnly("[async] `value` must be enclosed in `optionally`")
14+
@compileTimeOnly("[async] `value` must be enclosed in `EitherCps.either`")
1515
def value[E, T](option: Either[E, T]): T = ???
1616
def impl(c: blackbox.Context)(body: c.Tree): c.Tree = {
1717
import c.universe._
18-
val awaitSym = typeOf[EitherAwait.type].decl(TermName("value"))
18+
val awaitSym = typeOf[EitherCps.type].decl(TermName("value"))
1919
def mark(t: DefDef): Tree =
2020
c.internal.markForAsyncTransform(c.internal.enclosingOwner, t, awaitSym, Map.empty)
2121
val name = TypeName("stateMachine$async")

modules/build-macros/src/main/scala/scala/build/EitherTraverse.scala renamed to modules/build-macros/src/main/scala/scala/build/EitherSequence.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package scala.build
22

33
import scala.collection.mutable.ListBuffer
44

5-
object EitherTraverse {
6-
def traverse[E, T](eithers: Seq[Either[E, T]]): Either[::[E], Seq[T]] = {
5+
object EitherSequence {
6+
def sequence[E, T](eithers: Seq[Either[E, T]]): Either[::[E], Seq[T]] = {
77
val errors = new ListBuffer[E]
88
val values = new ListBuffer[T]
99
eithers.foreach {

modules/build-macros/src/main/scala/scala/build/Ops.scala

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@ package scala.build
22

33
object Ops {
44
implicit class EitherSeqOps[E, T](private val seq: Seq[Either[E, T]]) extends AnyVal {
5-
def traverse: Either[::[E], Seq[T]] =
6-
EitherTraverse.traverse(seq)
5+
def sequence: Either[::[E], Seq[T]] =
6+
EitherSequence.sequence(seq)
7+
}
8+
9+
implicit class EitherOptOps[E, T](private val opt: Option[Either[E, T]]) extends AnyVal {
10+
def sequence: Either[E, Option[T]] =
11+
opt match {
12+
case None => Right(None)
13+
case Some(Left(e)) => Left(e)
14+
case Some(Right(t)) => Right(Some(t))
15+
}
716
}
817

918
implicit class EitherThrowOps[E <: Throwable, T](private val either: Either[E, T])
@@ -14,4 +23,22 @@ object Ops {
1423
case Right(t) => t
1524
}
1625
}
26+
27+
implicit class EitherMap3[Ex <: Throwable, ExA <: Ex, ExB <: Ex, ExC <: Ex, A, B, C](
28+
private val eithers: (Either[ExA, A], Either[ExB, B], Either[ExC, C])
29+
) extends AnyVal {
30+
def traverseN: Either[::[Ex], (A, B, C)] =
31+
eithers match {
32+
case (Right(a), Right(b), Right(c)) => Right((a, b, c))
33+
case _ =>
34+
val errors = eithers._1.left.toOption.toSeq ++
35+
eithers._2.left.toOption.toSeq ++
36+
eithers._3.left.toOption.toSeq
37+
val errors0 = errors.toList match {
38+
case Nil => sys.error("Cannot happen")
39+
case h :: t => ::(h, t)
40+
}
41+
Left(errors0)
42+
}
43+
}
1744
}

modules/build/src/main/scala/scala/build/Artifacts.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import dependency._
1111
import java.nio.file.Path
1212

1313
import scala.build.errors.{BuildException, CompositeBuildException}
14-
import scala.build.EitherAwait.{either, value}
14+
import scala.build.EitherCps.{either, value}
1515
import scala.build.internal.Constants
1616
import scala.build.internal.Constants._
1717
import scala.build.internal.Util.ScalaDependencyOps
@@ -190,7 +190,7 @@ object Artifacts {
190190
artifacts(Seq(dep0), allExtraRepositories, params, logger)
191191
.map(_.map { case (url, path) => (dep0, url, path) })
192192
}
193-
.traverse
193+
.sequence
194194
.left.map(CompositeBuildException(_))
195195
.map(_.flatten)
196196
}

modules/build/src/main/scala/scala/build/Bloop.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.io.File
88
import java.nio.file.Path
99

1010
import scala.build.blooprifle.BloopRifleConfig
11-
import scala.build.EitherAwait.{either, value}
11+
import scala.build.EitherCps.{either, value}
1212
import scala.build.errors.ModuleFormatError
1313
import scala.build.internal.Util.ScalaDependencyOps
1414
import scala.build.Ops._

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import com.swoval.files.FileTreeViews.Observer
66
import com.swoval.files.{FileTreeRepositories, PathWatcher, PathWatchers}
77
import dependency._
88
import scala.build.blooprifle.BloopRifleConfig
9-
import scala.build.EitherAwait.{either, value}
9+
import scala.build.EitherCps.{either, value}
1010
import scala.build.errors.{BuildException, CompositeBuildException}
1111
import scala.build.internal.{Constants, CustomCodeWrapper, MainClass, Util}
1212
import scala.build.Ops._
@@ -117,10 +117,12 @@ object Build {
117117
crossBuilds: Boolean
118118
): Either[BuildException, (Build, Seq[Build])] = either {
119119

120-
val crossSources = CrossSources.forInputs(
121-
inputs,
122-
Sources.defaultPreprocessors(options.scriptOptions.codeWrapper.getOrElse(CustomCodeWrapper))
123-
)
120+
val crossSources = value {
121+
CrossSources.forInputs(
122+
inputs,
123+
Sources.defaultPreprocessors(options.scriptOptions.codeWrapper.getOrElse(CustomCodeWrapper))
124+
)
125+
}
124126

125127
val sources = crossSources.sources(options)
126128

@@ -149,7 +151,7 @@ object Build {
149151
if (crossBuilds)
150152
value {
151153
options0.crossOptions.map(opt => doBuild(opt))
152-
.traverse
154+
.sequence
153155
.left.map(CompositeBuildException(_))
154156
}
155157
else
@@ -314,8 +316,7 @@ object Build {
314316
val isHidden = relPath.segments.exists(_.startsWith("."))
315317
def isScalaFile = relPath.last.endsWith(".sc") || relPath.last.endsWith(".scala")
316318
def isJavaFile = relPath.last.endsWith(".java")
317-
def isConfFile = relPath.last == "scala.conf" || relPath.last.endsWith(".scala.conf")
318-
!isHidden && (isScalaFile || isJavaFile || isConfFile)
319+
!isHidden && (isScalaFile || isJavaFile)
319320
case _ => _ => true
320321
}
321322

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

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
package scala.build
22

3+
import scala.build.EitherCps.{either, value}
4+
import scala.build.errors.BuildException
35
import scala.build.internal.CodeWrapper
4-
import scala.build.options.{BuildOptions, BuildRequirements, HasBuildRequirements}
6+
import scala.build.Ops._
7+
import scala.build.options.{BuildOptions, BuildRequirements, HasBuildRequirements, Platform}
58
import scala.build.preprocessing._
9+
import scala.build.errors.CompositeBuildException
610

711
final case class CrossSources(
812
paths: Seq[HasBuildRequirements[(os.Path, os.RelPath)]],
@@ -29,11 +33,11 @@ final case class CrossSources(
2933

3034
val platform =
3135
if (buildOptionsWithScalaVersion.scalaJsOptions.enable)
32-
BuildRequirements.Platform.JS
36+
Platform.JS
3337
else if (buildOptionsWithScalaVersion.scalaNativeOptions.enable)
34-
BuildRequirements.Platform.Native
38+
Platform.Native
3539
else
36-
BuildRequirements.Platform.JVM
40+
Platform.JVM
3741

3842
// FIXME Not 100% sure the way we compute the intermediate and final BuildOptions
3943
// is consistent (we successively filter out / retain options to compute a scala
@@ -66,11 +70,17 @@ object CrossSources {
6670
def forInputs(
6771
inputs: Inputs,
6872
preprocessors: Seq[Preprocessor]
69-
): CrossSources = {
73+
): Either[BuildException, CrossSources] = either {
7074

71-
val preprocessedSources = inputs.flattened().flatMap { elem =>
72-
preprocessors.iterator.flatMap(p => p.preprocess(elem).iterator).toStream.headOption
73-
.getOrElse(Nil) // FIXME Warn about unprocessed stuff?
75+
val preprocessedSources = value {
76+
inputs.flattened()
77+
.map { elem =>
78+
preprocessors.iterator.flatMap(p => p.preprocess(elem).iterator).toStream.headOption
79+
.getOrElse(Right(Nil)) // FIXME Warn about unprocessed stuff?
80+
}
81+
.sequence
82+
.left.map(CompositeBuildException(_))
83+
.map(_.flatten)
7484
}
7585

7686
val buildOptions = preprocessedSources.flatMap {
@@ -98,17 +108,19 @@ object CrossSources {
98108
Nil
99109
}
100110

101-
val mainClassOpt = inputs.mainClassElement
102-
.collect {
103-
case elem: Inputs.SingleElement =>
104-
preprocessors.iterator
105-
.flatMap(p => p.preprocess(elem).iterator)
106-
.toStream.headOption
107-
.getOrElse(Nil)
108-
.flatMap(_.mainClassOpt.toSeq)
109-
.headOption
110-
}
111-
.flatten
111+
val mainClassOpt = value {
112+
inputs.mainClassElement
113+
.collect {
114+
case elem: Inputs.SingleElement =>
115+
preprocessors.iterator
116+
.flatMap(p => p.preprocess(elem).iterator)
117+
.toStream.headOption
118+
.getOrElse(Right(Nil))
119+
.map(_.flatMap(_.mainClassOpt.toSeq).headOption)
120+
}
121+
.sequence
122+
.map(_.flatten)
123+
}
112124

113125
val paths = preprocessedSources.collect {
114126
case d: PreprocessedSource.OnDisk =>

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

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ package scala.build
22

33
import java.io.{ByteArrayInputStream, ByteArrayOutputStream}
44
import java.math.BigInteger
5-
import java.net.URI
65
import java.nio.charset.StandardCharsets
7-
import java.nio.file.{Files, Paths}
86
import java.security.MessageDigest
97
import java.util.zip.{ZipEntry, ZipInputStream}
108
import scala.annotation.tailrec
11-
import scala.util.Properties
129
import scala.util.matching.Regex
1310

1411
final case class Inputs(
@@ -38,8 +35,6 @@ final case class Inputs(
3835
Inputs.ScalaFile(d.path, p.subRelativeTo(d.path))
3936
case p if p.last.endsWith(".sc") =>
4037
Inputs.Script(d.path, p.subRelativeTo(d.path))
41-
case p if p.last == "scala.conf" || p.last.endsWith(".scala.conf") =>
42-
Inputs.ConfigFile(p)
4338
}
4439
.toVector
4540
case _: Inputs.ResourceDirectory =>
@@ -77,8 +72,6 @@ final case class Inputs(
7772
Inputs.ScalaFile(d.path, p.subRelativeTo(d.path))
7873
case p if p.last.endsWith(".sc") =>
7974
Inputs.Script(d.path, p.subRelativeTo(d.path))
80-
case p if p.last == "scala.conf" || p.last.endsWith(".scala.conf") =>
81-
Inputs.ConfigFile(p)
8275
}
8376
.toVector
8477
case _: Inputs.ResourceDirectory =>
@@ -145,8 +138,6 @@ object Inputs {
145138
final case class Directory(path: os.Path) extends OnDisk with Compiled
146139
final case class ResourceDirectory(path: os.Path) extends OnDisk
147140

148-
final case class ConfigFile(path: os.Path) extends SingleFile
149-
150141
final case class VirtualScript(content: Array[Byte], source: String, wrapperPath: os.SubPath)
151142
extends Virtual with AnyScalaFile
152143
final case class VirtualScalaFile(content: Array[Byte], source: String)
@@ -164,7 +155,6 @@ object Inputs {
164155
case _: Inputs.JavaFile => "java:"
165156
case _: Inputs.ScalaFile => "scala:"
166157
case _: Inputs.Script => "sc:"
167-
case _: Inputs.ConfigFile => "config:"
168158
}
169159
Iterator(prefix, elem.path.toString, "\n").map(bytes)
170160
case v: Inputs.Virtual =>
@@ -329,22 +319,8 @@ object Inputs {
329319
else
330320
forNonEmptyArgs(args, cwd, directories, baseProjectName, download, stdinOpt, acceptFds)
331321

332-
def default(cwd: os.Path = Os.pwd): Option[Inputs] = {
333-
val hasConf = os.isFile(cwd / "scala.conf") ||
334-
os.list(cwd).filter(os.isFile(_)).exists(_.last.endsWith(".scala.conf"))
335-
if (hasConf)
336-
Some {
337-
Inputs(
338-
Seq(Directory(cwd)),
339-
mainClassElement = None,
340-
workspace = cwd,
341-
baseProjectName = "project",
342-
mayAppendHash = true
343-
)
344-
}
345-
else
346-
None
347-
}
322+
def default(cwd: os.Path = Os.pwd): Option[Inputs] =
323+
None
348324

349325
def empty(workspace: os.Path): Inputs =
350326
Inputs(

modules/build/src/main/scala/scala/build/ReplArtifacts.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import java.nio.file.Path
55
import dependency._
66

77
import scala.build.errors.BuildException
8-
import scala.build.EitherAwait.{either, value}
8+
import scala.build.EitherCps.{either, value}
99

1010
final case class ReplArtifacts(
1111
replArtifacts: Seq[(String, Path)],

0 commit comments

Comments
 (0)