From bc25c1a90e68989c1a4600d1d481ee822f685b2a Mon Sep 17 00:00:00 2001 From: Maciej Gajek Date: Wed, 2 Aug 2023 11:12:59 +0200 Subject: [PATCH 1/4] Edit warning in password option section --- website/docs/reference/password-options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/reference/password-options.md b/website/docs/reference/password-options.md index 679d75007d..80443f4f65 100644 --- a/website/docs/reference/password-options.md +++ b/website/docs/reference/password-options.md @@ -4,7 +4,7 @@ sidebar_position: 8 --- :::caution -The `export` sub-command is restricted and requires setting the `--power` option to be used. +Using password options is restricted and requires setting the `--power` option to be used. You can pass it explicitly or set it globally by running: scala-cli config power true From a9507897aca5beae475b0178cd0cc4ce54164c25 Mon Sep 17 00:00:00 2001 From: Maciej Gajek Date: Wed, 2 Aug 2023 14:17:11 +0200 Subject: [PATCH 2/4] Add scaladoc to BuildInfo, make docs auto-generated --- .../build/tests/SourceGeneratorTests.scala | 38 ++++---- .../scala/cli/doc/GenerateReferenceDoc.scala | 91 +++++++++++++++++++ .../scala/scala/build/info/BuildInfo.scala | 43 ++++++--- .../scala/build/info/ScopedBuildInfo.scala | 23 +++-- website/docs/reference/bloop.md | 2 +- website/docs/reference/build-info.md | 90 ++++++++++++++++++ 6 files changed, 248 insertions(+), 39 deletions(-) create mode 100644 website/docs/reference/build-info.md diff --git a/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala b/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala index 2d166fe081..a9439998a1 100644 --- a/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala @@ -39,7 +39,7 @@ class SourceGeneratorTests extends munit.FunSuite { ) ) - private def normalizeResolvers(contents: String): String = + private def normalizeContents(contents: String): String = contents .replaceAll( "ivy:file:[^\"]*scala-cli-tests-extra-repo[^\"]*/local-repo[^\"]*", @@ -48,7 +48,9 @@ class SourceGeneratorTests extends munit.FunSuite { .replaceAll( "ivy:file:[^\"]*\\.ivy2/local[^\"]*", "ivy:file:.../.ivy2/local/" - ) + ).linesWithSeparators + .filterNot(_.stripLeading().startsWith("/**")) + .mkString test(s"BuildInfo source generated") { val inputs = TestInputs( @@ -85,7 +87,8 @@ class SourceGeneratorTests extends munit.FunSuite { val buildInfoContent = os.read(buildInfoPath) - expect(normalizeResolvers(buildInfoContent) == + assertNoDiff( + normalizeContents(buildInfoContent), s"""package scala.cli.build | |object BuildInfo { @@ -97,7 +100,6 @@ class SourceGeneratorTests extends munit.FunSuite { | val scalaNativeVersion = None | val mainClass = Some("Main") | - | | object Main { | val sources = Seq("${root / "main.scala"}") | val scalacOptions = Seq("-Xasync") @@ -117,9 +119,9 @@ class SourceGeneratorTests extends munit.FunSuite { | val resourceDirs = Nil | val customJarsDecls = Nil | } - | |} - |""".stripMargin) + |""".stripMargin + ) } } @@ -160,7 +162,8 @@ class SourceGeneratorTests extends munit.FunSuite { val buildInfoContent = os.read(buildInfoPath) - expect(normalizeResolvers(buildInfoContent) == + assertNoDiff( + normalizeContents(buildInfoContent), s"""package scala.cli.build | |object BuildInfo { @@ -172,7 +175,6 @@ class SourceGeneratorTests extends munit.FunSuite { | val scalaNativeVersion = Some("0.4.6") | val mainClass = Some("Main") | - | | object Main { | val sources = Seq("${root / "main.scala"}") | val scalacOptions = Seq("-Xasync") @@ -192,9 +194,9 @@ class SourceGeneratorTests extends munit.FunSuite { | val resourceDirs = Nil | val customJarsDecls = Nil | } - | |} - |""".stripMargin) + |""".stripMargin + ) } } @@ -236,7 +238,8 @@ class SourceGeneratorTests extends munit.FunSuite { val buildInfoContent = os.read(buildInfoPath) - expect(normalizeResolvers(buildInfoContent) == + assertNoDiff( + normalizeContents(buildInfoContent), s"""package scala.cli.build | |object BuildInfo { @@ -248,7 +251,6 @@ class SourceGeneratorTests extends munit.FunSuite { | val scalaNativeVersion = None | val mainClass = Some("Main") | - | | object Main { | val sources = Seq("${root / "main.scala"}") | val scalacOptions = Seq("-Xasync") @@ -268,9 +270,9 @@ class SourceGeneratorTests extends munit.FunSuite { | val resourceDirs = Nil | val customJarsDecls = Nil | } - | |} - |""".stripMargin) + |""".stripMargin + ) } } @@ -309,7 +311,8 @@ class SourceGeneratorTests extends munit.FunSuite { val buildInfoContent = os.read(buildInfoPath) - expect(normalizeResolvers(buildInfoContent) == + assertNoDiff( + normalizeContents(buildInfoContent), s"""package scala.cli.build | |object BuildInfo { @@ -321,7 +324,6 @@ class SourceGeneratorTests extends munit.FunSuite { | val scalaNativeVersion = None | val mainClass = Some("Main") | - | | object Main { | val sources = Seq("${root / "main.scala"}") | val scalacOptions = Seq("-Xasync") @@ -341,9 +343,9 @@ class SourceGeneratorTests extends munit.FunSuite { | val resourceDirs = Nil | val customJarsDecls = Nil | } - | |} - |""".stripMargin) + |""".stripMargin + ) } } } diff --git a/modules/generate-reference-doc/src/main/scala/scala/cli/doc/GenerateReferenceDoc.scala b/modules/generate-reference-doc/src/main/scala/scala/cli/doc/GenerateReferenceDoc.scala index 85f64e0fac..9acaf8a87d 100644 --- a/modules/generate-reference-doc/src/main/scala/scala/cli/doc/GenerateReferenceDoc.scala +++ b/modules/generate-reference-doc/src/main/scala/scala/cli/doc/GenerateReferenceDoc.scala @@ -11,6 +11,7 @@ import shapeless.tag import java.nio.charset.StandardCharsets import java.util +import scala.build.info.{ArtifactId, BuildInfo, ExportDependencyFormat, ScopedBuildInfo} import scala.build.options.{BuildOptions, BuildRequirements, WithBuildRequirements} import scala.build.preprocessing.directives.DirectiveHandler import scala.build.preprocessing.directives.DirectivesPreprocessingUtils.* @@ -481,6 +482,93 @@ object GenerateReferenceDoc extends CaseApp[InternalDocOptions] { b.toString } + private def buildInfoContent: String = { + val b = new StringBuilder + + b.section( + """--- + |title: BuildInfo + |sidebar_position: 6 + |---""".stripMargin + ) + b.section( + """:::caution + |BuildInfo is a restricted feature and requires setting the `--power` option to be used. + |You can pass it explicitly or set it globally by running: + | + | scala-cli config power true + |:::""".stripMargin + ) + + b.section( + """During the building process Scala CLI collects information about the project's configuration, + |both from the console options and `using directives` found in the project's sources. + |You can access this information from your code using the `BuildInfo` object, that's automatically generated for your + |build on compile when that information changes.""".stripMargin + ) + + b.section( + """To enable BuildInfo generation pass the `--build-info` option to Scala CLI or use a + |`//> using buildInfo` directive.""".stripMargin + ) + + b.section( + """## Usage + | + |The generated BuildInfo object is available on the project's classpath. To access it you need to import it first. + |It is available in the package `scala.cli.build` so use + |```scala + |import scala.cli.build.BuildInfo + |``` + |to import it. + | + |Below you can find an example instance of the BuildInfo object, with all fields explained. + |Some of the values have been shortened for readability.""".stripMargin + ) + + val osLibDep = ExportDependencyFormat("com.lihaoyi", ArtifactId("os-lib", "os-lib_3"), "0.9.1") + val toolkitDep = + ExportDependencyFormat("org.scala-lang", ArtifactId("toolkit", "toolkit_3"), "latest.release") + + val mainScopedBuildInfo = ScopedBuildInfo(BuildOptions(), Seq(".../Main.scala")).copy( + scalacOptions = Seq("-Werror"), + scalaCompilerPlugins = Nil, + dependencies = Seq(osLibDep), + resolvers = Seq("https://repo1.maven.org/maven2", "ivy:file:..."), + resourceDirs = Seq(".../resources"), + customJarsDecls = Seq(".../AwesomeJar1.jar", ".../AwesomeJar2.jar") + ) + + val testScopedBuildInfo = ScopedBuildInfo(BuildOptions(), Seq(".../MyTests.scala")).copy( + scalacOptions = Seq("-Vdebug"), + scalaCompilerPlugins = Nil, + dependencies = Seq(toolkitDep), + resolvers = Seq("https://repo1.maven.org/maven2", "ivy:file:..."), + resourceDirs = Seq(".../test/resources"), + customJarsDecls = Nil + ) + + val buildInfo = BuildInfo(BuildOptions()).copy( + scalaVersion = Some("3.3.0"), + platform = Some("JVM"), + jvmVersion = Some("11"), + scalaJsVersion = None, + jsEsVersion = None, + scalaNativeVersion = None, + mainClass = Some("Main") + ) + .withScope("main", mainScopedBuildInfo) + .withScope("test", testScopedBuildInfo) + + b.section( + s"""```scala + |${buildInfo.generateContents().strip()} + |```""".stripMargin + ) + + b.mkString + } + def run(options: InternalDocOptions, args: RemainingArgs): Unit = { val scalaCli = new ScalaCliCommands( @@ -512,6 +600,7 @@ object GenerateReferenceDoc extends CaseApp[InternalDocOptions] { requireDirectiveHandlers, onlyRestricted = false ) + val restrictedDirectivesContent = usingContent( allUsingDirectiveHandlers.filterNot(_.isRestricted), requireDirectiveHandlers.filterNot(_.isRestricted), @@ -524,6 +613,7 @@ object GenerateReferenceDoc extends CaseApp[InternalDocOptions] { (os.rel / "cli-options.md") -> allCliOptionsContent, (os.rel / "commands.md") -> allCommandsContent, (os.rel / "directives.md") -> allDirectivesContent, + (os.rel / "build-info.md") -> buildInfoContent, (os.rel / restrictedDocsDir / "cli-options.md") -> restrictedCliOptionsContent, (os.rel / restrictedDocsDir / "commands.md") -> restrictedCommandsContent, (os.rel / restrictedDocsDir / "directives.md") -> restrictedDirectivesContent, @@ -551,6 +641,7 @@ object GenerateReferenceDoc extends CaseApp[InternalDocOptions] { maybeWrite(options.outputPath / "cli-options.md", allCliOptionsContent) maybeWrite(options.outputPath / "commands.md", allCommandsContent) maybeWrite(options.outputPath / "directives.md", allDirectivesContent) + maybeWrite(options.outputPath / "build-info.md", buildInfoContent) maybeWrite( options.outputPath / restrictedDocsDir / "cli-options.md", diff --git a/modules/options/src/main/scala/scala/build/info/BuildInfo.scala b/modules/options/src/main/scala/scala/build/info/BuildInfo.scala index ddf8d4b041..bde82e0232 100644 --- a/modules/options/src/main/scala/scala/build/info/BuildInfo.scala +++ b/modules/options/src/main/scala/scala/build/info/BuildInfo.scala @@ -31,18 +31,38 @@ final case class BuildInfo( val nl = System.lineSeparator() val indent = " " * 2 val stringVals = Seq( + "/** version of Scala used to compile this project */", s"val scalaVersion = \"${escapeBackslashes(scalaVersion.getOrElse(Constants.defaultScalaVersion))}\"", + "/** target platform of this project, it can be \"JVM\" or \"JS\" or \"Native\" */", s"val platform = \"${escapeBackslashes(platform.getOrElse(Platform.JVM.repr))}\"" ) val optionVals = Seq( - "val jvmVersion =" -> jvmVersion, - "val scalaJsVersion =" -> scalaJsVersion, - "val jsEsVersion =" -> jsEsVersion, - "val scalaNativeVersion =" -> scalaNativeVersion, - "val mainClass =" -> mainClass - ).map { case (prefix, opt) => - opt.map(v => s"$prefix Some(\"${escapeBackslashes(v)}\")").getOrElse(s"$prefix None") + Seq( + "/** version of JVM, if it's the target platform */", + "val jvmVersion =" + ) -> jvmVersion, + Seq( + "/** version of Scala.js, if it's the target platform */", + "val scalaJsVersion =" + ) -> scalaJsVersion, + Seq( + "/** Scala.js ECMA Script version, if Scala.js is the target platform */", + "val jsEsVersion =" + ) -> jsEsVersion, + Seq( + "/** version of Scala Native, if it's the target platform */", + "val scalaNativeVersion =" + ) -> scalaNativeVersion, + Seq( + "/** Main class specified for the project */", + "val mainClass =" + ) -> mainClass + ).flatMap { case (Seq(scaladoc, prefix), opt) => + Seq( + scaladoc, + opt.map(v => s"$prefix Some(\"${escapeBackslashes(v)}\")").getOrElse(s"$prefix None") + ) } val allVals = stringVals ++ optionVals @@ -52,17 +72,18 @@ final case class BuildInfo( yield { val scopedBuildInfoVals = scopedBuildInfo.generateContentLines() .mkString(indent, nl + indent * 2, "") - s"""${indent}object ${scopeName.capitalize} { + s"""$indent/** Information about the ${scopeName.capitalize} scope */ + |${indent}object ${scopeName.capitalize} { |$indent$scopedBuildInfoVals - |$indent} - |""".stripMargin + |$indent}""".stripMargin } s"""package scala.cli.build | + |/** Information about the build gathered by Scala CLI */ |object BuildInfo { |${allVals.mkString(indent, nl + indent, nl)} - |${scopesContents.mkString(nl, nl, "")} + |${scopesContents.mkString(nl * 2)} |} |""".stripMargin } diff --git a/modules/options/src/main/scala/scala/build/info/ScopedBuildInfo.scala b/modules/options/src/main/scala/scala/build/info/ScopedBuildInfo.scala index 4ccb41dc7a..8c15327669 100644 --- a/modules/options/src/main/scala/scala/build/info/ScopedBuildInfo.scala +++ b/modules/options/src/main/scala/scala/build/info/ScopedBuildInfo.scala @@ -25,14 +25,19 @@ final case class ScopedBuildInfo( def generateContentLines(): Seq[String] = Seq( - s"val sources = " -> sources, - s"val scalacOptions = " -> scalacOptions, - s"val scalaCompilerPlugins = " -> scalaCompilerPlugins.map(_.toString()), - s"val dependencies = " -> dependencies.map(_.toString()), - s"val resolvers = " -> resolvers, - s"val resourceDirs = " -> resourceDirs, - s"val customJarsDecls = " -> customJarsDecls - ).map { case (prefix, values) => + Seq("/** sources found for the scope */", "val sources = ") -> sources, + Seq("/** scalac options for the scope */", "val scalacOptions = ") -> scalacOptions, + Seq( + "/** compiler plugins used in this scope */", + "val scalaCompilerPlugins = " + ) -> scalaCompilerPlugins.map(_.toString()), + Seq("/** dependencies used in this scope */", "val dependencies = ") -> dependencies.map( + _.toString() + ), + Seq("/** dependency resolvers used in this scope */", "val resolvers = ") -> resolvers, + Seq("/** resource directories used in this scope */", "val resourceDirs = ") -> resourceDirs, + Seq("/** custom jars added to this scope */", "val customJarsDecls = ") -> customJarsDecls + ).flatMap { case (Seq(scaladoc, prefix), values) => val sb = new StringBuilder sb.append(prefix) if (values.isEmpty) sb.append("Nil") @@ -40,7 +45,7 @@ final case class ScopedBuildInfo( values.map(str => s"\"${BuildInfo.escapeBackslashes(str)}\"") .mkString("Seq(", ", ", ")") } - sb.toString() + Seq(scaladoc, sb.toString()) } } diff --git a/website/docs/reference/bloop.md b/website/docs/reference/bloop.md index 0bc6450987..6a8534d925 100644 --- a/website/docs/reference/bloop.md +++ b/website/docs/reference/bloop.md @@ -1,6 +1,6 @@ --- title: Interaction with Bloop server -sidebar_position: 6 +sidebar_position: 10 --- # Interaction with Bloop server diff --git a/website/docs/reference/build-info.md b/website/docs/reference/build-info.md new file mode 100644 index 0000000000..0dcd80b512 --- /dev/null +++ b/website/docs/reference/build-info.md @@ -0,0 +1,90 @@ +--- +title: BuildInfo +sidebar_position: 6 +--- + +:::caution +BuildInfo is a restricted feature and requires setting the `--power` option to be used. +You can pass it explicitly or set it globally by running: + + scala-cli config power true +::: + +During the building process Scala CLI collects information about the project's configuration, +both from the console options and `using directives` found in the project's sources. +You can access this information from your code using the `BuildInfo` object, that's automatically generated for your +build on compile when that information changes. + +To enable BuildInfo generation pass the `--build-info` option to Scala CLI or use a +`//> using buildInfo` directive. + +## Usage + +The generated BuildInfo object is available on the project's classpath. To access it you need to import it first. +It is available in the package `scala.cli.build` so use +```scala +import scala.cli.build.BuildInfo +``` +to import it. + +Below you can find an example instance of the BuildInfo object, with all fields explained. +Some of the values have been shortened for readability. + +```scala +package scala.cli.build + +/** Information about the build gathered by Scala CLI */ +object BuildInfo { + /** version of Scala used to compile this project */ + val scalaVersion = "3.3.0" + /** target platform of this project, it can be "JVM" or "JS" or "Native" */ + val platform = "JVM" + /** version of JVM, if it's the target platform */ + val jvmVersion = Some("11") + /** version of Scala.js, if it's the target platform */ + val scalaJsVersion = None + /** Scala.js ECMA Script version, if Scala.js is the target platform */ + val jsEsVersion = None + /** version of Scala Native, if it's the target platform */ + val scalaNativeVersion = None + /** Main class specified for the project */ + val mainClass = Some("Main") + + /** Information about the Main scope */ + object Main { + /** sources found for the scope */ + val sources = Seq(".../Main.scala") + /** scalac options for the scope */ + val scalacOptions = Seq("-Werror") + /** compiler plugins used in this scope */ + val scalaCompilerPlugins = Nil + /** dependencies used in this scope */ + val dependencies = Seq("com.lihaoyi:os-lib_3:0.9.1") + /** dependency resolvers used in this scope */ + val resolvers = Seq("https://repo1.maven.org/maven2", "ivy:file:...") + /** resource directories used in this scope */ + val resourceDirs = Seq(".../resources") + /** custom jars added to this scope */ + val customJarsDecls = Seq(".../AwesomeJar1.jar", ".../AwesomeJar2.jar") + } + + /** Information about the Test scope */ + object Test { + /** sources found for the scope */ + val sources = Seq(".../MyTests.scala") + /** scalac options for the scope */ + val scalacOptions = Seq("-Vdebug") + /** compiler plugins used in this scope */ + val scalaCompilerPlugins = Nil + /** dependencies used in this scope */ + val dependencies = Seq("org.scala-lang:toolkit_3:latest.release") + /** dependency resolvers used in this scope */ + val resolvers = Seq("https://repo1.maven.org/maven2", "ivy:file:...") + /** resource directories used in this scope */ + val resourceDirs = Seq(".../test/resources") + /** custom jars added to this scope */ + val customJarsDecls = Nil + } +} +``` + From 66ccfa7eb5f8e3e49bb801b1ed72a83819dbe16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wro=C5=84ski?= Date: Tue, 8 Aug 2023 10:30:16 +0200 Subject: [PATCH 3/4] Fix compilation error after merge --- .../build/tests/SourceGeneratorTests.scala | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala b/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala index 66d4f3f5ab..dae2dfd8ba 100644 --- a/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala +++ b/modules/build/src/test/scala/scala/build/tests/SourceGeneratorTests.scala @@ -113,42 +113,42 @@ class SourceGeneratorTests extends munit.FunSuite { val buildInfoContent = os.read(buildInfoPath) - assertNoDiff( - normalizeContents(buildInfoContent), - s"""package scala.cli.build - | - |object BuildInfo { - | val scalaVersion = "3.2.2" - | val platform = "JVM" - | val jvmVersion = Some("11") - | val scalaJsVersion = None - | val jsEsVersion = None - | val scalaNativeVersion = None - | val mainClass = Some("Main") - | val projectVersion = Some("1.0.0") - | - | object Main { - | val sources = Seq("${root / "main.scala"}") - | val scalacOptions = Seq("-Xasync") - | val scalaCompilerPlugins = Seq("org.wartremover:wartremover_3.2.2:3.0.9") - | val dependencies = Seq("com.lihaoyi:os-lib_3:0.9.1") - | val resolvers = Seq("ivy:file:.../scala-cli-tests-extra-repo/local-repo/...", "https://repo1.maven.org/maven2", "ivy:file:.../.ivy2/local/") - | val resourceDirs = Seq("${root / "resources"}") - | val customJarsDecls = Seq("${root / "TEST1.jar"}", "${root / "TEST2.jar"}") - | } - | - | object Test { - | val sources = Nil - | val scalacOptions = Nil - | val scalaCompilerPlugins = Nil - | val dependencies = Nil - | val resolvers = Nil - | val resourceDirs = Nil - | val customJarsDecls = Nil - | } - |} - |""".stripMargin - ) + assertNoDiff( + normalizeContents(buildInfoContent), + s"""package scala.cli.build + | + |object BuildInfo { + | val scalaVersion = "3.2.2" + | val platform = "JVM" + | val jvmVersion = Some("11") + | val scalaJsVersion = None + | val jsEsVersion = None + | val scalaNativeVersion = None + | val mainClass = Some("Main") + | val projectVersion = Some("1.0.0") + | + | object Main { + | val sources = Seq("${root / "main.scala"}") + | val scalacOptions = Seq("-Xasync") + | val scalaCompilerPlugins = Seq("org.wartremover:wartremover_3.2.2:3.0.9") + | val dependencies = Seq("com.lihaoyi:os-lib_3:0.9.1") + | val resolvers = Seq("ivy:file:.../scala-cli-tests-extra-repo/local-repo/...", "https://repo1.maven.org/maven2", "ivy:file:.../.ivy2/local/") + | val resourceDirs = Seq("${root / "resources"}") + | val customJarsDecls = Seq("${root / "TEST1.jar"}", "${root / "TEST2.jar"}") + | } + | + | object Test { + | val sources = Nil + | val scalacOptions = Nil + | val scalaCompilerPlugins = Nil + | val dependencies = Nil + | val resolvers = Nil + | val resourceDirs = Nil + | val customJarsDecls = Nil + | } + |} + |""".stripMargin + ) } } From b17dbcc12fea619679a88c91b14bbfb38cd786f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wro=C5=84ski?= Date: Tue, 8 Aug 2023 10:46:50 +0200 Subject: [PATCH 4/4] Update reference doc --- .../main/scala/scala/cli/doc/GenerateReferenceDoc.scala | 9 ++++++++- website/docs/reference/build-info.md | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/generate-reference-doc/src/main/scala/scala/cli/doc/GenerateReferenceDoc.scala b/modules/generate-reference-doc/src/main/scala/scala/cli/doc/GenerateReferenceDoc.scala index 9acaf8a87d..b808c37c6b 100644 --- a/modules/generate-reference-doc/src/main/scala/scala/cli/doc/GenerateReferenceDoc.scala +++ b/modules/generate-reference-doc/src/main/scala/scala/cli/doc/GenerateReferenceDoc.scala @@ -548,7 +548,14 @@ object GenerateReferenceDoc extends CaseApp[InternalDocOptions] { customJarsDecls = Nil ) - val buildInfo = BuildInfo(BuildOptions()).copy( + val generatedBuildInfo = BuildInfo(BuildOptions(), os.pwd) match { + case Right(bv) => bv + case Left(exception) => + System.err.println(s"Failed to generate BuildInfo: ${exception.message}") + sys.exit(1) + } + + val buildInfo = generatedBuildInfo.copy( scalaVersion = Some("3.3.0"), platform = Some("JVM"), jvmVersion = Some("11"), diff --git a/website/docs/reference/build-info.md b/website/docs/reference/build-info.md index 0dcd80b512..8738e905f8 100644 --- a/website/docs/reference/build-info.md +++ b/website/docs/reference/build-info.md @@ -49,6 +49,8 @@ object BuildInfo { val scalaNativeVersion = None /** Main class specified for the project */ val mainClass = Some("Main") + /** Project version */ + val projectVersion = Some("1.0.3-SNAPSHOT") /** Information about the Main scope */ object Main {