From 2cef7222f1dbd4f6eb7d7a396319a0e12e781be3 Mon Sep 17 00:00:00 2001 From: Adrien Piquerez Date: Fri, 11 Oct 2024 16:57:28 +0200 Subject: [PATCH 1/2] Move dataclassGen to Utils --- build.sbt | 17 +---------------- project/Utils.scala | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/build.sbt b/build.sbt index c1eda5dff..deffeaab4 100644 --- a/build.sbt +++ b/build.sbt @@ -1461,21 +1461,6 @@ lazy val lmCoursierDependencies = Def.settings( ), ) -def dataclassGen(data: Reference) = Def.taskDyn { - val root = (ThisBuild / baseDirectory).value.toURI.toString - val from = (data / Compile / sourceDirectory).value - val to = (Compile / sourceManaged).value - val outFrom = from.toURI.toString.stripSuffix("/").stripPrefix(root) - val outTo = to.toURI.toString.stripSuffix("/").stripPrefix(root) - val _ = (data / Compile / compile).value - Def.task { - val _ = (data / Compile / scalafix) - .toTask(s" --rules GenerateDataClass --out-from=$outFrom --out-to=$outTo") - .value - (to ** "*.scala").get - } -} - lazy val lmCoursierDefinitions = project .in(file("lm-coursier/definitions")) .disablePlugins(MimaPlugin) @@ -1500,7 +1485,7 @@ lazy val lmCoursier = project Mima.settings, Mima.lmCoursierFilters, lmCoursierDependencies, - Compile / sourceGenerators += dataclassGen(lmCoursierDefinitions).taskValue, + Compile / sourceGenerators += Utils.dataclassGen(lmCoursierDefinitions).taskValue, ) .dependsOn( // We depend on lmIvy rather than just lmCore to handle the ModuleDescriptor diff --git a/project/Utils.scala b/project/Utils.scala index 0a94e31b2..a553eeefd 100644 --- a/project/Utils.scala +++ b/project/Utils.scala @@ -1,6 +1,7 @@ import scala.util.control.NonFatal import sbt._ import Keys._ +import scalafix.sbt.ScalafixPlugin.autoImport.scalafix import sbt.internal.inc.Analysis @@ -165,6 +166,21 @@ object Utils { sourceGenerators += Def.task(Seq(generateKeywords.value)).taskValue ) ) + + def dataclassGen(data: Reference) = Def.taskDyn { + val root = (ThisBuild / baseDirectory).value.toURI.toString + val from = (data / Compile / sourceDirectory).value + val to = (Compile / sourceManaged).value + val outFrom = from.toURI.toString.stripSuffix("/").stripPrefix(root) + val outTo = to.toURI.toString.stripSuffix("/").stripPrefix(root) + val _ = (data / Compile / compile).value + Def.task { + val _ = (data / Compile / scalafix) + .toTask(s" --rules GenerateDataClass --out-from=$outFrom --out-to=$outTo") + .value + (to ** "*.scala").get + } + } } object Licensed { From 9d94423f247d9e84f8ea03e5eaed6a4120197799 Mon Sep 17 00:00:00 2001 From: Adrien Piquerez Date: Fri, 11 Oct 2024 17:42:34 +0200 Subject: [PATCH 2/2] [2.x] Exclude Scala libraries from lm-coursier-shaded --- build.sbt | 48 +++++++++++++++----------------------- project/Dependencies.scala | 1 + 2 files changed, 20 insertions(+), 29 deletions(-) diff --git a/build.sbt b/build.sbt index deffeaab4..66bf46a56 100644 --- a/build.sbt +++ b/build.sbt @@ -1447,20 +1447,6 @@ lazy val lmCoursierSettings: Seq[Setting[_]] = Def.settings( ), ) -lazy val lmCoursierDependencies = Def.settings( - libraryDependencies ++= Seq( - coursier, - coursierSbtMavenRepo, - "io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier" % jniUtilsVersion, - "net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixVersion % Provided, - "org.scalatest" %% "scalatest" % "3.2.19" % Test, - ), - excludeDependencies ++= Seq( - ExclusionRule("org.scala-lang.modules", "scala-xml_2.13"), - ExclusionRule("org.scala-lang.modules", "scala-collection-compat_2.13") - ), -) - lazy val lmCoursierDefinitions = project .in(file("lm-coursier/definitions")) .disablePlugins(MimaPlugin) @@ -1478,6 +1464,20 @@ lazy val lmCoursierDefinitions = project ) .dependsOn(lmIvy % "provided") +lazy val lmCoursierDependencies = Def.settings( + libraryDependencies ++= Seq( + coursier, + coursierSbtMavenRepo, + "io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier" % jniUtilsVersion, + "net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixVersion % Provided, + "org.scalatest" %% "scalatest" % "3.2.19" % Test, + ), + excludeDependencies ++= Seq( + ExclusionRule("org.scala-lang.modules", "scala-xml_2.13"), + ExclusionRule("org.scala-lang.modules", "scala-collection-compat_2.13") + ), +) + lazy val lmCoursier = project .in(file("lm-coursier")) .settings( @@ -1503,23 +1503,13 @@ lazy val lmCoursierShaded = project Mima.lmCoursierShadedFilters, Compile / sources := (lmCoursier / Compile / sources).value, lmCoursierDependencies, + autoScalaLibrary := false, + libraryDependencies ++= Seq( + scala3Library % Provided, + ), + assembly / assemblyOption ~= { _.withIncludeScala(false) }, conflictWarning := ConflictWarning.disable, Utils.noPublish, - // shadedModules ++= Set( - // "io.get-coursier" %% "coursier", - // "io.get-coursier" %% "coursier-sbt-maven-repository", - // "io.get-coursier.jniutils" % "windows-jni-utils-lmcoursier" - // ), - // validNamespaces += "lmcoursier", - // validEntries ++= Set( - // // FIXME Ideally, we should just strip those from the resulting JAR… - // "README", // from google-collections via plexus-archiver (see below) - // // from plexus-util via plexus-archiver (see below) - // "licenses/extreme.indiana.edu.license.TXT", - // "licenses/javolution.license.TXT", - // "licenses/thoughtworks.TXT", - // "licenses/", - // ), assemblyShadeRules := { val namespacesToShade = Seq( "coursier", diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 364ce24c3..054794d69 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -98,6 +98,7 @@ object Dependencies { "com.eed3si9n.remoteapis.shaded" % "shaded-remoteapis-java" % "2.3.0-M1-52317e00d8d4c37fa778c628485d220fb68a8d08" val scalaCompiler = "org.scala-lang" %% "scala3-compiler" % scala3 + val scala3Library = "org.scala-lang" %% "scala3-library" % scala3 val scalaXml = Def.setting( if (scalaBinaryVersion.value == "3") {