diff --git a/gifs/scenarios/demo.sh b/gifs/scenarios/demo.sh index c6008806c4..1e84b51d66 100755 --- a/gifs/scenarios/demo.sh +++ b/gifs/scenarios/demo.sh @@ -12,7 +12,7 @@ if [[ -z "${ASCIINEMA_REC}" ]]; then # Warm up scala-cli echo "println(1)" | scala-cli - cat < demo.test.scala | -//> using dep "org.scalameta::munit:0.7.29" +//> using dep org.scalameta::munit:0.7.29 EOF scala-cli test demo.test.scala # or do other preparation (e.g. create code) @@ -56,7 +56,7 @@ EOF clearConsole cat < using dep "org.scalameta::munit:0.7.29" +//> using dep org.scalameta::munit:0.7.29 class demoTest extends munit.FunSuite { test("test nice args") { diff --git a/gifs/scenarios/learning_curve.sh b/gifs/scenarios/learning_curve.sh index ce84130736..c37415deb3 100755 --- a/gifs/scenarios/learning_curve.sh +++ b/gifs/scenarios/learning_curve.sh @@ -19,7 +19,7 @@ else # Put your stuff here cat < using scala "3.0.2" +//> using scala 3.0.2 @main def hello() = println("Hello world from Scala CLI") EOF @@ -31,7 +31,7 @@ EOF clearConsole cat < using scala "2.13.6" +//> using scala 2.13.6 object Hello extends App { println("Hello world from Scala CLI") diff --git a/gifs/scenarios/powerful_scripts.sh b/gifs/scenarios/powerful_scripts.sh index 91580797c5..8ed29e6f0e 100755 --- a/gifs/scenarios/powerful_scripts.sh +++ b/gifs/scenarios/powerful_scripts.sh @@ -10,8 +10,8 @@ SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) if [[ -z "${ASCIINEMA_REC}" ]]; then # Warm up scala-cli - echo '//> using dep "com.lihaoyi::os-lib:0.9.1"' | scala-cli - - echo '//> using dep "com.lihaoyi::pprint:0.8.1"' | scala-cli - + echo '//> using dep com.lihaoyi::os-lib:0.9.1' | scala-cli - + echo '//> using dep com.lihaoyi::pprint:0.8.1' | scala-cli - # or do other preparation (e.g. create code) else . $SCRIPT_DIR/../demo-magic.sh @@ -20,8 +20,8 @@ else # Put your stuff here cat < using dep "com.lihaoyi::os-lib:0.9.1" -//> using dep "com.lihaoyi::pprint:0.8.1" +//> using dep com.lihaoyi::os-lib:0.9.1 +//> using dep com.lihaoyi::pprint:0.8.1 import pprint._ import os._ diff --git a/gifs/scenarios/projects.sh b/gifs/scenarios/projects.sh index 984721292e..1abc62725e 100755 --- a/gifs/scenarios/projects.sh +++ b/gifs/scenarios/projects.sh @@ -21,7 +21,7 @@ else # Put your stuff here cat < using dep "com.softwaremill.sttp.client3::core:3.3.18" +//> using dep com.softwaremill.sttp.client3::core:3.3.18 import sttp.client3._ // https://sttp.softwaremill.com/en/latest/quickstart.html diff --git a/gifs/scenarios/scripting.sh b/gifs/scenarios/scripting.sh index 74d4e578d0..a57b816ff1 100755 --- a/gifs/scenarios/scripting.sh +++ b/gifs/scenarios/scripting.sh @@ -24,7 +24,7 @@ Hello World from file EOF cat < using dep "com.lihaoyi::os-lib::0.9.1" +//> using dep com.lihaoyi::os-lib::0.9.1 val filePath = os.pwd / "file" val fileContent = os.read(filePath) diff --git a/modules/build/src/main/scala/scala/build/CrossSources.scala b/modules/build/src/main/scala/scala/build/CrossSources.scala index 649bb30cca..b4e3e542ae 100644 --- a/modules/build/src/main/scala/scala/build/CrossSources.scala +++ b/modules/build/src/main/scala/scala/build/CrossSources.scala @@ -310,7 +310,7 @@ object CrossSources { } yield mainClass val pathsWithDirectivePositions - : Seq[(WithBuildRequirements[(os.Path, os.RelPath)], Option[DirectivesPositions])] = + : Seq[(WithBuildRequirements[(os.Path, os.RelPath)], Option[Position.File])] = preprocessedSources.collect { case d: PreprocessedSource.OnDisk => val baseReqs0 = baseReqs(d.scopePath) @@ -320,7 +320,7 @@ object CrossSources { ) -> d.directivesPositions } val inMemoryWithDirectivePositions - : Seq[(WithBuildRequirements[Sources.InMemory], Option[DirectivesPositions])] = + : Seq[(WithBuildRequirements[Sources.InMemory], Option[Position.File])] = preprocessedSources.collect { case m: PreprocessedSource.InMemory => val baseReqs0 = baseReqs(m.scopePath) @@ -330,7 +330,7 @@ object CrossSources { ) -> m.directivesPositions } val unwrappedScriptsWithDirectivePositions - : Seq[(WithBuildRequirements[Sources.UnwrappedScript], Option[DirectivesPositions])] = + : Seq[(WithBuildRequirements[Sources.UnwrappedScript], Option[Position.File])] = preprocessedSources.collect { case m: PreprocessedSource.UnwrappedScript => val baseReqs0 = baseReqs(m.scopePath) @@ -347,10 +347,8 @@ object CrossSources { WithBuildRequirements(BuildRequirements(), _) ) - lazy val allPathsWithDirectivesByScope: Map[Scope, Seq[(os.Path, DirectivesPositions)]] = - (pathsWithDirectivePositions ++ - inMemoryWithDirectivePositions ++ - unwrappedScriptsWithDirectivePositions) + lazy val allPathsWithDirectivesByScope: Map[Scope, Seq[(os.Path, Position.File)]] = + (pathsWithDirectivePositions ++ inMemoryWithDirectivePositions ++ unwrappedScriptsWithDirectivePositions) .flatMap { (withBuildRequirements, directivesPositions) => val scope = withBuildRequirements.scopedValue(Scope.Main).scope val path: os.Path = withBuildRequirements.value match @@ -384,7 +382,7 @@ object CrossSources { .foreach { (_, directivesPositions) => logger.diagnostic( s"Using directives detected in multiple files. It is recommended to keep them centralized in the $projectFilePath file.", - positions = Seq(directivesPositions.all.maxBy(_.endPos._1)) + positions = Seq(directivesPositions) ) } } diff --git a/modules/build/src/main/scala/scala/build/preprocessing/ExtractedDirectives.scala b/modules/build/src/main/scala/scala/build/preprocessing/ExtractedDirectives.scala index e5fe655297..4f4846ec0f 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/ExtractedDirectives.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/ExtractedDirectives.scala @@ -1,13 +1,8 @@ package scala.build.preprocessing -import com.virtuslab.using_directives.config.Settings -import com.virtuslab.using_directives.custom.model.{ - UsingDirectiveKind, - UsingDirectiveSyntax, - UsingDirectives -} +import com.virtuslab.using_directives.UsingDirectivesProcessor +import com.virtuslab.using_directives.custom.model.UsingDirectives import com.virtuslab.using_directives.custom.utils.ast.{UsingDef, UsingDefs} -import com.virtuslab.using_directives.{Context, UsingDirectivesProcessor} import scala.annotation.targetName import scala.build.errors.* @@ -19,22 +14,13 @@ import scala.jdk.CollectionConverters.* case class ExtractedDirectives( directives: Seq[StrictDirective], - positions: Option[DirectivesPositions] + positions: Option[Position.File] ) { @targetName("append") def ++(other: ExtractedDirectives): ExtractedDirectives = ExtractedDirectives(directives ++ other.directives, positions) } -case class DirectivesPositions( - codeDirectives: Position.File, - specialCommentDirectives: Position.File, - plainCommentDirectives: Position.File -) { - def all: Seq[Position.File] = - Seq(codeDirectives, specialCommentDirectives, plainCommentDirectives) -} - object ExtractedDirectives { def empty: ExtractedDirectives = ExtractedDirectives(Seq.empty, None) @@ -55,14 +41,8 @@ object ExtractedDirectives { else errors += diag } - val processor = { - val settings = new Settings - settings.setAllowStartWithoutAt(true) - settings.setAllowRequire(false) - val context = new Context(reporter, settings) - new UsingDirectivesProcessor(context) - } - val all = processor.extract(contentChars, true, true).asScala + val processor = new UsingDirectivesProcessor(reporter) + val allDirectives = processor.extract(contentChars).asScala val malformedDirectiveErrors = errors.map(diag => new MalformedDirectiveError(diag.message, diag.positions)).toSeq val maybeCompositeMalformedDirectiveError = @@ -71,65 +51,22 @@ object ExtractedDirectives { else None if (malformedDirectiveErrors.isEmpty || maybeCompositeMalformedDirectiveError.isEmpty) { - def byKind(kind: UsingDirectiveKind) = all.find(_.getKind == kind).get - - val codeDirectives = byKind(UsingDirectiveKind.Code) - val specialCommentDirectives = byKind(UsingDirectiveKind.SpecialComment) - val plainCommentDirectives = byKind(UsingDirectiveKind.PlainComment) - - val directivesPositionsOpt = - if ( - codeDirectives.containsTargetDirectivesOnly && - specialCommentDirectives.containsTargetDirectivesOnly && - plainCommentDirectives.containsTargetDirectivesOnly - ) + val directivesOpt = allDirectives.headOption + val directivesPositionOpt = directivesOpt match { + case Some(directives) if directives.containsTargetDirectivesOnly => None - else - Some(DirectivesPositions( - codeDirectives.getPosition(path), - specialCommentDirectives.getPosition(path), - plainCommentDirectives.getPosition(path) - )) - - def reportWarning(msg: String, values: Seq[UsingDef], before: Boolean = true): Unit = - values.foreach { v => - val astPos = v.getPosition - val (start, end) = - if (before) (0, astPos.getColumn) - else (astPos.getColumn, astPos.getColumn + v.getSyntax.getKeyword.length) - val position = Position.File(path, (astPos.getLine, start), (astPos.getLine, end)) - logger.diagnostic(msg, positions = Seq(position)) - } - - if (codeDirectives.nonEmpty) { - val msg = - "This using directive is ignored. Only using directives starting with //> are supported." - reportWarning(msg, getDirectives(codeDirectives)) + case Some(directives) => Some(directives.getPosition(path)) + case None => None } - if (plainCommentDirectives.nonEmpty) { - val msg = - s"This using directive is ignored. $changeToSpecialCommentMsg" - reportWarning(msg, getDirectives(plainCommentDirectives)) - } - - val usedDirectives = specialCommentDirectives - - // All using directives should use just `using` keyword, no @using or require - reportWarning( - "Deprecated using directive syntax, please use keyword `using`.", - getDirectives(specialCommentDirectives).filter(_.getSyntax != UsingDirectiveSyntax.Using), - before = false - ) - - val flattened = usedDirectives.getFlattenedMap.asScala.toSeq + val flattened = directivesOpt.map(_.getFlattenedMap.asScala.toSeq).getOrElse(Seq.empty) val strictDirectives = flattened.map { case (k, l) => StrictDirective(k.getPath.asScala.mkString("."), l.asScala.toSeq) } - Right(ExtractedDirectives(strictDirectives, directivesPositionsOpt)) + Right(ExtractedDirectives(strictDirectives, directivesPositionOpt)) } else maybeCompositeMalformedDirectiveError match { diff --git a/modules/build/src/main/scala/scala/build/preprocessing/JavaPreprocessor.scala b/modules/build/src/main/scala/scala/build/preprocessing/JavaPreprocessor.scala index bc4c8ed1b8..7b8825e4c3 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/JavaPreprocessor.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/JavaPreprocessor.scala @@ -1,6 +1,5 @@ package scala.build.preprocessing -import com.virtuslab.using_directives.custom.model.UsingDirectiveKind import coursier.cache.ArchiveCache import coursier.util.Task diff --git a/modules/build/src/main/scala/scala/build/preprocessing/MarkdownCodeBlockProcessor.scala b/modules/build/src/main/scala/scala/build/preprocessing/MarkdownCodeBlockProcessor.scala index 72db669f48..90294b1f13 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/MarkdownCodeBlockProcessor.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/MarkdownCodeBlockProcessor.scala @@ -1,7 +1,5 @@ package scala.build.preprocessing -import com.virtuslab.using_directives.custom.model.UsingDirectiveKind - import scala.build.EitherCps.{either, value} import scala.build.Logger import scala.build.errors.BuildException diff --git a/modules/build/src/main/scala/scala/build/preprocessing/PreprocessedSource.scala b/modules/build/src/main/scala/scala/build/preprocessing/PreprocessedSource.scala index 2f82ae0939..1bd2579b96 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/PreprocessedSource.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/PreprocessedSource.scala @@ -1,5 +1,6 @@ package scala.build.preprocessing +import scala.build.Position import scala.build.internal.CodeWrapper import scala.build.options.{BuildOptions, BuildRequirements, WithBuildRequirements} @@ -11,7 +12,7 @@ sealed abstract class PreprocessedSource extends Product with Serializable { def scopedRequirements: Seq[Scoped[BuildRequirements]] def scopePath: ScopePath - def directivesPositions: Option[DirectivesPositions] + def directivesPositions: Option[Position.File] } object PreprocessedSource { @@ -23,7 +24,7 @@ object PreprocessedSource { requirements: Option[BuildRequirements], scopedRequirements: Seq[Scoped[BuildRequirements]], mainClassOpt: Option[String], - directivesPositions: Option[DirectivesPositions] + directivesPositions: Option[Position.File] ) extends PreprocessedSource { def scopePath: ScopePath = ScopePath.fromPath(path) @@ -39,7 +40,7 @@ object PreprocessedSource { scopedRequirements: Seq[Scoped[BuildRequirements]], mainClassOpt: Option[String], scopePath: ScopePath, - directivesPositions: Option[DirectivesPositions] + directivesPositions: Option[Position.File] ) extends PreprocessedSource { def reportingPath: Either[String, os.Path] = originalPath.map(_._2) @@ -54,7 +55,7 @@ object PreprocessedSource { scopedRequirements: Seq[Scoped[BuildRequirements]], mainClassOpt: Option[String], scopePath: ScopePath, - directivesPositions: Option[DirectivesPositions], + directivesPositions: Option[Position.File], wrapScriptFun: CodeWrapper => (String, Int) ) extends PreprocessedSource diff --git a/modules/build/src/main/scala/scala/build/preprocessing/ScalaPreprocessor.scala b/modules/build/src/main/scala/scala/build/preprocessing/ScalaPreprocessor.scala index 4f3754aad6..ac0da80479 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/ScalaPreprocessor.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/ScalaPreprocessor.scala @@ -1,6 +1,5 @@ package scala.build.preprocessing -import com.virtuslab.using_directives.custom.model.UsingDirectiveKind import dependency.AnyDependency import dependency.parser.DependencyParser @@ -33,7 +32,7 @@ case object ScalaPreprocessor extends Preprocessor { opts: BuildOptions, optsWithReqs: List[WithBuildRequirements[BuildOptions]], updatedContent: Option[String], - directivesPositions: Option[DirectivesPositions] + directivesPositions: Option[Position.File] ) object ProcessingOutput { @@ -129,7 +128,7 @@ case object ScalaPreprocessor extends Preprocessor { options: BuildOptions, optionsWithTargetRequirements: List[WithBuildRequirements[BuildOptions]], updatedContentOpt: Option[String], - directivesPositions: Option[DirectivesPositions] + directivesPositions: Option[Position.File] ) = value( process( diff --git a/modules/build/src/main/scala/scala/build/preprocessing/UsingDirectivesOps.scala b/modules/build/src/main/scala/scala/build/preprocessing/UsingDirectivesOps.scala index 98d060828c..c9481eb66b 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/UsingDirectivesOps.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/UsingDirectivesOps.scala @@ -1,10 +1,6 @@ package scala.build.preprocessing -import com.virtuslab.using_directives.custom.model.{ - UsingDirectiveKind, - UsingDirectiveSyntax, - UsingDirectives -} +import com.virtuslab.using_directives.custom.model.UsingDirectives import com.virtuslab.using_directives.custom.utils.ast.UsingDefs import scala.build.Position diff --git a/modules/build/src/main/scala/scala/build/preprocessing/directives/PreprocessedDirectives.scala b/modules/build/src/main/scala/scala/build/preprocessing/directives/PreprocessedDirectives.scala index a83aa1d29e..80bd07aa54 100644 --- a/modules/build/src/main/scala/scala/build/preprocessing/directives/PreprocessedDirectives.scala +++ b/modules/build/src/main/scala/scala/build/preprocessing/directives/PreprocessedDirectives.scala @@ -1,7 +1,8 @@ package scala.build.preprocessing.directives +import scala.build.Position import scala.build.options.{BuildOptions, BuildRequirements, WithBuildRequirements} -import scala.build.preprocessing.{DirectivesPositions, Scoped} +import scala.build.preprocessing.Scoped case class PreprocessedDirectives( globalReqs: BuildRequirements, @@ -9,7 +10,7 @@ case class PreprocessedDirectives( usingsWithReqs: List[WithBuildRequirements[BuildOptions]], scopedReqs: Seq[Scoped[BuildRequirements]], strippedContent: Option[String], - directivesPositions: Option[DirectivesPositions] + directivesPositions: Option[Position.File] ) { def isEmpty: Boolean = globalReqs == BuildRequirements.monoid.zero && globalUsings == BuildOptions.monoid.zero && diff --git a/modules/build/src/test/scala/scala/build/tests/ActionableDiagnosticTests.scala b/modules/build/src/test/scala/scala/build/tests/ActionableDiagnosticTests.scala index fd730ba524..1e07cd6764 100644 --- a/modules/build/src/test/scala/scala/build/tests/ActionableDiagnosticTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/ActionableDiagnosticTests.scala @@ -27,7 +27,7 @@ class ActionableDiagnosticTests extends munit.FunSuite { val dependencyOsLib = "com.lihaoyi::os-lib:0.7.8" val testInputs = TestInputs( os.rel / "Foo.scala" -> - s"""//> using dep "$dependencyOsLib" + s"""//> using dep $dependencyOsLib | |object Hello extends App { | println("Hello") @@ -56,8 +56,8 @@ class ActionableDiagnosticTests extends munit.FunSuite { val dependencyPprintLib = "com.lihaoyi::pprint:0.6.6" val testInputs = TestInputs( os.rel / "Foo.scala" -> - s"""//> using dep "$dependencyOsLib" - |//> using dep "$dependencyPprintLib" + s"""//> using dep $dependencyOsLib + |//> using dep $dependencyPprintLib | |object Hello extends App { | println("Hello") @@ -87,7 +87,7 @@ class ActionableDiagnosticTests extends munit.FunSuite { test("actionable actions suggest update only to stable version") { val testInputs = TestInputs( os.rel / "Foo.scala" -> - s"""//> using dep "test-org::test-name-1:1.0.6" + s"""//> using dep test-org::test-name-1:1.0.6 | |object Hello extends App { | println("Hello") @@ -150,7 +150,7 @@ class ActionableDiagnosticTests extends munit.FunSuite { test("actionable actions should not suggest update to previous version") { val testInputs = TestInputs( os.rel / "Foo.scala" -> - s"""//> using dep "test-org::test-name-1:2.0.0-M1" + s"""//> using dep test-org::test-name-1:2.0.0-M1 | |object Hello extends App { | println("Hello") @@ -208,7 +208,7 @@ class ActionableDiagnosticTests extends munit.FunSuite { test("actionable actions should not suggest update if uses version: latest") { val testInputs = TestInputs( os.rel / "Foo.scala" -> - s"""//> using toolkit "latest" + s"""//> using toolkit latest | |object Hello extends App { | os.list(os.pwd).foreach(println) diff --git a/modules/build/src/test/scala/scala/build/tests/BuildTests.scala b/modules/build/src/test/scala/scala/build/tests/BuildTests.scala index 89b724bd8f..bac340312f 100644 --- a/modules/build/src/test/scala/scala/build/tests/BuildTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/BuildTests.scala @@ -263,7 +263,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("dependencies - using") { val testInputs = TestInputs( os.rel / "simple.sc" -> - """//> using dep "com.lihaoyi::geny:0.6.5" + """//> using dep com.lihaoyi::geny:0.6.5 |import geny.Generator |val g = Generator("Hel", "lo") |println(g.mkString) @@ -283,14 +283,14 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("several dependencies - using") { val testInputs = TestInputs( os.rel / "simple.sc" -> - """//> using dep "com.lihaoyi::geny:0.6.5" - |//> using dep "com.lihaoyi::pprint:0.6.6" + """//> using dep com.lihaoyi::geny:0.6.5 + |//> using dep com.lihaoyi::pprint:0.6.6 |import geny.Generator |val g = Generator("Hel", "lo") |pprint.log(g) |""".stripMargin, os.rel / "simple2.sc" -> - """//> using dep "com.lihaoyi::geny:0.6.5", "com.lihaoyi::pprint:0.6.6" + """//> using dep com.lihaoyi::geny:0.6.5, "com.lihaoyi::pprint:0.6.6" |import geny.Generator |val g = Generator("Hel", "lo") |pprint.log(g) @@ -399,7 +399,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { |} |""".stripMargin, os.rel / "Ignored.scala" -> - """//> using target.platform "scala.js" + """//> using target.platform scala.js |object Ignored { | def foo = 2 |} @@ -422,13 +422,13 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { |} |""".stripMargin, os.rel / "Ignored.scala" -> - """//> using target.platform "jvm" + """//> using target.platform jvm |object Ignored { | def foo = 2 |} |""".stripMargin, os.rel / "IgnoredToo.scala" -> - """//> using target.platform "native" + """//> using target.platform native |object IgnoredToo { | def foo = 2 |} @@ -445,55 +445,10 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { } } - test("ignore files if wrong Scala version requirement via in clause") { - val testInputs = TestInputs( - os.rel / "Simple.scala" -> - """//> using target.scala.== "2.12" in "my-scala-2.12/" - |object Simple { - | def main(args: Array[String]): Unit = - | println("Hello") - |} - |""".stripMargin, - os.rel / "my-scala-2.12" / "Ignored.scala" -> - """object Ignored { - | def foo = 2 - |} - |""".stripMargin - ) - testInputs.withBuild(defaultOptions, buildThreads, bloopConfigOpt) { (_, _, maybeBuild) => - maybeBuild.orThrow.assertGeneratedEquals( - "Simple.class", - "Simple$.class" - ) - } - } - test("ignore files if wrong Scala target requirement via in clause") { - val testInputs = TestInputs( - os.rel / "Simple.scala" -> - """//> using target.platform "scala.js" in "js-sources/" - |object Simple { - | def main(args: Array[String]): Unit = - | println("Hello") - |} - |""".stripMargin, - os.rel / "js-sources" / "Ignored.scala" -> - """object Ignored { - | def foo = 2 - |} - |""".stripMargin - ) - testInputs.withBuild(defaultOptions, buildThreads, bloopConfigOpt) { (_, _, maybeBuild) => - maybeBuild.orThrow.assertGeneratedEquals( - "Simple.class", - "Simple$.class" - ) - } - } - test("Pass files with only commented directives as is to scalac") { val testInputs = TestInputs( os.rel / "Simple.scala" -> - """//> using dep "com.lihaoyi::pprint:0.6.6" + """//> using dep com.lihaoyi::pprint:0.6.6 |object Simple { | def main(args: Array[String]): Unit = | pprint.log("Hello " + "from tests") @@ -510,8 +465,8 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("Compiler plugins from using directives") { val inputs = TestInputs( os.rel / "p.sc" -> - """//> using scala "2.13" - |//> using plugins "com.olegpy::better-monadic-for:0.3.1" + """//> using scala 2.13 + |//> using plugins com.olegpy::better-monadic-for:0.3.1 | |def getCounts: Either[String, (Int, Int)] = ??? | @@ -528,9 +483,9 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("Scala Native working with Scala 3.1") { val testInputs = TestInputs( os.rel / "Simple.scala" -> - """//> using platform "scala-native" - |//> using nativeVersion "0.4.3-RC2" - |//> using scala "3.1.0" + """//> using platform scala-native + |//> using nativeVersion 0.4.3-RC2 + |//> using scala 3.1.0 |def foo(): String = "foo" |""".stripMargin ) @@ -547,9 +502,9 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("Scala Native not working with Scala 3.0") { val testInputs = TestInputs( os.rel / "Simple.scala" -> - """//> using platform "scala-native" - |//> using nativeVersion "0.4.3-RC2" - |//> using scala "3.0.2" + """//> using platform scala-native + |//> using nativeVersion 0.4.3-RC2 + |//> using scala 3.0.2 |def foo(): String = "foo" |""".stripMargin ) @@ -600,7 +555,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { val inputs = TestInputs( os.rel / "foo.scala" -> - s"""//> using dep "$usingDependency" + s"""//> using dep $usingDependency |def foo = "bar" |""".stripMargin ) @@ -632,7 +587,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { val inputs = TestInputs( os.rel / "foo.scala" -> - s"""//> using options "${usingDirectiveScalacOptions.mkString("\", \"")}" + s"""//> using options ${usingDirectiveScalacOptions.mkString(" ")} |def foo = "bar" |""".stripMargin ) @@ -663,7 +618,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { val inputs = TestInputs( os.rel / "foo.scala" -> - s"""//> using javaOpt "${usingDirectiveJavaOptions.mkString("\", \"")}" + s"""//> using javaOpt ${usingDirectiveJavaOptions.mkString(" ")} |def foo = "bar" |""".stripMargin ) @@ -687,14 +642,14 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("repeated Java options") { val inputs = TestInputs( os.rel / "foo.sc" -> - """//> using javaOpt "--add-opens", "foo/bar" - |//> using javaOpt "--add-opens", "other/thing" - |//> using javaOpt "--add-exports", "foo/bar" - |//> using javaOpt "--add-exports", "other/thing" - |//> using javaOpt "--add-modules", "foo/bar" - |//> using javaOpt "--add-modules", "other/thing" - |//> using javaOpt "--add-reads", "foo/bar" - |//> using javaOpt "--add-reads", "other/thing" + """//> using javaOpt --add-opens, "foo/bar" + |//> using javaOpt --add-opens, "other/thing" + |//> using javaOpt --add-exports, "foo/bar" + |//> using javaOpt --add-exports, "other/thing" + |//> using javaOpt --add-modules, "foo/bar" + |//> using javaOpt --add-modules, other/thing + |//> using javaOpt --add-reads, "foo/bar" + |//> using javaOpt --add-reads, "other/thing" |//> using javaOpt "--patch-module", "foo/bar" |//> using javaOpt "--patch-module", "other/thing" | @@ -746,9 +701,9 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("scalac options not spuriously duplicating") { val inputs = TestInputs( os.rel / "foo.scala" -> - """//> using scala "2.13" - |//> using options "-deprecation", "-feature", "-Xmaxwarns", "1" - |//> using option "-Xdisable-assertions" + """//> using scala 2.13 + |//> using options -deprecation, "-feature", "-Xmaxwarns", "1" + |//> using option -Xdisable-assertions | |def foo = "bar" |""".stripMargin @@ -766,8 +721,8 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("multiple times scalac options with -Xplugin prefix") { val inputs = TestInputs( os.rel / "foo.scala" -> - """//> using option "-Xplugin:/paradise_2.12.15-2.1.1.jar" - |//> using option "-Xplugin:/semanticdb-scalac_2.12.15-4.4.31.jar" + """//> using option -Xplugin:/paradise_2.12.15-2.1.1.jar + |//> using option -Xplugin:/semanticdb-scalac_2.12.15-4.4.31.jar | |def foo = "bar" |""".stripMargin @@ -788,8 +743,8 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("Pin Scala 2 artifacts version") { val inputs = TestInputs( os.rel / "Foo.scala" -> - """//> using dep "com.lihaoyi:ammonite_2.13.8:2.5.1-6-5fce97fb" - |//> using scala "2.13.5" + """//> using dep com.lihaoyi:ammonite_2.13.8:2.5.1-6-5fce97fb + |//> using scala 2.13.5 | |object Foo { | def main(args: Array[String]): Unit = { @@ -818,8 +773,8 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { test("Pin Scala 3 artifacts version") { val inputs = TestInputs( os.rel / "Foo.scala" -> - """//> using dep "com.lihaoyi:ammonite_3.1.1:2.5.1-6-5fce97fb" - |//> using scala "3.1.0" + """//> using dep com.lihaoyi:ammonite_3.1.1:2.5.1-6-5fce97fb + |//> using scala 3.1.0 | |object Foo { | def main(args: Array[String]): Unit = { @@ -901,7 +856,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { val inputs = TestInputs( os.rel / helloFile -> - """|//> using file "Utils.scala" + """|//> using file Utils.scala | |object Hello extends App { | println(Utils.hello) @@ -921,7 +876,7 @@ abstract class BuildTests(server: Boolean) extends munit.FunSuite { // updating sources in using directive should change project name val updatedHelloScala = - """|//> using file "Helper.scala" + """|//> using file Helper.scala | |object Hello extends App { | println(Helper.hello) diff --git a/modules/build/src/test/scala/scala/build/tests/DirectiveParsingTest.scala b/modules/build/src/test/scala/scala/build/tests/DirectiveParsingTest.scala deleted file mode 100644 index f66b711d60..0000000000 --- a/modules/build/src/test/scala/scala/build/tests/DirectiveParsingTest.scala +++ /dev/null @@ -1,137 +0,0 @@ -package scala.build -package tests - -import com.eed3si9n.expecty.Expecty.{assert => expect} -import com.virtuslab.using_directives.custom.model.UsingDirectiveKind - -import scala.build.errors.Diagnostic -import scala.build.preprocessing.{ExtractedDirectives, ScopePath} -import scala.build.errors.Severity -import scala.build.errors.CompositeBuildException -import scala.build.errors.BuildException - -class DirectiveParsingTest extends munit.FunSuite { - - val path = os.pwd - - trait Check { - def test(diags: Seq[Diagnostic]): Boolean - } - - case class Warn(messagePattern: String, line: Int, index: Int) extends Check { - def test(diags: Seq[Diagnostic]): Boolean = { - val matching = diags.filter(_.positions.exists { - case Position.File(_, (`line`, `index`), _) => true - case _ => false - }).filter(_.severity == Severity.Warning) - val Regex = s".*$messagePattern.*".r - matching.map(_.message).exists { - case Regex() => true - case _ => false - } - } - } - - case class NoWarn(messagePattern: String) extends Check { - def test(diags: Seq[Diagnostic]): Boolean = { - val Regex = s".*$messagePattern.*".r - val matching = diags.filter(d => Regex.unapplySeq(d.message).nonEmpty) - expect(matching.isEmpty) - matching.isEmpty - } - } - - case class Error(messagePattern: String) extends Check { - def test(diags: Seq[Diagnostic]): Boolean = - testMsgs(diags.filter(_.severity == Severity.Error).map(_.message)) - - def testMsgs(diags: Seq[String]): Boolean = { - val Regex = s".*$messagePattern.*".r - println("Errors: " + diags) - val matching = diags.filter(d => Regex.unapplySeq(d).nonEmpty) - expect(matching.nonEmpty) - matching.nonEmpty - } - } - - private def testDiagnostics(lines: String*)(checks: Check*): List[Diagnostic] = { - val persistentLogger = new PersistentDiagnosticLogger(Logger.nop) - val code = lines.mkString("\n").toCharArray() - val res = ExtractedDirectives.from( - code, - Right(path), - persistentLogger, - maybeRecoverOnError = e => Some(e) - ) - - def checkDiag(checks: Seq[Check]) = { - val diags = persistentLogger.diagnostics - if (checks.isEmpty) expect(diags.isEmpty) - else checks.foreach(warn => expect(warn.test(diags))) - diags - } - - val (expectedError, expectedWarnings) = - checks.partitionMap { case e: Error => Left(e); case o => Right(o) } - if (expectedError.isEmpty) expect(res.isRight) - else - res match { - case Left(exception) => - def flatten(e: BuildException): Seq[String] = e match { - case c: CompositeBuildException => - c.exceptions.flatMap(flatten) - case e => - Seq(e.getMessage()) - } - val msgs = flatten(exception) - expectedError.foreach(e => expect(e.testMsgs(msgs))) - case _ => - checkDiag(expectedError) - } - checkDiag(expectedWarnings) - - } - - val commentDirective = """// using commentDirective "b" """ - val specialCommentDirective = """//> using specialCommentDirective "b" """ - val directive = """using directive "b" """ - - test("Test deprecation warnings about comments") { - testDiagnostics(commentDirective)(Warn("deprecated", 0, 0)) - testDiagnostics( - commentDirective, - specialCommentDirective, - commentDirective - )( - Warn("deprecated", 0, 0), - Warn("deprecated", 2, 0) - ) - } - - test("Test warnings about mixing syntax") { - testDiagnostics(directive, specialCommentDirective)(Warn("ignored", 0, 0)) - testDiagnostics(directive, commentDirective)(Warn("ignored", 0, 0)) - testDiagnostics(specialCommentDirective, commentDirective)(Warn("ignored", 1, 0)) - testDiagnostics(commentDirective, specialCommentDirective)(Warn("deprecated", 0, 0)) - } - - test("Plain comment result in ignored warning") { - testDiagnostics(commentDirective)(Warn("ignored", 0, 0)) - } - - test("@using is deprecated") { - def addAt(s: String) = s.replace("using ", "@using ") - testDiagnostics(addAt(specialCommentDirective))(Warn("syntax", 0, 4), Warn("keyword", 0, 4)) - } - - test("interpolator in dependency") { - val diags = - testDiagnostics("""//> using dep ivy"org.scala-sbt::io:1.6.0"""")(Error("interpolator")) - println(diags) - } - - test("unicode in using directives") { - val diags = testDiagnostics("""using nativeMode “release-full”"""")(Error("illegal")) - println(diags) - } -} diff --git a/modules/build/src/test/scala/scala/build/tests/ScalaPreprocessorTests.scala b/modules/build/src/test/scala/scala/build/tests/ScalaPreprocessorTests.scala index 58e7ca2dd0..8996117fae 100644 --- a/modules/build/src/test/scala/scala/build/tests/ScalaPreprocessorTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/ScalaPreprocessorTests.scala @@ -27,8 +27,8 @@ class ScalaPreprocessorTests extends munit.FunSuite { )(using ScalaCliInvokeData.dummy) expect(result.nonEmpty) val Some(directivesPositions) = result.head.directivesPositions - expect(directivesPositions.specialCommentDirectives.startPos == 0 -> 0) - expect(directivesPositions.specialCommentDirectives.endPos == 3 -> 0) + expect(directivesPositions.startPos == 0 -> 0) + expect(directivesPositions.endPos == 3 -> 0) } } @@ -47,8 +47,8 @@ class ScalaPreprocessorTests extends munit.FunSuite { )(using ScalaCliInvokeData.dummy) expect(result.nonEmpty) val Some(directivesPositions) = result.head.directivesPositions - expect(directivesPositions.specialCommentDirectives.startPos == 0 -> 0) - expect(directivesPositions.specialCommentDirectives.endPos == 2 -> 0) + expect(directivesPositions.startPos == 0 -> 0) + expect(directivesPositions.endPos == 2 -> 0) } } } diff --git a/modules/directives/src/main/scala/scala/build/directives/DirectiveValueParser.scala b/modules/directives/src/main/scala/scala/build/directives/DirectiveValueParser.scala index 1d09c767dc..b3ad5d97c4 100644 --- a/modules/directives/src/main/scala/scala/build/directives/DirectiveValueParser.scala +++ b/modules/directives/src/main/scala/scala/build/directives/DirectiveValueParser.scala @@ -1,12 +1,6 @@ package scala.build.directives -import com.virtuslab.using_directives.custom.model.{ - BooleanValue, - EmptyValue, - NumericValue, - StringValue, - Value -} +import com.virtuslab.using_directives.custom.model.{BooleanValue, EmptyValue, StringValue, Value} import scala.build.Positioned.apply import scala.build.errors.{ @@ -106,11 +100,6 @@ object DirectiveValueParser { case s: BooleanValue => Some(s.get()) case _ => None } - def asNum: Option[String] = - value match { - case n: NumericValue => Some(n.get()) - case _ => None - } def position(path: Either[String, os.Path]): Position = DirectiveUtil.position(value, path, skipQuotes = isString) @@ -152,10 +141,10 @@ object DirectiveValueParser { given DirectiveSingleValueParser[MaybeNumericalString] = (value, scopePath, path) => - value.asString.orElse(value.asNum).map(MaybeNumericalString(_)).toRight { + value.asString.map(MaybeNumericalString(_)).toRight { val pos = value.position(path) new MalformedDirectiveError( - s"Expected a string or a numerical value, got '${value.getRelatedASTNode.toString}'", + s"Expected a string value, got '${value.getRelatedASTNode.toString}'", Seq(pos) ) } diff --git a/modules/directives/src/main/scala/scala/build/errors/SingleValueExpectedError.scala b/modules/directives/src/main/scala/scala/build/errors/SingleValueExpectedError.scala index 9d38824533..8f9ffb046c 100644 --- a/modules/directives/src/main/scala/scala/build/errors/SingleValueExpectedError.scala +++ b/modules/directives/src/main/scala/scala/build/errors/SingleValueExpectedError.scala @@ -10,5 +10,5 @@ final class SingleValueExpectedError( s"(got ${directive.values.length} values: ${directive.values.map(_.get().toString).mkString(", ")})", positions = DirectiveUtil.positions(directive.values, path) ) { - assert(directive.numericalOrStringValuesCount > 1) + assert(directive.stringValuesCount > 1) } diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/CustomJar.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/CustomJar.scala index a608184afc..fb15c97536 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/CustomJar.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/CustomJar.scala @@ -11,15 +11,15 @@ import scala.util.{Failure, Success, Try} @DirectiveGroupName("Custom JAR") @DirectiveExamples( - "//> using jar \"/Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar\"" + "//> using jar /Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar" ) @DirectiveExamples( - "//> using test.jar \"/Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar\"" + "//> using test.jar /Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar" ) @DirectiveUsage( - "`//> using jar `_path_ | `//> using jars `_path1_, _path2_ …", + "`//> using jar `_path_ | `//> using jars `_path1_ _path2_ …", """//> using jar _path_ | - |//> using jars _path1_, _path2_ …""".stripMargin + |//> using jars _path1_ _path2_ …""".stripMargin ) @DirectiveDescription("Manually add JAR(s) to the class path") @DirectiveLevel(SpecificationLevel.SHOULD) diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Dependency.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Dependency.scala index ec147cdec7..9d929bf536 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Dependency.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Dependency.scala @@ -18,15 +18,15 @@ import scala.build.preprocessing.ScopePath import scala.build.{Logger, Positioned} import scala.cli.commands.SpecificationLevel -@DirectiveExamples("//> using dep \"com.lihaoyi::os-lib:0.9.1\"") -@DirectiveExamples("//> using test.dep \"org.scalatest::scalatest:3.2.10\"") -@DirectiveExamples("//> using test.dep \"org.scalameta::munit:0.7.29\"") +@DirectiveExamples("//> using dep com.lihaoyi::os-lib:0.9.1") +@DirectiveExamples("//> using test.dep org.scalatest::scalatest:3.2.10") +@DirectiveExamples("//> using test.dep org.scalameta::munit:0.7.29") @DirectiveExamples( - "//> using dep \"tabby:tabby:0.2.3,url=https://github.com/bjornregnell/tabby/releases/download/v0.2.3/tabby_3-0.2.3.jar\"" + "//> using dep tabby:tabby:0.2.3,url=https://github.com/bjornregnell/tabby/releases/download/v0.2.3/tabby_3-0.2.3.jar" ) @DirectiveUsage( - "//> using dep \"org:name:ver\" | //> using deps \"org:name:ver\", \"org2:name2:ver2\"", - "`//> using dep \"`_org_`:`name`:`ver\"" + "//> using dep org:name:ver | //> using deps org:name:ver org2:name2:ver2", + "`//> using dep `_org_`:`name`:`ver" ) @DirectiveDescription("Add dependencies") @DirectiveLevel(SpecificationLevel.MUST) diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/DirectiveUtil.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/DirectiveUtil.scala index ae4de3883f..b7f11242d2 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/DirectiveUtil.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/DirectiveUtil.scala @@ -1,12 +1,6 @@ package scala.build.preprocessing.directives -import com.virtuslab.using_directives.custom.model.{ - BooleanValue, - EmptyValue, - NumericValue, - StringValue, - Value -} +import com.virtuslab.using_directives.custom.model.{BooleanValue, EmptyValue, StringValue, Value} import scala.build.preprocessing.ScopePath import scala.build.{Position, Positioned} @@ -34,9 +28,6 @@ object DirectiveUtil { case v: StringValue => val pos = position(v, scopedDirective.maybePath, skipQuotes = true) Positioned(pos, v.get) - case v: NumericValue => - val pos = position(v, scopedDirective.maybePath, skipQuotes = false) - Positioned(pos, v.get) case v: BooleanValue => val pos = position(v, scopedDirective.maybePath, skipQuotes = false) Positioned(pos, v.get.toString) diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Exclude.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Exclude.scala index 8293f331ce..d2934df9ed 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Exclude.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Exclude.scala @@ -10,12 +10,12 @@ import scala.cli.commands.SpecificationLevel import scala.util.Try @DirectiveGroupName("Exclude sources") -@DirectiveExamples("//> using exclude \"utils.scala\"") +@DirectiveExamples("//> using exclude utils.scala") @DirectiveUsage( - "`//> using exclude `_pattern_ | `//> using exclude `_pattern_, _pattern_ …", + "`//> using exclude `_pattern_ | `//> using exclude `_pattern_ _pattern_ …", """`//> using exclude "*.sc"` | - |`//> using exclude "examples/*", "*/resources/*" …`""".stripMargin + |`//> using exclude "examples/*" "*/resources/*" …`""".stripMargin ) @DirectiveDescription("Exclude sources from the project") @DirectiveLevel(SpecificationLevel.SHOULD) diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaHome.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaHome.scala index c846d302ba..38100190ab 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaHome.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaHome.scala @@ -9,7 +9,7 @@ import scala.cli.commands.SpecificationLevel import scala.util.{Failure, Success, Try} @DirectiveGroupName("Java home") -@DirectiveExamples("//> using javaHome \"/Users/Me/jdks/11\"") +@DirectiveExamples("//> using javaHome /Users/Me/jdks/11") @DirectiveUsage( "//> using javaHome _path_", "`//> using javaHome `_path_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaOptions.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaOptions.scala index b7d8f2d15e..8b3c967d91 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaOptions.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaOptions.scala @@ -8,8 +8,8 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Java options") -@DirectiveExamples("//> using javaOpt \"-Xmx2g\", \"-Dsomething=a\"") -@DirectiveExamples("//> using test.javaOpt \"-Dsomething=a\"") +@DirectiveExamples("//> using javaOpt -Xmx2g, -Dsomething=a") +@DirectiveExamples("//> using test.javaOpt -Dsomething=a") @DirectiveUsage( "//> using javaOpt _options_", "`//> using javaOpt `_options_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaProps.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaProps.scala index befca8ab99..0bcddc6d52 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaProps.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavaProps.scala @@ -8,8 +8,8 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Java properties") -@DirectiveExamples("//> using javaProp \"foo1=bar\", \"foo2\"") -@DirectiveExamples("//> using test.javaProp \"foo3=bar\", \"foo4\"") +@DirectiveExamples("//> using javaProp foo1=bar, foo2") +@DirectiveExamples("//> using test.javaProp foo3=bar foo4") @DirectiveUsage( "//> using javaProp _key=val_", """`//> using javaProp `_key=value_ diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavacOptions.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavacOptions.scala index d0c62a109a..897eb26c71 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavacOptions.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/JavacOptions.scala @@ -8,8 +8,8 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Javac options") -@DirectiveExamples("//> using javacOpt \"source\", \"1.8\", \"target\", \"1.8\"") -@DirectiveExamples("//> using test.javacOpt \"source\", \"1.8\", \"target\", \"1.8\"") +@DirectiveExamples("//> using javacOpt -source 1.8 -target 1.8") +@DirectiveExamples("//> using test.javacOpt -source 1.8 -target 1.8") @DirectiveUsage( "//> using javacOpt _options_", "`//> using javacOpt `_options_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Jvm.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Jvm.scala index ee038ee1c9..6a32aa5e7c 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Jvm.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Jvm.scala @@ -7,9 +7,9 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("JVM version") -@DirectiveExamples("//> using jvm \"11\"") -@DirectiveExamples("//> using jvm \"adopt:11\"") -@DirectiveExamples("//> using jvm \"graalvm:21\"") +@DirectiveExamples("//> using jvm 11") +@DirectiveExamples("//> using jvm adopt:11") +@DirectiveExamples("//> using jvm graalvm:21") @DirectiveUsage( "//> using jvm _value_", "`//> using jvm` _value_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/MainClass.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/MainClass.scala index 270c20b211..abb42ea6df 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/MainClass.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/MainClass.scala @@ -7,7 +7,7 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Main class") -@DirectiveExamples("//> using mainClass \"helloWorld\"") +@DirectiveExamples("//> using mainClass helloWorld") @DirectiveUsage( "//> using mainClass _main class_", "`//> using mainClass `_main class_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Packaging.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Packaging.scala index 5fc9113514..6ffb614f43 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Packaging.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Packaging.scala @@ -25,11 +25,11 @@ import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Packaging") @DirectivePrefix("packaging.") -@DirectiveExamples("//> using packaging.packageType \"assembly\"") -@DirectiveExamples("//> using packaging.output \"foo\"") -@DirectiveExamples("//> using packaging.provided \"org.apache.spark::spark-sql\"") -@DirectiveExamples("//> using packaging.dockerFrom \"openjdk:11\"") -@DirectiveExamples("//> using packaging.graalvmArgs \"--no-fallback\"") +@DirectiveExamples("//> using packaging.packageType assembly") +@DirectiveExamples("//> using packaging.output foo") +@DirectiveExamples("//> using packaging.provided org.apache.spark::spark-sql") +@DirectiveExamples("//> using packaging.dockerFrom openjdk:11") +@DirectiveExamples("//> using packaging.graalvmArgs --no-fallback") @DirectiveUsage( """using packaging.packageType [package type] |using packaging.output [destination path] @@ -40,9 +40,9 @@ import scala.cli.commands.SpecificationLevel |using packaging.dockerImageRegistry [image registry] |using packaging.dockerImageRepository [image repository] |""".stripMargin, - """`//> using packaging.packageType `"package type" + """`//> using packaging.packageType package_type` | - |`//> using packaging.output `"destination path" + |`//> using packaging.output destination_path` | |""".stripMargin ) diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Platform.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Platform.scala index f8b88f5f10..dae92bc070 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Platform.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Platform.scala @@ -20,8 +20,8 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Platform") -@DirectiveExamples("//> using platform \"scala-js\"") -@DirectiveExamples("//> using platform \"jvm\", \"scala-native\"") +@DirectiveExamples("//> using platform scala-js") +@DirectiveExamples("//> using platform jvm scala-native") @DirectiveUsage( "//> using platform (jvm|scala-js|scala-native)+", "`//> using platform `(`jvm`|`scala-js`|`scala-native`)+" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Plugin.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Plugin.scala index d709d134bf..79cdd6a7cd 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Plugin.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Plugin.scala @@ -13,9 +13,9 @@ import scala.build.{Logger, Positioned} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Compiler plugins") -@DirectiveExamples("//> using plugin \"org.typelevel:::kind-projector:0.13.2\"") +@DirectiveExamples("//> using plugin org.typelevel:::kind-projector:0.13.2") @DirectiveUsage( - "//> using plugin \"org:name:ver\" | //> using plugins \"org:name:ver\", \"org2:name2:ver2\"", + "//> using plugin org:name:ver | //> using plugins org:name:ver org2:name2:ver2", "`using plugin `_org_`:`name`:`ver" ) @DirectiveDescription("Adds compiler plugins") diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Publish.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Publish.scala index 01019fc386..e9ab0797ec 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Publish.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Publish.scala @@ -11,14 +11,14 @@ import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Publish") @DirectivePrefix("publish.") -@DirectiveExamples("//> using publish.organization \"io.github.myself\"") -@DirectiveExamples("//> using publish.name \"my-library\"") -@DirectiveExamples("//> using publish.version \"0.1.1\"") +@DirectiveExamples("//> using publish.organization io.github.myself") +@DirectiveExamples("//> using publish.name my-library") +@DirectiveExamples("//> using publish.version 0.1.1") @DirectiveUsage( "//> using publish.(organization|name|version) [value]", - """`//> using publish.organization `"value" - |`//> using publish.name `"value" - |`//> using publish.version `"value" + """`//> using publish.organization `value + |`//> using publish.name `value + |`//> using publish.version `value |""".stripMargin ) @DirectiveDescription("Set parameters for publishing") diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/PublishContextual.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/PublishContextual.scala index e5efa07c04..d1e2a04357 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/PublishContextual.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/PublishContextual.scala @@ -110,14 +110,14 @@ object PublishContextual { @DirectiveGroupName("Publish (contextual)") @DirectivePrefix("publish.") - @DirectiveExamples("//> using publish.computeVersion \"git:tag\"") - @DirectiveExamples("//> using publish.repository \"central-s01\"") - @DirectiveExamples("//> using publish.secretKey \"env:PUBLISH_SECRET_KEY\"") + @DirectiveExamples("//> using publish.computeVersion git:tag") + @DirectiveExamples("//> using publish.repository central-s01") + @DirectiveExamples("//> using publish.secretKey env:PUBLISH_SECRET_KEY") @DirectiveUsage( "//> using publish.(computeVersion|repository|secretKey|…) [value]", - """`//> using publish.computeVersion `"value" - |`//> using publish.repository `"value" - |`//> using publish.secretKey `"value" + """`//> using publish.computeVersion `value + |`//> using publish.repository `value + |`//> using publish.secretKey `value |""".stripMargin ) @DirectiveDescription("Set contextual parameters for publishing") @@ -146,14 +146,14 @@ object PublishContextual { @DirectiveGroupName("Publish (CI)") @DirectivePrefix("publish.ci.") - @DirectiveExamples("//> using publish.ci.computeVersion \"git:tag\"") - @DirectiveExamples("//> using publish.ci.repository \"central-s01\"") - @DirectiveExamples("//> using publish.ci.secretKey \"env:PUBLISH_SECRET_KEY\"") + @DirectiveExamples("//> using publish.ci.computeVersion git:tag") + @DirectiveExamples("//> using publish.ci.repository central-s01") + @DirectiveExamples("//> using publish.ci.secretKey env:PUBLISH_SECRET_KEY") @DirectiveUsage( "//> using publish.[.ci](computeVersion|repository|secretKey|…) [value]", - """`//> using publish.ci.computeVersion `"value" - |`//> using publish.ci.repository `"value" - |`//> using publish.ci.secretKey `"value" + """`//> using publish.ci.computeVersion `value + |`//> using publish.ci.repository `value + |`//> using publish.ci.secretKey `value |""".stripMargin ) @DirectiveDescription("Set CI parameters for publishing") diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Repository.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Repository.scala index e499d00644..dda5dd5659 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Repository.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Repository.scala @@ -7,10 +7,10 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Repository") -@DirectiveExamples("//> using repository \"jitpack\"") -@DirectiveExamples("//> using repository \"sonatype:snapshots\"") +@DirectiveExamples("//> using repository jitpack") +@DirectiveExamples("//> using repository sonatype:snapshots") @DirectiveExamples( - "//> using repository \"https://maven-central.storage-download.googleapis.com/maven2\"" + "//> using repository https://maven-central.storage-download.googleapis.com/maven2" ) @DirectiveUsage( "//> using repository _repository_", diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequirePlatform.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequirePlatform.scala index e8f134e593..d15551991d 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequirePlatform.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequirePlatform.scala @@ -10,9 +10,9 @@ import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Platform") @DirectivePrefix("target.") @DirectiveDescription("Require a Scala platform for the current file") -@DirectiveExamples("//> using target.platform \"scala-js\"") -@DirectiveExamples("//> using target.platform \"scala-js\", \"scala-native\"") -@DirectiveExamples("//> using target.platform \"jvm\"") +@DirectiveExamples("//> using target.platform scala-js") +@DirectiveExamples("//> using target.platform scala-js, scala-native") +@DirectiveExamples("//> using target.platform jvm") @DirectiveUsage( "//> using target.platform _platform_", "`//> using target.platform `_platform_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersion.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersion.scala index c896c1c4a2..b5e54b81bb 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersion.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersion.scala @@ -8,7 +8,7 @@ import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Scala version") @DirectivePrefix("target.") @DirectiveDescription("Require a Scala version for the current file") -@DirectiveExamples("//> using target.scala \"3\"") +@DirectiveExamples("//> using target.scala 3") @DirectiveUsage( "//> using target.scala _version_", "`//> using target.scala `_version_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersionBounds.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersionBounds.scala index 71f9be01d5..dd76e00840 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersionBounds.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScalaVersionBounds.scala @@ -8,8 +8,8 @@ import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Scala version bounds") @DirectivePrefix("target.scala.") @DirectiveDescription("Require a Scala version for the current file") -@DirectiveExamples("//> using target.scala.>= \"2.13\"") -@DirectiveExamples("//> using target.scala.< \"3.0.2\"") +@DirectiveExamples("//> using target.scala.>= 2.13") +@DirectiveExamples("//> using target.scala.< 3.0.2") @DirectiveUsage( "//> using target.scala.>= _version_", "`//> using target.scala.>= `_version_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScope.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScope.scala index 27da39c0ab..8490f53dc8 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScope.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/RequireScope.scala @@ -11,7 +11,7 @@ import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Scope") @DirectivePrefix("target.") @DirectiveDescription("Require a scope for the current file") -@DirectiveExamples("//> using target.scope \"test\"") +@DirectiveExamples("//> using target.scope test") @DirectiveUsage( "//> using target.scope _scope_", "`//> using target.scope `_scope_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Resources.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Resources.scala index 2db75aa805..cb5f372fab 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Resources.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Resources.scala @@ -15,15 +15,15 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Resource directories") -@DirectiveExamples("//> using resourceDir \"./resources\"") -@DirectiveExamples("//> using test.resourceDir \"./resources\"") +@DirectiveExamples("//> using resourceDir ./resources") +@DirectiveExamples("//> using test.resourceDir ./resources") @DirectiveUsage( """//> using resourceDir _path_ | - |//> using resourceDirs _path1_, _path2_ …""".stripMargin, + |//> using resourceDirs _path1_ _path2_ …""".stripMargin, """`//> using resourceDir `_path_ | - |`//> using resourceDirs `_path1_, _path2_ …""".stripMargin + |`//> using resourceDirs `_path1_ _path2_ …""".stripMargin ) @DirectiveDescription("Manually add a resource directory to the class path") @DirectiveLevel(SpecificationLevel.SHOULD) diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaJs.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaJs.scala index 2258e5e2ad..350291e39a 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaJs.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaJs.scala @@ -8,7 +8,7 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Scala.js options") -@DirectiveExamples("//> using jsModuleKind \"common\"") +@DirectiveExamples("//> using jsModuleKind common") @DirectiveUsage( "//> using jsVersion|jsMode|jsModuleKind|… _value_", """ @@ -18,7 +18,7 @@ import scala.cli.commands.SpecificationLevel | |`//> using jsModuleKind` _value_ | - |`//> using jsSmallModuleForPackage` _value1_, _value2_ + |`//> using jsSmallModuleForPackage` _value1_ _value2_ | |`//> using jsCheckIr` _true|false_ | diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaNative.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaNative.scala index 6a0e899803..47ada42944 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaNative.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaNative.scala @@ -7,7 +7,7 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Scala Native options") -@DirectiveExamples("//> using nativeVersion \"0.4.0\"") +@DirectiveExamples("//> using nativeVersion 0.4.0") @DirectiveUsage( "//> using nativeGc _value_ | using native-version _value_", """`//> using nativeGc` _value_ @@ -18,9 +18,9 @@ import scala.cli.commands.SpecificationLevel | |`//> using nativeVersion` _value_ | - |`//> using nativeCompile` _value1_, _value2_ + |`//> using nativeCompile` _value1_ _value2_ | - |`//> using nativeLinking` _value1_, _value2_ + |`//> using nativeLinking` _value1_ _value2_ | |`//> using nativeClang` _value_ | diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaVersion.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaVersion.scala index 469ffae450..bd688259c3 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaVersion.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalaVersion.scala @@ -7,10 +7,10 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Scala version") -@DirectiveExamples("//> using scala \"3.0.2\"") -@DirectiveExamples("//> using scala \"2.13\"") -@DirectiveExamples("//> using scala \"2\"") -@DirectiveExamples("//> using scala \"2.13.6\", \"2.12.16\"") +@DirectiveExamples("//> using scala 3.0.2") +@DirectiveExamples("//> using scala 2.13") +@DirectiveExamples("//> using scala 2") +@DirectiveExamples("//> using scala 2.13.6, 2.12.16") @DirectiveUsage( "//> using scala _version_+", "`//> using scala `_version_+" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalacOptions.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalacOptions.scala index 3d9f2fa1f7..e5371a7b63 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalacOptions.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/ScalacOptions.scala @@ -15,9 +15,9 @@ import scala.build.{Logger, Positioned} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Compiler options") -@DirectiveExamples("//> using option \"-Xasync\"") -@DirectiveExamples("//> using test.option \"-Xasync\"") -@DirectiveExamples("//> using options \"-Xasync\", \"-Xfatal-warnings\"") +@DirectiveExamples("//> using option -Xasync") +@DirectiveExamples("//> using test.option -Xasync") +@DirectiveExamples("//> using options -Xasync, -Xfatal-warnings") @DirectiveUsage( "using option _option_ | using options _option1_ _option2_ …", """`//> using option `_option_ diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Sources.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Sources.scala index 8c255c3703..bed61e3d4a 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Sources.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Sources.scala @@ -10,7 +10,7 @@ import scala.cli.commands.SpecificationLevel import scala.util.Try @DirectiveGroupName("Custom sources") -@DirectiveExamples("//> using file \"utils.scala\"") +@DirectiveExamples("//> using file utils.scala") @DirectiveUsage( "`//> using file `_path_ | `//> using files `_path1_, _path2_ …", """//> using file hello.sc diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/StrictDirective.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/StrictDirective.scala index 5ed9de1cae..2ae1588a5d 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/StrictDirective.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/StrictDirective.scala @@ -1,6 +1,6 @@ package scala.build.preprocessing.directives -import com.virtuslab.using_directives.custom.model.{NumericValue, StringValue, Value} +import com.virtuslab.using_directives.custom.model.{StringValue, Value} case class StrictDirective( key: String, @@ -10,10 +10,9 @@ case class StrictDirective( val suffix = if values.isEmpty then "" else s" \"${values.mkString("\", \"")}\"" s"//> using $key$suffix" } - def numericalOrStringValuesCount: Int = + def stringValuesCount: Int = values.count { - case _: NumericValue => true - case _: StringValue => true - case _ => false + case _: StringValue => true + case _ => false } } diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Tests.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Tests.scala index 077700a3b6..23e154f72d 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Tests.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Tests.scala @@ -7,7 +7,7 @@ import scala.build.{Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Test framework") -@DirectiveExamples("//> using testFramework \"utest.runner.Framework\"") +@DirectiveExamples("//> using testFramework utest.runner.Framework") @DirectiveUsage( "using testFramework _class_name_", "`//> using testFramework ` _class_name_" diff --git a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Toolkit.scala b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Toolkit.scala index e551284ead..c13886c293 100644 --- a/modules/directives/src/main/scala/scala/build/preprocessing/directives/Toolkit.scala +++ b/modules/directives/src/main/scala/scala/build/preprocessing/directives/Toolkit.scala @@ -21,9 +21,9 @@ import scala.build.{Artifacts, Logger, Positioned, options} import scala.cli.commands.SpecificationLevel @DirectiveGroupName("Toolkit") -@DirectiveExamples("//> using toolkit \"0.1.0\"") -@DirectiveExamples("//> using toolkit \"latest\"") -@DirectiveExamples("//> using test.toolkit \"latest\"") +@DirectiveExamples("//> using toolkit 0.1.0") +@DirectiveExamples("//> using toolkit latest") +@DirectiveExamples("//> using test.toolkit latest") @DirectiveUsage( "//> using toolkit _version_", "`//> using toolkit` _version_" diff --git a/modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala b/modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala index 75ec9adcf2..14e91692ef 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala @@ -926,35 +926,6 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String]) } } - test("using directive") { - val inputs = TestInputs( - os.rel / "test.sc" -> - s"""// using scala "3.0" - |println(123)""".stripMargin - ) - withBsp(inputs, Seq(".")) { (_, localClient, remoteServer) => - async { - // prepare build - val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala) - // build code - val targets = buildTargetsResp.getTargets.asScala.map(_.getId()).asJava - await(remoteServer.buildTargetCompile(new b.CompileParams(targets)).asScala) - - val visibleDiagnostics = - localClient.diagnostics().takeWhile(!_.getReset).flatMap(_.getDiagnostics.asScala) - - expect(visibleDiagnostics.nonEmpty) - visibleDiagnostics.foreach { d => - expect( - d.getSeverity == b.DiagnosticSeverity.WARNING, - d.getMessage.contains("deprecated"), - d.getMessage.contains("directive") - ) - } - } - } - } - test("workspace/reload --dependency option") { val inputs = TestInputs( os.rel / "ReloadTest.scala" -> @@ -1191,7 +1162,7 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String]) test("bloop projects are initialised properly for an invalid directive value") { val inputs = TestInputs( os.rel / "InvalidUsingDirective.scala" -> - s"""//> using scala 3.1.2 + s"""//> using scala true | |object InvalidUsingDirective extends App { | println("Hello") @@ -1212,12 +1183,12 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String]) checkDiagnostic( diagnostic = diagnostics.head, expectedMessage = - "Expected new line after the using directive, in the line; but found number literal: .2", + "Expected a string value, got 'true'", expectedSeverity = b.DiagnosticSeverity.ERROR, expectedStartLine = 0, - expectedStartCharacter = 19, + expectedStartCharacter = 16, expectedEndLine = 0, - expectedEndCharacter = 19 + expectedEndCharacter = 20 ) } } diff --git a/modules/integration/src/test/scala/scala/cli/integration/PublishSetupTests.scala b/modules/integration/src/test/scala/scala/cli/integration/PublishSetupTests.scala index 45c4840ebb..c030d265f6 100644 --- a/modules/integration/src/test/scala/scala/cli/integration/PublishSetupTests.scala +++ b/modules/integration/src/test/scala/scala/cli/integration/PublishSetupTests.scala @@ -1,10 +1,8 @@ package scala.cli.integration import com.eed3si9n.expecty.Expecty.expect -import com.virtuslab.using_directives.config.Settings -import com.virtuslab.using_directives.custom.model.UsingDirectiveKind +import com.virtuslab.using_directives.UsingDirectivesProcessor import com.virtuslab.using_directives.reporter.ConsoleReporter -import com.virtuslab.using_directives.{Context, UsingDirectivesProcessor} import org.eclipse.jgit.api.Git import org.eclipse.jgit.transport.URIish @@ -62,20 +60,13 @@ class PublishSetupTests extends ScalaCliSuite { } private def directives(content: String): Map[String, Seq[String]] = { - val reporter = new ConsoleReporter - val processor = { - val settings = new Settings - settings.setAllowStartWithoutAt(true) - settings.setAllowRequire(false) - val context = new Context(reporter, settings) - new UsingDirectivesProcessor(context) - } + val reporter = new ConsoleReporter + val processor = new UsingDirectivesProcessor(reporter) val usedDirectives = processor - .extract(content.toCharArray, true, true) + .extract(content.toCharArray) .asScala - .find(_.getKind == UsingDirectiveKind.SpecialComment) - .get + .head usedDirectives .getFlattenedMap diff --git a/project/deps.sc b/project/deps.sc index 35385adbd3..33ee2242d2 100644 --- a/project/deps.sc +++ b/project/deps.sc @@ -173,7 +173,7 @@ object Deps { def swoval = ivy"com.swoval:file-tree-views:2.1.10" def testInterface = ivy"org.scala-sbt:test-interface:1.0" def toolkit = ivy"org.scala-lang:toolkit:0.1.6" - def usingDirectives = ivy"org.virtuslab:using_directives:0.1.0" + def usingDirectives = ivy"org.virtuslab:using_directives:1.0.0" // Lives at https://github.com/scala-cli/no-crc32-zip-input-stream, see #865 // This provides a ZipInputStream that doesn't verify CRC32 checksums, that users // can enable by setting SCALA_CLI_VENDORED_ZIS=true in the environment, to workaround diff --git a/website/docs/commands/compile.md b/website/docs/commands/compile.md index 491e765a2d..311feb8762 100644 --- a/website/docs/commands/compile.md +++ b/website/docs/commands/compile.md @@ -31,7 +31,7 @@ For a full list of options, run `scala-cli compile --help`, or check the options `--test` makes Scala CLI compile main and test scopes: ```scala title=Sample.test.scala -//> using dep "org.scalameta::munit:0.7.29" +//> using dep org.scalameta::munit:0.7.29 class Test extends munit.FunSuite { test("sample") { assert(2 + 2 == 4) @@ -118,15 +118,15 @@ scala-cli Hello.scala -S 2.13.9-bin-4505094 For setting this inside scala files, use [`using` directives](/docs/guides/using-directives.md): ```scala compile -//> using scala "2.nightly" +//> using scala 2.nightly ``` ```scala compile -//> using scala "3.nightly" +//> using scala 3.nightly ``` ```scala compile -//> using scala "2.13.9-bin-4505094" +//> using scala 2.13.9-bin-4505094 ``` ## Dependencies @@ -189,14 +189,14 @@ It is also possible to pass compiler options with the appropriate `using` direct A single option can be passed like this: ```scala compile -//> using option "-new-syntax" +//> using option -new-syntax @main def hello = if true then println("Hello") ``` It's also possible to pass a value to the option with the same directive: ```scala compile -//> using option "-release", "11" +//> using option -release 11 import java.net.http.HttpRequest ``` @@ -204,7 +204,7 @@ import java.net.http.HttpRequest There's a separate directive for passing multiple options at one time: ```scala compile -//> using options "-new-syntax", "-rewrite", "-source:3.2-migration" +//> using options -new-syntax -rewrite -source:3.2-migration @main def hello = if (true) println("Hello") ``` @@ -459,7 +459,7 @@ scala-cli Hello.scala --javac-opt source --javac-opt 1.8 --javac-opt target --ja You can also add javac options with the using directive `//> using javacOpt`: ```scala compile -//> using javacOpt "source", "1.8", "target", "1.8" +//> using javacOpt source 1.8 target 1.8 ``` ## Exclude sources diff --git a/website/docs/commands/export.md b/website/docs/commands/export.md index 00f751ce8f..1689fee6b7 100644 --- a/website/docs/commands/export.md +++ b/website/docs/commands/export.md @@ -32,9 +32,9 @@ as well as options passed to the `export` sub-command. Let's take a simple one-file project as an example: ```scala title=Hello.scala -//> using scala "3.1.3" -//> using option "-Xasync" -//> using dep "com.lihaoyi::os-lib:0.9.0" +//> using scala 3.1.3 +//> using option -Xasync +//> using dep com.lihaoyi::os-lib:0.9.0 object Hello { def main(args: Array[String]): Unit = diff --git a/website/docs/commands/package.md b/website/docs/commands/package.md index 8e4b8ef765..10624c5a32 100644 --- a/website/docs/commands/package.md +++ b/website/docs/commands/package.md @@ -450,7 +450,7 @@ Instead of passing the `package` options directly from bash, it is possible to p This using directive makes it possible to define the type of the package generated by the `package` command. For example: ```scala compile power -//> using packaging.packageType "assembly" +//> using packaging.packageType assembly ``` Available types: `assembly`, `raw-assembly`, `bootstrap`, `library`, `source`, `doc`, `spark`, `js`, `native`, `docker`, `graalvm`, `deb`, `dmg`, `pkg`, `rpm`, `msi`. @@ -460,7 +460,7 @@ Available types: `assembly`, `raw-assembly`, `bootstrap`, `library`, `source`, ` This using directive makes it possible to define the destination path of the package generated by the `package` command. For example: ```scala compile power -//> using packaging.output "foo" +//> using packaging.output foo ``` The using directive above makes it possible to create a package named `foo` inside the current directory. @@ -470,7 +470,7 @@ The using directive above makes it possible to create a package named `foo` insi This using directive makes it possible to pass args to GraalVM: ```scala compile power -//> using packaging.graalvmArgs "--no-fallback", "--enable-url-protocols=http,https" +//> using packaging.graalvmArgs --no-fallback --enable-url-protocols=http,https ``` ### Docker @@ -480,7 +480,7 @@ This using directive makes it possible to pass args to GraalVM: The using directive allows you to define the base Docker image that is used to run your application. ```scala compile power -//> using packaging.dockerFrom "openjdk:11" +//> using packaging.dockerFrom openjdk:11 ``` #### packaging.dockerFrom @@ -488,7 +488,7 @@ The using directive allows you to define the base Docker image that is used to r The using directive allows you to define the generated Docker image tag. ```scala compile power -//> using packaging.dockerImageTag "1.0.0" +//> using packaging.dockerImageTag 1.0.0 ``` #### packaging.dockerImageRegistry @@ -496,7 +496,7 @@ The using directive allows you to define the generated Docker image tag. The using directive allows you to define the image registry. ```scala compile power -//> using packaging.dockerImageRegistry "virtuslab" +//> using packaging.dockerImageRegistry virtuslab ``` #### packaging.dockerImageRegistry @@ -504,6 +504,6 @@ The using directive allows you to define the image registry. The using directive allows you to define the image repository. ```scala compile power -//> using packaging.dockerImageRepository "scala-cli" +//> using packaging.dockerImageRepository scala-cli ``` diff --git a/website/docs/commands/publishing/publish.md b/website/docs/commands/publishing/publish.md index 1621d897dc..979ebdb080 100644 --- a/website/docs/commands/publishing/publish.md +++ b/website/docs/commands/publishing/publish.md @@ -56,7 +56,7 @@ will infer an organization from it: if your project lives in GitHub organization To override this default value, set the `publish.organization` directive, like ```scala -//> using publish.organization "io.github.foo" +//> using publish.organization io.github.foo ``` ### Name @@ -67,7 +67,7 @@ Scala CLI project lives in a directory named `something`, it will be published a To override this default value, set the `publish.name` directive, like ```scala -//> using publish.name "something" +//> using publish.name something ``` ### Version @@ -78,7 +78,7 @@ Else, if it has such a tag earlier in the git history, version `1.2.4-SNAPSHOT` To override this default value, set the `publish.computeVersion` directive, like ```scala -//> using publish.computeVersion "git:tag" +//> using publish.computeVersion git:tag ``` ## Repository settings @@ -180,9 +180,9 @@ To get started, consult the [documentation on the library's website](https://gnu [Protecting code integrity with PGP guide from the Linux Foundation](https://github.com/lfit/itpol/blob/master/protecting-code-integrity.md#target-audience). To enable signing with GPG, pass `--gpg-key *key_id*` on the command line -or specify it with a `using` directive: `//>using publish.gpgKey "key_id"`. +or specify it with a `using` directive: `//>using publish.gpgKey key_id`. If needed, you can specify arguments meant to be passed to `gpg`, -with `--gpg-option` or `//>using publish.gpgOptions "--opt1" "--opt2"`, like +with `--gpg-option` or `//>using publish.gpgOptions --opt1 --opt2`, like ```text --gpg-key 1234567890ABCDEF --gpg-option --foo --gpg-option --bar ``` diff --git a/website/docs/commands/run.md b/website/docs/commands/run.md index 83913945b2..6ef383fbd2 100644 --- a/website/docs/commands/run.md +++ b/website/docs/commands/run.md @@ -88,7 +88,7 @@ scala-cli Hello.scala --jvm adopt:14 You can also specify custom JVM with the using directive `//> using jvm`: ```scala compile -//> using jvm "adopt:14" +//> using jvm adopt:14 ``` JVMs are [managed by coursier](https://get-coursier.io/docs/cli-java#managed-jvms), and are read from @@ -107,7 +107,7 @@ scala-cli Hello.scala --java-opt -Xmx1g --java-opt -Dfoo=bar You can also add java options with the using directive `//> using javaOpt`: ```scala compile -//> using javaOpt "-Xmx1g", "-Dfoo=bar" +//> using javaOpt -Xmx1g -Dfoo=bar ``` Additionally, java properties can be passed to Scala CLI without `--java-prop`: @@ -135,7 +135,7 @@ When you provide a JAR file as input to Scala CLI, it will be added to the `clas You can also add source files with the using directive `//> using file`: ```scala title=Main.scala -//> using file "Utils.scala" +//> using file Utils.scala object Main extends App { println(Utils.message) @@ -169,7 +169,7 @@ Hello World It is also possible to pass multiple paths to source files in a single using directive: ```scala title=Multiple.scala -//> using files "Utils.scala", "Main.scala" +//> using files Utils.scala Main.scala ``` ```bash diff --git a/website/docs/commands/test.md b/website/docs/commands/test.md index 416276c674..3dc97ebeae 100644 --- a/website/docs/commands/test.md +++ b/website/docs/commands/test.md @@ -17,7 +17,7 @@ or [special imports](/docs/guides/configuration#special-imports)) can be used to A source file is treated as test source if: -- it contains the `//> using target.scope "test"` directive, or +- it contains the `//> using target.scope test` directive, or - the file name ends with `.test.scala`, or - the file comes from a directory that is provided as input, and the relative path from that file to its original directory contains a `test` directory @@ -80,7 +80,7 @@ when running your whole app, you only need it in tests. So rather than declare i the `test.dep` directive: ```scala compile -//> using test.dep "org.scalameta::munit::0.7.29" +//> using test.dep org.scalameta::munit::0.7.29 ``` For more details on test directives, @@ -103,7 +103,7 @@ Some of the most popular test frameworks in Scala are: The following example shows how to run an munit-based test suite: ```scala title=MyTests.test.scala -//> using test.dep "org.scalameta::munit::0.7.29" +//> using test.dep org.scalameta::munit::0.7.29 class MyTests extends munit.FunSuite { test("foo") { @@ -137,7 +137,7 @@ foo Passing the `--test-only` option to the `test` sub-command filters the test suites to be run: ```scala title=BarTests.test.scala -//> using test.dep "org.scalameta::munit::0.7.29" +//> using test.dep org.scalameta::munit::0.7.29 package tests.only class BarTests extends munit.FunSuite { @@ -175,7 +175,7 @@ tests.only.BarTests: To run a specific test case inside the unit test suite pass `*exact-test-name*` as an argument to scala-cli: ```scala title=BarTests.test.scala -//> using test.dep "org.scalameta::munit::0.7.29" +//> using test.dep org.scalameta::munit::0.7.29 package tests.only class Tests extends munit.FunSuite { @@ -209,7 +209,7 @@ tests.only.Tests: You can pass test arguments to your test framework by passing them after `--`: ```scala title=MyTests.test.scala -//> using test.dep "org.scalatest::scalatest::3.2.9" +//> using test.dep org.scalatest::scalatest::3.2.9 import org.scalatest._ import org.scalatest.flatspec._ diff --git a/website/docs/cookbooks/debugging.md b/website/docs/cookbooks/debugging.md index 20991c95f9..91081d72a9 100644 --- a/website/docs/cookbooks/debugging.md +++ b/website/docs/cookbooks/debugging.md @@ -18,7 +18,7 @@ object MyClass extends App { ``` ```scala title=MyTests.test.scala -//> using dep "org.scalameta::munit::0.7.27" +//> using dep org.scalameta::munit::0.7.27 class MyTests extends munit.FunSuite { test("foo") { diff --git a/website/docs/cookbooks/gh-action.md b/website/docs/cookbooks/gh-action.md index 371fa85ef3..c576143e33 100644 --- a/website/docs/cookbooks/gh-action.md +++ b/website/docs/cookbooks/gh-action.md @@ -10,8 +10,8 @@ To use Scala CLI features in a simple way you can use the GitHub Actions [scala- For example, here's a simple `ls` application printing the files in a given directory: ```scala title=Ls.scala -//> using scala "2.13" -//> using dep "com.lihaoyi::os-lib:0.7.8" +//> using scala 2.13 +//> using dep com.lihaoyi::os-lib:0.7.8 @main def hello(args: String*) = val path = args.headOption match @@ -25,7 +25,7 @@ For example, here's a simple `ls` application printing the files in a given dire and some tests for `ls` application: ```scala title=TestsLs.test.scala -//> using dep "org.scalameta::munit::0.7.27" +//> using dep org.scalameta::munit::0.7.27 import scala.util.Properties class TestsLs extends munit.FunSuite { @@ -106,8 +106,8 @@ Scala CLI allows to build native executable applications using [GraalVM](https:/ Given this simple Scala Script `package.sc` to package application to every platform: ```scala title=package.sc -//> using scala "3.1.2" -//> using dep "com.lihaoyi::os-lib:0.8.0" +//> using scala 3.1.2 +//> using dep com.lihaoyi::os-lib:0.8.0 import scala.util.Properties val platformSuffix: String = { diff --git a/website/docs/cookbooks/gists.md b/website/docs/cookbooks/gists.md index 475f9cf3b9..c080dec765 100644 --- a/website/docs/cookbooks/gists.md +++ b/website/docs/cookbooks/gists.md @@ -56,7 +56,7 @@ You can also use resources from gists archive. This is done by passing `resource For example, given the gist `https://gist.github.com/lwronski/7ee12fa4b8b8bac3211841273df82080` which containing Scala code and text file: ```scala title=Hello.scala -//> using resourceDir "./" +//> using resourceDir ./ import scala.io.Source object Hello extends App { diff --git a/website/docs/cookbooks/instant-startup-scala-scripts.md b/website/docs/cookbooks/instant-startup-scala-scripts.md index 958af5c082..f532b70d4b 100644 --- a/website/docs/cookbooks/instant-startup-scala-scripts.md +++ b/website/docs/cookbooks/instant-startup-scala-scripts.md @@ -17,8 +17,8 @@ As an example, let’s build a script printing files from a directory with sizes bigger than a passed value. ```scala title=size-higher-than.scala -//> using scala "3.1.1" -//> using dep "com.lihaoyi::os-lib::0.8.1" +//> using scala 3.1.1 +//> using dep com.lihaoyi::os-lib::0.8.1 @main def sizeHigherThan(dir: String, minSizeMB: Int) = @@ -55,9 +55,9 @@ We can fix that by either running with a `—-native` option, or, in this case, by including an additional using directive: ```scala compile title=size-higher-than.scala -//> using scala "3.1.1" -//> using dep "com.lihaoyi::os-lib::0.8.1" -//> using platform "scala-native" +//> using scala 3.1.1 +//> using dep com.lihaoyi::os-lib::0.8.1 +//> using platform scala-native @main def sizeHigherThan(dir: String, minSizeMB: Int) = @@ -81,10 +81,10 @@ We can make the runtime itself even faster, using various Scala Native optimizat We pass these using a `-–native-mode` scala-cli option or, like previously, by adding a using directive: ```scala compile title=size-higher-than.scala -//> using scala "3.1.1" -//> using dep "com.lihaoyi::os-lib::0.8.1" -//> using platform "scala-native" -//> using nativeMode "release-full" +//> using scala 3.1.1 +//> using dep com.lihaoyi::os-lib::0.8.1 +//> using platform scala-native +//> using nativeMode release-full @main def sizeHigherThan(dir: String, minSizeMB: Int) = diff --git a/website/docs/cookbooks/intellij-multi-bsp.md b/website/docs/cookbooks/intellij-multi-bsp.md index 4b8b5de090..9444e84dea 100644 --- a/website/docs/cookbooks/intellij-multi-bsp.md +++ b/website/docs/cookbooks/intellij-multi-bsp.md @@ -45,7 +45,7 @@ tree -a ``` ```scala title=app1/test/MyTests1.scala -//> using dep "org.scalameta::munit:1.0.0-M7" +//> using dep org.scalameta::munit:1.0.0-M7 class MyTests1 extends munit.FunSuite { test("my test 1") { assert(2 + 2 == 4) @@ -58,7 +58,7 @@ class MyTests1 extends munit.FunSuite { ``` ```scala title=app2/test/MyTests2.scala -//> using dep "com.lihaoyi::utest::0.8.1" +//> using dep com.lihaoyi::utest::0.8.1 import utest.* diff --git a/website/docs/cookbooks/intellij.md b/website/docs/cookbooks/intellij.md index e9aec28ceb..4e338f8186 100644 --- a/website/docs/cookbooks/intellij.md +++ b/website/docs/cookbooks/intellij.md @@ -17,7 +17,7 @@ def hello() = println("Hello, world") ``` ```scala title=test/MyTests.test.scala -//> using dep "org.scalameta::munit::1.0.0-M1" +//> using dep org.scalameta::munit::1.0.0-M1 class MyTests extends munit.FunSuite { test("test") { diff --git a/website/docs/cookbooks/scala-versions.md b/website/docs/cookbooks/scala-versions.md index 7a76079aaf..28700f3156 100644 --- a/website/docs/cookbooks/scala-versions.md +++ b/website/docs/cookbooks/scala-versions.md @@ -90,7 +90,7 @@ The `using` directives syntax is still experimental, and may change in future ve Here’s an example of a source code file named `version.scala` that contains a `using` directive: ```scala title=version.scala -//> using scala "2.12" +//> using scala 2.12 object OldCode //rest of the config diff --git a/website/docs/cookbooks/test-only.md b/website/docs/cookbooks/test-only.md index 3acff77809..8ad8ff359c 100644 --- a/website/docs/cookbooks/test-only.md +++ b/website/docs/cookbooks/test-only.md @@ -26,7 +26,7 @@ The `--test-only` option is supported for every test framework running with Scal For example, passing `tests.only*` to the `--test-only` option runs only the test suites which start with `tests.only`: ```scala title=BarTests.scala -//> using dep "org.scalameta::munit::0.7.29" +//> using dep org.scalameta::munit::0.7.29 package tests.only class BarTests extends munit.FunSuite { @@ -70,7 +70,7 @@ To run a specific test case inside a test suite pass `*test-name*` as an argumen ```scala title=MunitTests.scala -//> using dep "org.scalameta::munit::0.7.29" +//> using dep org.scalameta::munit::0.7.29 package tests.only class Tests extends munit.FunSuite { @@ -109,7 +109,7 @@ order to run a specific test case you will need to specify the exact name of the ```scala title=MyTests.scala -//> using dep "com.lihaoyi::utest::0.7.10" +//> using dep com.lihaoyi::utest::0.7.10 import utest._ diff --git a/website/docs/cookbooks/vscode.md b/website/docs/cookbooks/vscode.md index 3f9d35ec00..2d30b04e78 100644 --- a/website/docs/cookbooks/vscode.md +++ b/website/docs/cookbooks/vscode.md @@ -13,7 +13,7 @@ def hello() = println("Hello, world") ``` ```scala title=MyTests.test.scala -//> using dep "org.scalameta::munit::1.0.0-M1" +//> using dep org.scalameta::munit::1.0.0-M1 class MyTests extends munit.FunSuite { test("test") { diff --git a/website/docs/getting_started.md b/website/docs/getting_started.md index 24bfc11d49..9309c1d055 100644 --- a/website/docs/getting_started.md +++ b/website/docs/getting_started.md @@ -119,7 +119,7 @@ cd scala-cli-getting-started Now we can write our logic in a file named `files.scala`: ```scala title=files.scala -//> using dep "com.lihaoyi::os-lib:0.9.0" +//> using dep com.lihaoyi::os-lib:0.9.0 def filesByExtension( extension: String, @@ -156,7 +156,7 @@ With our IDE in place, how can we test if our code works correctly? The best way We also need to add a test framework. Scala CLI support most popular test frameworks, and for this guide we will stick with [munit](https://scalameta.org/munit/). To add a test framework, we just need an ordinary dependency, and once again we'll add that with the `using` directive: ```scala title=files.test.scala -//> using dep "org.scalameta::munit:1.0.0-M1" +//> using dep org.scalameta::munit:1.0.0-M1 class TestSuite extends munit.FunSuite { test("hello") { diff --git a/website/docs/guides/configuration.md b/website/docs/guides/configuration.md index 1d174b73e5..7ffdb5d846 100644 --- a/website/docs/guides/configuration.md +++ b/website/docs/guides/configuration.md @@ -69,9 +69,9 @@ This is achieved by specifying `using` directives inside comments at the top of before any `package` or `import` statement: ```scala compile -//> using scala "2.13" -//> using platform "scala-js" -//> using options "-Xasync" +//> using scala 2.13 +//> using platform scala-js +//> using options -Xasync // package and import statements follow here ... ``` @@ -81,7 +81,7 @@ The reference documentation lists [all available using directives](/docs/referen Also, there are some directives which only target tests, like `using test.dep`. Those can be useful when defining configuration specific to your test runs. ```scala compile -//> using test.dep "com.lihaoyi::utest:0.7.10" +//> using test.dep com.lihaoyi::utest:0.7.10 ``` More details can be found in the [`using` directives guide](./using-directives.md#directives-with-a-test-scope-equivalent). @@ -91,8 +91,8 @@ More details can be found in the [`using` directives guide](./using-directives.m Dependencies can be added right from `.scala` and `.sc` files with [`using` directives](#using-directives): ```scala compile -//> using dep "com.lihaoyi::upickle:1.4.0" -//> using dep "com.lihaoyi::pprint:0.6.6" +//> using dep com.lihaoyi::upickle:1.4.0 +//> using dep com.lihaoyi::pprint:0.6.6 import ujson._ ``` diff --git a/website/docs/guides/dependencies.md b/website/docs/guides/dependencies.md index 4380dcadf3..48d42d65e1 100644 --- a/website/docs/guides/dependencies.md +++ b/website/docs/guides/dependencies.md @@ -48,7 +48,7 @@ It requires passing the organization and module name of the dependency to be exc the following Scala code: ```scala title=Main.scala -//> using dep "com.lihaoyi::pprint:0.8.1" +//> using dep com.lihaoyi::pprint:0.8.1 object Main extends App { println("Hello") } @@ -58,7 +58,7 @@ If you want to compile it with the `pprint` library but exclude its `sourcecode` the `exclude` parameter as follows: ```scala title=Main.scala -//> using dep "com.lihaoyi::pprint:0.8.1,exclude=com.lihaoyi%%sourcecode" +//> using dep com.lihaoyi::pprint:0.8.1,exclude=com.lihaoyi%%sourcecode object Main extends App { println("Hello") } @@ -67,7 +67,7 @@ object Main extends App { To exclude Scala modules, you can also use a single `%` but with the full name of the module name, like this: ```scala title=Main.scala -//> using dep "com.lihaoyi::pprint:0.8.1,exclude=com.lihaoyi%sourcecode_3" +//> using dep com.lihaoyi::pprint:0.8.1,exclude=com.lihaoyi%sourcecode_3 object Main extends App { println("Hello") } @@ -83,7 +83,7 @@ If you want to use the `pytorch` dependency with the classifier `linux-x86_64`, follows: ```scala title=Main.scala -//> using dep "org.bytedeco:pytorch:1.12.1-1.5.8,classifier=linux-x86_64" +//> using dep org.bytedeco:pytorch:1.12.1-1.5.8,classifier=linux-x86_64 object Main extends App { println("Hello") } @@ -94,7 +94,7 @@ object Main extends App { It is possible to declare dependencies limited to the test scope with the `using test.dep` directive. ```scala -//> using test.dep "org.scalameta::munit::0.7.29" +//> using test.dep org.scalameta::munit::0.7.29 ````` More details can be found in diff --git a/website/docs/guides/markdown.md b/website/docs/guides/markdown.md index a6c9d98e95..7cd42d9f4d 100644 --- a/website/docs/guides/markdown.md +++ b/website/docs/guides/markdown.md @@ -274,7 +274,7 @@ You can run `scala test` code blocks with the `test` sub-command. This is a simple example of an `.md` file with a test Scala snippet. ```scala test -//> using dep "org.scalameta::munit:0.7.29" +//> using dep org.scalameta::munit:0.7.29 class Test extends munit.FunSuite { test("example test") { assert(true) @@ -367,7 +367,7 @@ This is supported for all `scala` code block flavours. ## `scala raw` example ```scala raw -//> using dep "com.lihaoyi::pprint:0.8.0" +//> using dep com.lihaoyi::pprint:0.8.0 object Printer { def printHello(): Unit = pprint.pprintln("Hello") } @@ -375,13 +375,13 @@ object Printer { ## Plain `scala` example ```scala -//> using dep "com.lihaoyi::os-lib:0.8.1" +//> using dep com.lihaoyi::os-lib:0.8.1 println(os.pwd) ``` ## `scala test` example ```scala test -//> using dep "org.scalameta::munit:1.0.0-M7" +//> using dep org.scalameta::munit:1.0.0-M7 class Test extends munit.FunSuite { test("foo") { @@ -408,14 +408,14 @@ context. A directive defined in a later snippet within the same source may overr ## 1 ```scala -//> using scala "2.12.17" +//> using scala 2.12.17 println(util.Properties.versionNumberString) ``` ## 2 ```scala -//> using scala "2.13.10" +//> using scala 2.13.10 println(util.Properties.versionNumberString) ``` ```` diff --git a/website/docs/guides/scala-js.md b/website/docs/guides/scala-js.md index a8c6fd9f5b..1579187a07 100644 --- a/website/docs/guides/scala-js.md +++ b/website/docs/guides/scala-js.md @@ -87,9 +87,9 @@ Hello World from Scala.js Passing `--js-module-split-style smallestmodules` to the `package` sub-command creates many small modules as possibles for the classes in the listed packages (and their subpackages). To define packages use `jsSmallModuleForPackage` parameter. ```scala title=SmallestModules.scala -//> using jsModuleKind "es" -//> using jsModuleSplitStyleStr "smallmodulesfor" -//> using jsSmallModuleForPackage "com.example.test", "com.example.example"" +//> using jsModuleKind es +//> using jsModuleSplitStyleStr smallmodulesfor +//> using jsSmallModuleForPackage com.example.test com.example.example package com.example.test @@ -143,7 +143,7 @@ npm install jsdom ::: ```scala title=Hello.scala -//> using dep "org.scala-js::scalajs-dom::2.1.0" +//> using dep org.scala-js::scalajs-dom::2.1.0 //> using platform scala-js object Hello { diff --git a/website/docs/guides/scripts.md b/website/docs/guides/scripts.md index 7b7aee76c9..f921fa5172 100644 --- a/website/docs/guides/scripts.md +++ b/website/docs/guides/scripts.md @@ -195,7 +195,7 @@ script.sc You can also add source files with the using directive `//> using file` in Scala scripts: ```scala title=main.sc -//> using file "Utils.scala" +//> using file Utils.scala println(Utils.message) ``` diff --git a/website/docs/guides/update-dependencies.md b/website/docs/guides/update-dependencies.md index d639fe395b..99388c2171 100644 --- a/website/docs/guides/update-dependencies.md +++ b/website/docs/guides/update-dependencies.md @@ -8,8 +8,8 @@ import {ChainedSnippets} from "../../src/components/MarkdownComponents.js"; To check if dependencies in using directives are up-to-date, use `dependency-update` command: ```scala title=Hello.scala -//> using dep "com.lihaoyi::os-lib:0.7.8" -//> using dep "com.lihaoyi::utest:0.7.10" +//> using dep com.lihaoyi::os-lib:0.7.8 +//> using dep com.lihaoyi::utest:0.7.10 object Hello extends App { println("Hello World") diff --git a/website/docs/guides/using-directives.md b/website/docs/guides/using-directives.md index a0e05e1b2c..2b9c3a8c6e 100644 --- a/website/docs/guides/using-directives.md +++ b/website/docs/guides/using-directives.md @@ -3,10 +3,6 @@ title: Using directives sidebar_position: 5 --- -:::warning -`using` directives is an experimental language extension that may change in future versions of Scala CLI. -::: - The `using` directives mechanism lets you define configuration information within `.scala` source code files, eliminating the need for build tools to define a dedicated configuration syntax. @@ -14,60 +10,23 @@ eliminating the need for build tools to define a dedicated configuration syntax. need to be put in comments with a special syntax. For instance, this command: ```scala -//> using foo "bar", "baz" -``` - -Scala CLI reports warnings for each using directive that does not contribute to the build, which includes all removed -alternatives to special comment using directives. - -With following snippet: - -```scala -using scala "3.1" -// using scala "2.13.8" -//> using scala "2.12.11" -``` - -Scala `2.12.11` will be used and following warnings would be reported: - -``` -[warn] ./.pg/a.scala:1:1: This using directive is ignored. Only using directives starting with //> are supported. -[warn] using scala "3.1" -[warn] ^^^ -[warn] ./.pg/a.scala:2:1: Using directive using plain comments are deprecated. Please use a special comment syntax: '//> ...'. -[warn] // using scala "2.13.8" -[warn] ^^^^ +//> using foo bar baz ``` ## Deprecated syntax As a part of `0.0.x` series we experimented with different syntaxes for using directives. Based on feedback and discussions with the Scala compiler team, we decided to remove `@using` (using annotations), `// using` (using within -plain comment) and `using` code directives. Those syntaxes will keep working in the `0.1.x` series and will result in an -error starting from `1.0.x`. - -Scala CLI produces warnings if any of the syntaxes above is used: - -``` -[warn] ./.pg/a.scala:1:1: Using directive using plain comments are deprecated, please add `>` to each comment. -[warn] // using scala "3" -[warn] ^^^ -``` - -``` -[warn] ./.pg/a.scala:1:1: Deprecated using directive syntax, please use keyword `using`. -[warn] @using scala "3" -[warn] ^^^^^^ -``` +plain comment) and `using` code directives. Those syntaxes will keep working in the `0.1.x` series and will be ignored starting from `1.0.x`. ## Semantics `using` directives can be only declared **before any other Scala code**: ```scala -//> using scala "2.13" -//> using platform "scala-js" -//> using options "-Xasync" +//> using scala 2.13 +//> using platform scala-js +//> using options -Xasync // package statements, import statements and other code follows ... ``` @@ -79,23 +38,23 @@ whether the source file is a test, or not). The only exceptions are `using target` directives, which only apply to the given file. `using target` is a marker to assign a given file to a given target (e.g., test or main sources). -**We believe that syntax similar to `using` directives should become a part of Scala in the future.** +**We believe that syntax similar to `using` directives should become a part of Scala in the future and will already be included within the Scala runner itself** ## `using` directives in the Scala CLI Below is a list of the most important `using` directives that Scala CLI supports. The full list can be found in the [Reference section of this documentation](/docs/reference/directives.md). -- `//> using scala ""` - defines version of Scala used -- `//> using dep "org::name:version"` - defines dependency to a given +- `//> using scala ` - defines version of Scala used +- `//> using dep org::name:version` - defines dependency to a given library [more in dedicated guide](/docs/guides/dependencies.md) -- `//> using dep "org:name:version"` - defines dependency to a given **java** library, note the `:` instead of `::` -- `//> using dep "org::name:version,url=url"` - defines dependency to a given library with a fallback to its jar url -- `//> using resourceDir "dir"` - marks directory as source of resources. Resources accessible at runtime and packaged +- `//> using dep org:name:version` - defines dependency to a given **java** library, note the `:` instead of `::` +- `//> using dep org::name:version,url=url` - defines dependency to a given library with a fallback to its jar url +- `//> using resourceDir dir` - marks directory as source of resources. Resources accessible at runtime and packaged together with compiled code. -- `//> using javaOpt "opt"` - use given java options when running application or tests -- `//> using target.scope "test"` used to marked or unmarked given source as test -- `//> using testFramework "framework"` - select test framework to use +- `//> using javaOpt opt` - use given java options when running application or tests +- `//> using target.scope test` used to marked or unmarked given source as test +- `//> using testFramework framework` - select test framework to use There are several reasons that we believe `using` directives are a good solution: @@ -127,14 +86,14 @@ The `${.}` pattern in directive values will be replaced by the parent directory directive. This makes it possible for example to generate coverage output files relative to the source file location. ```scala -//> using options "-coverage-out:${.}" +//> using options -coverage-out:${.} ``` However, if you want to include the `${.}` pattern in the directive value without it being replaced, you can precede it with two dollar signs (`$$`), like this: ```scala -//> using options "-coverage-out:$${.}" +//> using options -coverage-out:$${.} ``` ## How to comment out using directives? @@ -159,25 +118,25 @@ dependencies that are only used in tests outside test-specific sources. For example, this way you can declare the dependency to `munit` in `project.scala` like this: ```scala title=project.scala -//> using test.dep "org.scalameta::munit::0.7.29" +//> using test.dep org.scalameta::munit::0.7.29 ``` The dependency will then only be available in test sources. It's effectively an equivalent to just `using dep` inside of a test source (except you can define it anywhere): ```scala title=src/test/scala/Tests.scala -//> using dep "org.scalameta::munit::0.7.29" +//> using dep org.scalameta::munit::0.7.29 ``` Directives with a test scope equivalent: ```scala compile -//> using test.dep "org.scalameta::munit::0.7.29" -//> using test.jar "path/to/jar" -//> using test.javaOpt "-Dfoo=bar" -//> using test.javacOpt "source", "1.8", "target", "1.8" -//> using test.javaProp "foo1=bar1" -//> using test.option "-Xfatal-warnings" -//> using test.resourceDir "testResources" -//> using test.toolkit "latest" +//> using test.dep org.scalameta::munit::0.7.29 +//> using test.jar path/to/jar +//> using test.javaOpt -Dfoo=bar +//> using test.javacOpt source 1.8 target 1.8 +//> using test.javaProp foo1=bar1 +//> using test.option -Xfatal-warnings +//> using test.resourceDir testResources +//> using test.toolkit latest ``` diff --git a/website/docs/guides/verbosity.md b/website/docs/guides/verbosity.md index de4d3c585a..16f09613f9 100644 --- a/website/docs/guides/verbosity.md +++ b/website/docs/guides/verbosity.md @@ -101,11 +101,11 @@ That can be done by passing an appropriate option or by setting the appropriate ### Warnings about `using` directives spread in multiple files ```scala title=Deps1.sc -//> using dep "com.lihaoyi::os-lib:0.9.1" +//> using dep com.lihaoyi::os-lib:0.9.1 ``` ```scala title=Deps2.sc -//> using dep "com.lihaoyi::pprint:0.8.0" +//> using dep com.lihaoyi::pprint:0.8.0 ``` It is generally advised to not spread the `using` directives in multiple files, and put them in the @@ -144,7 +144,7 @@ scala-cli config suppress-warning.experimental-features true ### Warnings about having outdated dependencies ```scala title=OldDeps.sc -//> using dep "com.lihaoyi::pprint:0.6.6" +//> using dep com.lihaoyi::pprint:0.6.6 ``` Depending on outdated libraries produces warnings, which can be suppressed with diff --git a/website/docs/reference/directives.md b/website/docs/reference/directives.md index 509ae4d218..703d226293 100644 --- a/website/docs/reference/directives.md +++ b/website/docs/reference/directives.md @@ -14,11 +14,11 @@ Add Scala compiler options `//> using options `_option1_, _option2_ … #### Examples -`//> using option "-Xasync"` +`//> using option -Xasync` -`//> using test.option "-Xasync"` +`//> using test.option -Xasync` -`//> using options "-Xasync", "-Xfatal-warnings"` +`//> using options -Xasync, -Xfatal-warnings` ### Compiler plugins @@ -27,7 +27,7 @@ Adds compiler plugins `using plugin `_org_`:`name`:`ver #### Examples -`//> using plugin "org.typelevel:::kind-projector:0.13.2"` +`//> using plugin org.typelevel:::kind-projector:0.13.2` ### Custom JAR @@ -35,12 +35,12 @@ Manually add JAR(s) to the class path //> using jar _path_ -//> using jars _path1_, _path2_ … +//> using jars _path1_ _path2_ … #### Examples -`//> using jar "/Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar"` +`//> using jar /Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar` -`//> using test.jar "/Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar"` +`//> using test.jar /Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar` ### Custom sources @@ -51,22 +51,22 @@ Manually add sources to the project //> using files Utils.scala, Helper.scala … #### Examples -`//> using file "utils.scala"` +`//> using file utils.scala` ### Dependency Add dependencies -`//> using dep "`_org_`:`name`:`ver" +`//> using dep `_org_`:`name`:`ver #### Examples -`//> using dep "com.lihaoyi::os-lib:0.9.1"` +`//> using dep com.lihaoyi::os-lib:0.9.1` -`//> using test.dep "org.scalatest::scalatest:3.2.10"` +`//> using test.dep org.scalatest::scalatest:3.2.10` -`//> using test.dep "org.scalameta::munit:0.7.29"` +`//> using test.dep org.scalameta::munit:0.7.29` -`//> using dep "tabby:tabby:0.2.3,url=https://github.com/bjornregnell/tabby/releases/download/v0.2.3/tabby_3-0.2.3.jar"` +`//> using dep tabby:tabby:0.2.3,url=https://github.com/bjornregnell/tabby/releases/download/v0.2.3/tabby_3-0.2.3.jar` ### Exclude sources @@ -74,10 +74,10 @@ Exclude sources from the project `//> using exclude "*.sc"` -`//> using exclude "examples/*", "*/resources/*" …` +`//> using exclude "examples/*" "*/resources/*" …` #### Examples -`//> using exclude "utils.scala"` +`//> using exclude utils.scala` ### JVM version @@ -86,11 +86,11 @@ Use a specific JVM, such as `14`, `adopt:11`, or `graalvm:21`, or `system` `//> using jvm` _value_ #### Examples -`//> using jvm "11"` +`//> using jvm 11` -`//> using jvm "adopt:11"` +`//> using jvm adopt:11` -`//> using jvm "graalvm:21"` +`//> using jvm graalvm:21` ### Java home @@ -99,7 +99,7 @@ Sets Java home used to run your application or tests `//> using javaHome `_path_ #### Examples -`//> using javaHome "/Users/Me/jdks/11"` +`//> using javaHome /Users/Me/jdks/11` ### Java options @@ -108,9 +108,9 @@ Add Java options which will be passed when running an application. `//> using javaOpt `_options_ #### Examples -`//> using javaOpt "-Xmx2g", "-Dsomething=a"` +`//> using javaOpt -Xmx2g, -Dsomething=a` -`//> using test.javaOpt "-Dsomething=a"` +`//> using test.javaOpt -Dsomething=a` ### Java properties @@ -120,9 +120,9 @@ Add Java properties `//> using javaProp `_key_ #### Examples -`//> using javaProp "foo1=bar", "foo2"` +`//> using javaProp foo1=bar, foo2` -`//> using test.javaProp "foo3=bar", "foo4"` +`//> using test.javaProp foo3=bar foo4` ### Javac options @@ -131,9 +131,9 @@ Add Javac options which will be passed when compiling sources. `//> using javacOpt `_options_ #### Examples -`//> using javacOpt "source", "1.8", "target", "1.8"` +`//> using javacOpt -source 1.8 -target 1.8` -`//> using test.javacOpt "source", "1.8", "target", "1.8"` +`//> using test.javacOpt -source 1.8 -target 1.8` ### Main class @@ -142,28 +142,28 @@ Specify default main class `//> using mainClass `_main class_ #### Examples -`//> using mainClass "helloWorld"` +`//> using mainClass helloWorld` ### Packaging Set parameters for packaging -`//> using packaging.packageType `"package type" +`//> using packaging.packageType package_type` -`//> using packaging.output `"destination path" +`//> using packaging.output destination_path` #### Examples -`//> using packaging.packageType "assembly"` +`//> using packaging.packageType assembly` -`//> using packaging.output "foo"` +`//> using packaging.output foo` -`//> using packaging.provided "org.apache.spark::spark-sql"` +`//> using packaging.provided org.apache.spark::spark-sql` -`//> using packaging.dockerFrom "openjdk:11"` +`//> using packaging.dockerFrom openjdk:11` -`//> using packaging.graalvmArgs "--no-fallback"` +`//> using packaging.graalvmArgs --no-fallback` ### Platform @@ -172,57 +172,57 @@ Set the default platform to Scala.js or Scala Native `//> using platform `(`jvm`|`scala-js`|`scala-native`)+ #### Examples -`//> using platform "scala-js"` +`//> using platform scala-js` -`//> using platform "jvm", "scala-native"` +`//> using platform jvm scala-native` ### Publish Set parameters for publishing -`//> using publish.organization `"value" -`//> using publish.name `"value" -`//> using publish.version `"value" +`//> using publish.organization `value +`//> using publish.name `value +`//> using publish.version `value #### Examples -`//> using publish.organization "io.github.myself"` +`//> using publish.organization io.github.myself` -`//> using publish.name "my-library"` +`//> using publish.name my-library` -`//> using publish.version "0.1.1"` +`//> using publish.version 0.1.1` ### Publish (CI) Set CI parameters for publishing -`//> using publish.ci.computeVersion `"value" -`//> using publish.ci.repository `"value" -`//> using publish.ci.secretKey `"value" +`//> using publish.ci.computeVersion `value +`//> using publish.ci.repository `value +`//> using publish.ci.secretKey `value #### Examples -`//> using publish.ci.computeVersion "git:tag"` +`//> using publish.ci.computeVersion git:tag` -`//> using publish.ci.repository "central-s01"` +`//> using publish.ci.repository central-s01` -`//> using publish.ci.secretKey "env:PUBLISH_SECRET_KEY"` +`//> using publish.ci.secretKey env:PUBLISH_SECRET_KEY` ### Publish (contextual) Set contextual parameters for publishing -`//> using publish.computeVersion `"value" -`//> using publish.repository `"value" -`//> using publish.secretKey `"value" +`//> using publish.computeVersion `value +`//> using publish.repository `value +`//> using publish.secretKey `value #### Examples -`//> using publish.computeVersion "git:tag"` +`//> using publish.computeVersion git:tag` -`//> using publish.repository "central-s01"` +`//> using publish.repository central-s01` -`//> using publish.secretKey "env:PUBLISH_SECRET_KEY"` +`//> using publish.secretKey env:PUBLISH_SECRET_KEY` ### Python @@ -240,11 +240,11 @@ Add a repository for dependency resolution `//> using repository `_repository_ #### Examples -`//> using repository "jitpack"` +`//> using repository jitpack` -`//> using repository "sonatype:snapshots"` +`//> using repository sonatype:snapshots` -`//> using repository "https://maven-central.storage-download.googleapis.com/maven2"` +`//> using repository https://maven-central.storage-download.googleapis.com/maven2` ### Resource directories @@ -252,12 +252,12 @@ Manually add a resource directory to the class path `//> using resourceDir `_path_ -`//> using resourceDirs `_path1_, _path2_ … +`//> using resourceDirs `_path1_ _path2_ … #### Examples -`//> using resourceDir "./resources"` +`//> using resourceDir ./resources` -`//> using test.resourceDir "./resources"` +`//> using test.resourceDir ./resources` ### Scala Native options @@ -271,9 +271,9 @@ Add Scala Native options `//> using nativeVersion` _value_ -`//> using nativeCompile` _value1_, _value2_ +`//> using nativeCompile` _value1_ _value2_ -`//> using nativeLinking` _value1_, _value2_ +`//> using nativeLinking` _value1_ _value2_ `//> using nativeClang` _value_ @@ -282,7 +282,7 @@ Add Scala Native options `//> using nativeEmbedResources` _true|false_ #### Examples -`//> using nativeVersion "0.4.0"` +`//> using nativeVersion 0.4.0` ### Scala version @@ -291,13 +291,13 @@ Set the default Scala version `//> using scala `_version_+ #### Examples -`//> using scala "3.0.2"` +`//> using scala 3.0.2` -`//> using scala "2.13"` +`//> using scala 2.13` -`//> using scala "2"` +`//> using scala 2` -`//> using scala "2.13.6", "2.12.16"` +`//> using scala 2.13.6, 2.12.16` ### Scala.js options @@ -310,7 +310,7 @@ Add Scala.js options `//> using jsModuleKind` _value_ -`//> using jsSmallModuleForPackage` _value1_, _value2_ +`//> using jsSmallModuleForPackage` _value1_ _value2_ `//> using jsCheckIr` _true|false_ @@ -332,7 +332,7 @@ Add Scala.js options #### Examples -`//> using jsModuleKind "common"` +`//> using jsModuleKind common` ### Test framework @@ -341,7 +341,7 @@ Set the test framework `//> using testFramework ` _class_name_ #### Examples -`//> using testFramework "utest.runner.Framework"` +`//> using testFramework utest.runner.Framework` ### Toolkit @@ -350,11 +350,11 @@ Use a toolkit as dependency `//> using toolkit` _version_ #### Examples -`//> using toolkit "0.1.0"` +`//> using toolkit 0.1.0` -`//> using toolkit "latest"` +`//> using toolkit latest` -`//> using test.toolkit "latest"` +`//> using test.toolkit latest` ## target directives @@ -366,11 +366,11 @@ Require a Scala platform for the current file `//> using target.platform `_platform_ #### Examples -`//> using target.platform "scala-js"` +`//> using target.platform scala-js` -`//> using target.platform "scala-js", "scala-native"` +`//> using target.platform scala-js, scala-native` -`//> using target.platform "jvm"` +`//> using target.platform jvm` ### Scala version @@ -379,7 +379,7 @@ Require a Scala version for the current file `//> using target.scala `_version_ #### Examples -`//> using target.scala "3"` +`//> using target.scala 3` ### Scala version bounds @@ -388,9 +388,9 @@ Require a Scala version for the current file `//> using target.scala.>= `_version_ #### Examples -`//> using target.scala.>= "2.13"` +`//> using target.scala.>= 2.13` -`//> using target.scala.< "3.0.2"` +`//> using target.scala.< 3.0.2` ### Scope @@ -399,5 +399,5 @@ Require a scope for the current file `//> using target.scope `_scope_ #### Examples -`//> using target.scope "test"` +`//> using target.scope test` diff --git a/website/docs/reference/scala-command/directives.md b/website/docs/reference/scala-command/directives.md index 34428cec45..d78f3f4c68 100644 --- a/website/docs/reference/scala-command/directives.md +++ b/website/docs/reference/scala-command/directives.md @@ -20,11 +20,11 @@ Add Scala compiler options `//> using options `_option1_, _option2_ … #### Examples -`//> using option "-Xasync"` +`//> using option -Xasync` -`//> using test.option "-Xasync"` +`//> using test.option -Xasync` -`//> using options "-Xasync", "-Xfatal-warnings"` +`//> using options -Xasync, -Xfatal-warnings` ### Compiler plugins @@ -33,22 +33,22 @@ Adds compiler plugins `using plugin `_org_`:`name`:`ver #### Examples -`//> using plugin "org.typelevel:::kind-projector:0.13.2"` +`//> using plugin org.typelevel:::kind-projector:0.13.2` ### Dependency Add dependencies -`//> using dep "`_org_`:`name`:`ver" +`//> using dep `_org_`:`name`:`ver #### Examples -`//> using dep "com.lihaoyi::os-lib:0.9.1"` +`//> using dep com.lihaoyi::os-lib:0.9.1` -`//> using test.dep "org.scalatest::scalatest:3.2.10"` +`//> using test.dep org.scalatest::scalatest:3.2.10` -`//> using test.dep "org.scalameta::munit:0.7.29"` +`//> using test.dep org.scalameta::munit:0.7.29` -`//> using dep "tabby:tabby:0.2.3,url=https://github.com/bjornregnell/tabby/releases/download/v0.2.3/tabby_3-0.2.3.jar"` +`//> using dep tabby:tabby:0.2.3,url=https://github.com/bjornregnell/tabby/releases/download/v0.2.3/tabby_3-0.2.3.jar` ### Java options @@ -57,9 +57,9 @@ Add Java options which will be passed when running an application. `//> using javaOpt `_options_ #### Examples -`//> using javaOpt "-Xmx2g", "-Dsomething=a"` +`//> using javaOpt -Xmx2g, -Dsomething=a` -`//> using test.javaOpt "-Dsomething=a"` +`//> using test.javaOpt -Dsomething=a` ### Java properties @@ -69,9 +69,9 @@ Add Java properties `//> using javaProp `_key_ #### Examples -`//> using javaProp "foo1=bar", "foo2"` +`//> using javaProp foo1=bar, foo2` -`//> using test.javaProp "foo3=bar", "foo4"` +`//> using test.javaProp foo3=bar foo4` ### Main class @@ -80,7 +80,7 @@ Specify default main class `//> using mainClass `_main class_ #### Examples -`//> using mainClass "helloWorld"` +`//> using mainClass helloWorld` ### Scala version @@ -89,13 +89,13 @@ Set the default Scala version `//> using scala `_version_+ #### Examples -`//> using scala "3.0.2"` +`//> using scala 3.0.2` -`//> using scala "2.13"` +`//> using scala 2.13` -`//> using scala "2"` +`//> using scala 2` -`//> using scala "2.13.6", "2.12.16"` +`//> using scala 2.13.6, 2.12.16` ## SHOULD have directives: @@ -105,12 +105,12 @@ Manually add JAR(s) to the class path //> using jar _path_ -//> using jars _path1_, _path2_ … +//> using jars _path1_ _path2_ … #### Examples -`//> using jar "/Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar"` +`//> using jar /Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar` -`//> using test.jar "/Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar"` +`//> using test.jar /Users/alexandre/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/chuusai/shapeless_2.13/2.3.7/shapeless_2.13-2.3.7.jar` ### Custom sources @@ -121,7 +121,7 @@ Manually add sources to the project //> using files Utils.scala, Helper.scala … #### Examples -`//> using file "utils.scala"` +`//> using file utils.scala` ### Exclude sources @@ -129,10 +129,10 @@ Exclude sources from the project `//> using exclude "*.sc"` -`//> using exclude "examples/*", "*/resources/*" …` +`//> using exclude "examples/*" "*/resources/*" …` #### Examples -`//> using exclude "utils.scala"` +`//> using exclude utils.scala` ### JVM version @@ -141,11 +141,11 @@ Use a specific JVM, such as `14`, `adopt:11`, or `graalvm:21`, or `system` `//> using jvm` _value_ #### Examples -`//> using jvm "11"` +`//> using jvm 11` -`//> using jvm "adopt:11"` +`//> using jvm adopt:11` -`//> using jvm "graalvm:21"` +`//> using jvm graalvm:21` ### Java home @@ -154,7 +154,7 @@ Sets Java home used to run your application or tests `//> using javaHome `_path_ #### Examples -`//> using javaHome "/Users/Me/jdks/11"` +`//> using javaHome /Users/Me/jdks/11` ### Javac options @@ -163,9 +163,9 @@ Add Javac options which will be passed when compiling sources. `//> using javacOpt `_options_ #### Examples -`//> using javacOpt "source", "1.8", "target", "1.8"` +`//> using javacOpt -source 1.8 -target 1.8` -`//> using test.javacOpt "source", "1.8", "target", "1.8"` +`//> using test.javacOpt -source 1.8 -target 1.8` ### Platform @@ -174,9 +174,9 @@ Set the default platform to Scala.js or Scala Native `//> using platform `(`jvm`|`scala-js`|`scala-native`)+ #### Examples -`//> using platform "scala-js"` +`//> using platform scala-js` -`//> using platform "jvm", "scala-native"` +`//> using platform jvm scala-native` ### Repository @@ -185,11 +185,11 @@ Add a repository for dependency resolution `//> using repository `_repository_ #### Examples -`//> using repository "jitpack"` +`//> using repository jitpack` -`//> using repository "sonatype:snapshots"` +`//> using repository sonatype:snapshots` -`//> using repository "https://maven-central.storage-download.googleapis.com/maven2"` +`//> using repository https://maven-central.storage-download.googleapis.com/maven2` ### Resource directories @@ -197,12 +197,12 @@ Manually add a resource directory to the class path `//> using resourceDir `_path_ -`//> using resourceDirs `_path1_, _path2_ … +`//> using resourceDirs `_path1_ _path2_ … #### Examples -`//> using resourceDir "./resources"` +`//> using resourceDir ./resources` -`//> using test.resourceDir "./resources"` +`//> using test.resourceDir ./resources` ### Scala Native options @@ -216,9 +216,9 @@ Add Scala Native options `//> using nativeVersion` _value_ -`//> using nativeCompile` _value1_, _value2_ +`//> using nativeCompile` _value1_ _value2_ -`//> using nativeLinking` _value1_, _value2_ +`//> using nativeLinking` _value1_ _value2_ `//> using nativeClang` _value_ @@ -227,7 +227,7 @@ Add Scala Native options `//> using nativeEmbedResources` _true|false_ #### Examples -`//> using nativeVersion "0.4.0"` +`//> using nativeVersion 0.4.0` ### Scala.js options @@ -240,7 +240,7 @@ Add Scala.js options `//> using jsModuleKind` _value_ -`//> using jsSmallModuleForPackage` _value1_, _value2_ +`//> using jsSmallModuleForPackage` _value1_ _value2_ `//> using jsCheckIr` _true|false_ @@ -262,7 +262,7 @@ Add Scala.js options #### Examples -`//> using jsModuleKind "common"` +`//> using jsModuleKind common` ### Test framework @@ -271,7 +271,7 @@ Set the test framework `//> using testFramework ` _class_name_ #### Examples -`//> using testFramework "utest.runner.Framework"` +`//> using testFramework utest.runner.Framework` ### Toolkit @@ -280,9 +280,9 @@ Use a toolkit as dependency `//> using toolkit` _version_ #### Examples -`//> using toolkit "0.1.0"` +`//> using toolkit 0.1.0` -`//> using toolkit "latest"` +`//> using toolkit latest` -`//> using test.toolkit "latest"` +`//> using test.toolkit latest` diff --git a/website/src/pages/spark.md b/website/src/pages/spark.md index 0a5c95ef16..43883cb8ed 100644 --- a/website/src/pages/spark.md +++ b/website/src/pages/spark.md @@ -10,8 +10,8 @@ to `spark-submit`, and optimized for it. ```scala title=SparkJob.scala -//> using dep "org.apache.spark::spark-sql:3.0.3" -//> using scala "2.12.15" +//> using dep org.apache.spark::spark-sql:3.0.3 +//> using scala 2.12.15 import org.apache.spark._ import org.apache.spark.sql._ @@ -81,7 +81,7 @@ The `run` sub-command can run Hadoop jobs, by calling the `hadoop jar` command u ```java title=WordCount.java -//> using dep "org.apache.hadoop:hadoop-client-api:3.3.3" +//> using dep org.apache.hadoop:hadoop-client-api:3.3.3 // from https://hadoop.apache.org/docs/r3.3.3/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html