From e3baf827be3e530f47d2a03d14a67663fcb08a78 Mon Sep 17 00:00:00 2001 From: davesmith00000 Date: Sun, 13 Oct 2024 16:41:23 +0100 Subject: [PATCH 1/2] Add sbt and Mill examples to the README --- README.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 87ee5c2..afa31b5 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,13 @@ This library is published for Scala 2.12.x, 2.13.x and 3.1.x: ```scala // sbt -"org.typelevel" %% "scalac-options" % "0.1.3" +"org.typelevel" %% "scalac-options" % "0.1.7" // mill -ivy"org.typelevel::scalac-options:0.1.3" +ivy"org.typelevel::scalac-options:0.1.7" // Scala CLI -//> using lib "org.typelevel::scalac-options:0.1.3" +//> using dep "org.typelevel::scalac-options:0.1.7" ``` This library offers functions for filtering proposed Scala compiler options according to Scala version: @@ -50,10 +50,54 @@ ScalacOptions.defaultOptionsForVersion( ) // returns a Set[ScalacOption] based on the default option set ``` -### Conduct +The following are simple examples of use in sbt and Mill. Note that they are not complete project definitions. + +### sbt example + +Add the following dependency to an `sbt` file within the project directory, for instance `project/plugins`: + +```scala +libraryDependencies += "org.typelevel" %% "scalac-options" % "0.1.7" +``` + +Alter your `build.sbt` file as follows: + +```scala +// Types are not imported directly to avoid collisions with sbt's classes. +import org.typelevel.scalacoptions + +val scala3Version = "3.3.3" + +project + .settings( + scalaVersion := scala3Version, + scalacOptions ++= scalacoptions.ScalacOptions.defaultTokensForVersion( + scalacoptions.ScalaVersion.unsafeFromString(scala3Version) + ) + ) +``` + +### Mill example + +```scala +import $ivy.`org.typelevel::scalac-options:0.1.7`, org.typelevel.scalacoptions._ + +object example extends ScalaModule { + def scalaVersion = "3.3.3" + + override def scalacOptions = T { + super.scalacOptions() ++ + ScalacOptions.defaultTokensForVersion( + ScalaVersion.unsafeFromString(scalaVersion()) + ) + } +} +``` + +## Conduct Participants are expected to follow the [Scala Code of Conduct](https://www.scala-lang.org/conduct/) while discussing the project on GitHub and any other venues associated with the project. See the [organizational Code of Conduct](https://github.com/typelevel/.github/blob/main/CODE_OF_CONDUCT.md) for more details. -### License +## License All code in this repository is licensed under the Apache License, Version 2.0. See [LICENSE](./LICENSE). From 56eaf842140381786b85cf482a89a698c4d8866d Mon Sep 17 00:00:00 2001 From: davesmith00000 Date: Tue, 15 Oct 2024 07:36:23 +0100 Subject: [PATCH 2/2] Removed redundant quotes from Scala-CLI README example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index afa31b5..db10016 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This library is published for Scala 2.12.x, 2.13.x and 3.1.x: ivy"org.typelevel::scalac-options:0.1.7" // Scala CLI -//> using dep "org.typelevel::scalac-options:0.1.7" +//> using dep org.typelevel::scalac-options:0.1.7 ``` This library offers functions for filtering proposed Scala compiler options according to Scala version: