From 49d6c87b4610930b54642a454bc5159490ab215f Mon Sep 17 00:00:00 2001 From: spawlak Date: Fri, 29 Mar 2024 14:53:32 +0100 Subject: [PATCH 1/3] Fixing artifacts downloading logging #SCL-22163 --- .DS_Store | Bin 0 -> 8196 bytes .../sbt/jetbrains/LogDownloadArtifacts.scala | 36 +++++++++++++++++ .../sbt/jetbrains/keysAdapterEx.scala | 4 +- .../org.jetbrains/LogDownloadArtifacts.scala | 37 ++++++++++++++++++ .../org.jetbrains/keysAdapterEx.scala | 4 +- .../sbt/jetbrains/LogDownloadArtifacts.scala | 37 ++++++++++++++++++ .../sbt/jetbrains/keysAdapterEx.scala | 25 +++++++++++- .../org/jetbrains/sbt/StructurePlugin.scala | 9 +++-- 8 files changed, 146 insertions(+), 6 deletions(-) create mode 100644 .DS_Store create mode 100644 extractor/src/main/scala-sbt-0.13/sbt/jetbrains/LogDownloadArtifacts.scala create mode 100644 extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala create mode 100644 extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a501817c0196d17d98ed28432a630b8213588ad1 GIT binary patch literal 8196 zcmeHMTWl3Y7@lui=X`RDs*I;V^=v=wsqGFHPFhul>G08}#A~_~y2&FOQ>j4oI(Gvp_PWGhePBInAF)1aSLBbiLFC%)PApAPv zl3{m-l$3E9dm#3}WDkh&QJKY#(z`u>{rlY?$v9qytmiT#j_n7HjbB44E1x#Kf>-bv ze1Ff7H`)`JLBVe`^Ls_B*YliAscvTaY-=>FSG9X?VA`&g4*_=0qAvUTZ8ztQws{3N z=ZDxHY2YeX(|YyshzAddw)n*ud{R3KBpIfBKcaH?N=lXqC-Y1#X=lHb9?OD&= znYV(rx4eW!ql~>hDq$QBKkg<;x?BJOEhLK#N za{a@7IhxlFFDFLKg%-m|F6Df$(6{F;Dy3R8>Q)fI?Dc7B(KJ`BR#n~aJxtpyp<2^g zuIjnnj+wEXNY&gzs?PqR^lzkmU=yd=Hw)j4h1 z%DH}F&>u4MR`)3JEJAGQW&JMi1bV$CQ6PD!QSzv3(RnBkUM^mc7nSv-j9J_A$G_ zzGRo!ckFxi1N(*j&Mvb*QI2V-07oSj;tnjrV$@?T)?q!`(1|YWKsS1^9|w?ziG%Pk zf+O&83{T)BPT?s$hnMjRUd3y82WRj;KENlqfY0zbzQ8y55kKK)T*hDc8&?!nnX4>S z?opO2b;=5*NoiJE<hT^yPnA*dB;&cByYIi6M085Wh~SdC3X|Lt)tgsNyb(w()0?! zV=f41+^H=|=+lV*vU#_*ETK;)?#pIfqCTN36mqh;D$%IvWfV|qh;2&LYdW}W+^4l@ zdO3xbY;M#xX*v_pF59hQB;xD8C+t~vo_$J$y-0-pmHo#4U{{Ewvr$6?U54eTLjzV4 zNt@Av4cLedY{fP_M3n7CANsKegUG@n!VbYk9svp{;xRl State) with SbtStateOps { + + lazy val globalSettings: Seq[Setting[_]] = Seq[Setting[_]]( + ) + + lazy val projectSettings: Seq[Setting[_]] = Seq[Setting[_]]( + ) + + def apply(state: State): State = + applySettings(state, globalSettings, projectSettings) + + private def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { + val extracted = Project.extract(state) + import extracted.{structure => extractedStructure, _} + val transformedGlobalSettings = Project.transform(_ => GlobalScope, globalSettings) + val transformedProjectSettings = extractedStructure.allProjectRefs.flatMap { projectRef => + transformSettings(projectScope(projectRef), projectRef.build, rootProject, projectSettings) + } + reapply(extracted.session.appendRaw(transformedGlobalSettings ++ transformedProjectSettings), state) + } + + // copied from sbt.internal.Load + private def transformSettings(thisScope: Scope, uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] = + Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings) + + // copied from sbt.internal.SessionSettings + private def reapply(session: SessionSettings, s: State): State = + BuiltinCommands.reapply(session, Project.structure(s), s) +} diff --git a/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/keysAdapterEx.scala b/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/keysAdapterEx.scala index 4e63ef45..dec23359 100644 --- a/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/keysAdapterEx.scala +++ b/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/keysAdapterEx.scala @@ -1,6 +1,6 @@ package sbt.jetbrains -import sbt.{Def, File, Task, TaskKey} +import sbt.{Def, File, Task, Setting, TaskKey} object keysAdapterEx { val myScalaCompilerBridgeBinaryJar: Def.Initialize[Task[Option[File]]] = Def.taskDyn { @@ -8,4 +8,6 @@ object keysAdapterEx { None } } + + val artifactDownload: Seq[Setting[_]] = Seq.empty } diff --git a/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala b/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala new file mode 100644 index 00000000..52477b63 --- /dev/null +++ b/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala @@ -0,0 +1,37 @@ +package sbt.jetbrains + +import org.jetbrains.sbt.extractors._ +import sbt._ +import org.jetbrains.sbt.SbtStateOps +import sbt.jetbrains.apiAdapter._ +import sbt.jetbrains.keysAdapterEx + +object LogDownloadArtifacts extends (State => State) with SbtStateOps { + + lazy val globalSettings: Seq[Setting[_]] = Seq[Setting[_]]( + ) + + lazy val projectSettings: Seq[Setting[_]] = Seq[Setting[_]]( + ) + + def apply(state: State): State = + applySettings(state, globalSettings, projectSettings) + + private def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { + val extracted = Project.extract(state) + import extracted.{structure => extractedStructure, _} + val transformedGlobalSettings = Project.transform(_ => GlobalScope, globalSettings) + val transformedProjectSettings = extractedStructure.allProjectRefs.flatMap { projectRef => + transformSettings(projectScope(projectRef), projectRef.build, rootProject, projectSettings) + } + reapply(extracted.session.appendRaw(transformedGlobalSettings ++ transformedProjectSettings), state) + } + + // copied from sbt.internal.Load + private def transformSettings(thisScope: Scope, uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] = + Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings) + + // copied from sbt.internal.SessionSettings + private def reapply(session: SessionSettings, s: State): State = + BuiltinCommands.reapply(session, Project.structure(s), s) +} diff --git a/extractor/src/main/scala-sbt-1.2/org.jetbrains/keysAdapterEx.scala b/extractor/src/main/scala-sbt-1.2/org.jetbrains/keysAdapterEx.scala index 4e63ef45..dec23359 100644 --- a/extractor/src/main/scala-sbt-1.2/org.jetbrains/keysAdapterEx.scala +++ b/extractor/src/main/scala-sbt-1.2/org.jetbrains/keysAdapterEx.scala @@ -1,6 +1,6 @@ package sbt.jetbrains -import sbt.{Def, File, Task, TaskKey} +import sbt.{Def, File, Task, Setting, TaskKey} object keysAdapterEx { val myScalaCompilerBridgeBinaryJar: Def.Initialize[Task[Option[File]]] = Def.taskDyn { @@ -8,4 +8,6 @@ object keysAdapterEx { None } } + + val artifactDownload: Seq[Setting[_]] = Seq.empty } diff --git a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala new file mode 100644 index 00000000..b2208a02 --- /dev/null +++ b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala @@ -0,0 +1,37 @@ +package sbt.jetbrains + +import org.jetbrains.sbt.SbtStateOps +import sbt._ +import sbt.Keys.csrLogger +import sbt.jetbrains.apiAdapter._ + +object LogDownloadArtifacts extends (State => State) with SbtStateOps { + + lazy val globalSettings: Seq[Setting[_]] = Seq[Setting[_]]( + csrLogger := keysAdapterEx.artifactDownloadCsrLogger.value + ) + + lazy val projectSettings: Seq[Setting[_]] = Seq[Setting[_]]( + ) + + def apply(state: State): State = + applySettings(state, globalSettings, projectSettings) + + private def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { + val extracted = Project.extract(state) + import extracted.{structure => extractedStructure, _} + val transformedGlobalSettings = Project.transform(_ => GlobalScope, globalSettings) + val transformedProjectSettings = extractedStructure.allProjectRefs.flatMap { projectRef => + transformSettings(projectScope(projectRef), projectRef.build, rootProject, projectSettings) + } + reapply(extracted.session.appendRaw(transformedGlobalSettings ++ transformedProjectSettings), state) + } + + // copied from sbt.internal.Load + private def transformSettings(thisScope: Scope, uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] = + Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings) + + // copied from sbt.internal.SessionSettings + private def reapply(session: SessionSettings, s: State): State = + BuiltinCommands.reapply(session, Project.structure(s), s) +} diff --git a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala index 34862083..5ac17432 100644 --- a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala +++ b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala @@ -1,10 +1,33 @@ package sbt.jetbrains -import sbt.{Def, File, Task, TaskKey} +import lmcoursier.definitions.CacheLogger +import sbt.KeyRanks.{DTask, Invisible} +import sbt.{Def, File, Global, GlobalScope, Keys, Logger, Setting, Task, TaskKey} object keysAdapterEx { //NOTE: sbt.Keys.scalaCompilerBridgeBinaryJar exists since SBT 1.2.3, so we detect it only since 1.3.0 val myScalaCompilerBridgeBinaryJar: Def.Initialize[Task[Option[File]]] = Def.taskDyn { sbt.Keys.scalaCompilerBridgeBinaryJar } + val artifactDownloadTask: TaskKey[Option[CacheLogger]] = TaskKey("artifactDownloadTask", rank = DTask) + lazy val artifactDownloadCsrLogger: Def.Initialize[Task[Option[CacheLogger]]] = Def.task { + val st = Keys.streams.value + Some(new CoursierLogger(st.log)) + + } + + val artifactDownload: Seq[Setting[_]] = Seq( + artifactDownloadTask := keysAdapterEx.artifactDownloadCsrLogger.value, + Keys.csrLogger := keysAdapterEx.artifactDownloadCsrLogger.value + ) + + class CoursierLogger(logger: Logger) extends CacheLogger { + override def downloadedArtifact(url: String, success: Boolean): Unit = { + logger.info(s"downloaded $url") + } + + override def downloadingArtifact(url: String): Unit = { + logger.info(s"downloading $url") + } + } } diff --git a/extractor/src/main/scala/org/jetbrains/sbt/StructurePlugin.scala b/extractor/src/main/scala/org/jetbrains/sbt/StructurePlugin.scala index 70524c35..2d161eca 100644 --- a/extractor/src/main/scala/org/jetbrains/sbt/StructurePlugin.scala +++ b/extractor/src/main/scala/org/jetbrains/sbt/StructurePlugin.scala @@ -5,6 +5,7 @@ import org.jetbrains.sbt.structure.XmlSerializer._ import sbt._ import sbt.complete.DefaultParsers import sbt.plugins.JvmPlugin +import sbt.jetbrains.keysAdapterEx import scala.xml.PrettyPrinter @@ -16,13 +17,15 @@ object StructurePlugin extends AutoPlugin { override def requires: Plugins = JvmPlugin override def trigger: PluginTrigger = allRequirements + override def buildSettings: Seq[Def.Setting[_]] = super.buildSettings ++ keysAdapterEx.artifactDownload + override lazy val globalSettings: Seq[Setting[_]] = Seq( StructureKeys.sbtStructureOutputFile := None, StructureKeys.sbtStructureOptions := "prettyPrint download", StructureKeys.dumpStructureTo := pluginOnlyTasks.dumpStructureTo.evaluated - ) ++ CreateTasks.globalSettings + ) ++ keysAdapterEx.artifactDownload ++ CreateTasks.globalSettings - override lazy val projectSettings: Seq[Setting[_]] = CreateTasks.projectSettings + override lazy val projectSettings: Seq[Setting[_]] = CreateTasks.projectSettings ++ keysAdapterEx.artifactDownload } @@ -54,4 +57,4 @@ private object pluginOnlyTasks { outputFile } } -} \ No newline at end of file +} From 360dc096bf966c0ae39368c065ed2d5a31a8e592 Mon Sep 17 00:00:00 2001 From: spawlak Date: Wed, 3 Apr 2024 13:41:32 +0200 Subject: [PATCH 2/3] adressing github comments #SCL-22163 --- .../sbt/jetbrains/LogDownloadArtifacts.scala | 30 ++---------------- .../org.jetbrains/LogDownloadArtifacts.scala | 31 ++----------------- .../sbt/jetbrains/LogDownloadArtifacts.scala | 28 ++--------------- .../sbt/jetbrains/keysAdapterEx.scala | 10 +++--- .../scala/org/jetbrains/sbt/CreateTasks.scala | 2 +- .../org/jetbrains/sbt/StructurePlugin.scala | 4 +-- 6 files changed, 14 insertions(+), 91 deletions(-) diff --git a/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/LogDownloadArtifacts.scala b/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/LogDownloadArtifacts.scala index fe1c046d..fa1cdc4e 100644 --- a/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/LogDownloadArtifacts.scala +++ b/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/LogDownloadArtifacts.scala @@ -1,36 +1,10 @@ package sbt.jetbrains -import org.jetbrains.sbt.extractors._ import sbt._ -import org.jetbrains.sbt.SbtStateOps -import sbt.jetbrains.apiAdapter._ +import org.jetbrains.sbt.{CreateTasks, SbtStateOps} object LogDownloadArtifacts extends (State => State) with SbtStateOps { - lazy val globalSettings: Seq[Setting[_]] = Seq[Setting[_]]( - ) - - lazy val projectSettings: Seq[Setting[_]] = Seq[Setting[_]]( - ) - def apply(state: State): State = - applySettings(state, globalSettings, projectSettings) - - private def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { - val extracted = Project.extract(state) - import extracted.{structure => extractedStructure, _} - val transformedGlobalSettings = Project.transform(_ => GlobalScope, globalSettings) - val transformedProjectSettings = extractedStructure.allProjectRefs.flatMap { projectRef => - transformSettings(projectScope(projectRef), projectRef.build, rootProject, projectSettings) - } - reapply(extracted.session.appendRaw(transformedGlobalSettings ++ transformedProjectSettings), state) - } - - // copied from sbt.internal.Load - private def transformSettings(thisScope: Scope, uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] = - Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings) - - // copied from sbt.internal.SessionSettings - private def reapply(session: SessionSettings, s: State): State = - BuiltinCommands.reapply(session, Project.structure(s), s) + CreateTasks.applySettings(state, Seq[Setting[_]](), Seq[Setting[_]]()) } diff --git a/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala b/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala index 52477b63..fa1cdc4e 100644 --- a/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala +++ b/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala @@ -1,37 +1,10 @@ package sbt.jetbrains -import org.jetbrains.sbt.extractors._ import sbt._ -import org.jetbrains.sbt.SbtStateOps -import sbt.jetbrains.apiAdapter._ -import sbt.jetbrains.keysAdapterEx +import org.jetbrains.sbt.{CreateTasks, SbtStateOps} object LogDownloadArtifacts extends (State => State) with SbtStateOps { - lazy val globalSettings: Seq[Setting[_]] = Seq[Setting[_]]( - ) - - lazy val projectSettings: Seq[Setting[_]] = Seq[Setting[_]]( - ) - def apply(state: State): State = - applySettings(state, globalSettings, projectSettings) - - private def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { - val extracted = Project.extract(state) - import extracted.{structure => extractedStructure, _} - val transformedGlobalSettings = Project.transform(_ => GlobalScope, globalSettings) - val transformedProjectSettings = extractedStructure.allProjectRefs.flatMap { projectRef => - transformSettings(projectScope(projectRef), projectRef.build, rootProject, projectSettings) - } - reapply(extracted.session.appendRaw(transformedGlobalSettings ++ transformedProjectSettings), state) - } - - // copied from sbt.internal.Load - private def transformSettings(thisScope: Scope, uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] = - Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings) - - // copied from sbt.internal.SessionSettings - private def reapply(session: SessionSettings, s: State): State = - BuiltinCommands.reapply(session, Project.structure(s), s) + CreateTasks.applySettings(state, Seq[Setting[_]](), Seq[Setting[_]]()) } diff --git a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala index b2208a02..a820169d 100644 --- a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala +++ b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala @@ -1,9 +1,8 @@ package sbt.jetbrains -import org.jetbrains.sbt.SbtStateOps -import sbt._ +import org.jetbrains.sbt.{CreateTasks, SbtStateOps} import sbt.Keys.csrLogger -import sbt.jetbrains.apiAdapter._ +import sbt._ object LogDownloadArtifacts extends (State => State) with SbtStateOps { @@ -11,27 +10,6 @@ object LogDownloadArtifacts extends (State => State) with SbtStateOps { csrLogger := keysAdapterEx.artifactDownloadCsrLogger.value ) - lazy val projectSettings: Seq[Setting[_]] = Seq[Setting[_]]( - ) - def apply(state: State): State = - applySettings(state, globalSettings, projectSettings) - - private def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { - val extracted = Project.extract(state) - import extracted.{structure => extractedStructure, _} - val transformedGlobalSettings = Project.transform(_ => GlobalScope, globalSettings) - val transformedProjectSettings = extractedStructure.allProjectRefs.flatMap { projectRef => - transformSettings(projectScope(projectRef), projectRef.build, rootProject, projectSettings) - } - reapply(extracted.session.appendRaw(transformedGlobalSettings ++ transformedProjectSettings), state) - } - - // copied from sbt.internal.Load - private def transformSettings(thisScope: Scope, uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] = - Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings) - - // copied from sbt.internal.SessionSettings - private def reapply(session: SessionSettings, s: State): State = - BuiltinCommands.reapply(session, Project.structure(s), s) + CreateTasks.applySettings(state, globalSettings, Seq[Setting[_]]()) } diff --git a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala index 5ac17432..beb60b77 100644 --- a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala +++ b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala @@ -1,23 +1,23 @@ package sbt.jetbrains import lmcoursier.definitions.CacheLogger -import sbt.KeyRanks.{DTask, Invisible} -import sbt.{Def, File, Global, GlobalScope, Keys, Logger, Setting, Task, TaskKey} +import sbt.Keys.useSuperShell +import sbt.{Def, File, Keys, Logger, Setting, Task, TaskKey, ThisBuild} object keysAdapterEx { //NOTE: sbt.Keys.scalaCompilerBridgeBinaryJar exists since SBT 1.2.3, so we detect it only since 1.3.0 val myScalaCompilerBridgeBinaryJar: Def.Initialize[Task[Option[File]]] = Def.taskDyn { sbt.Keys.scalaCompilerBridgeBinaryJar } - val artifactDownloadTask: TaskKey[Option[CacheLogger]] = TaskKey("artifactDownloadTask", rank = DTask) lazy val artifactDownloadCsrLogger: Def.Initialize[Task[Option[CacheLogger]]] = Def.task { val st = Keys.streams.value - Some(new CoursierLogger(st.log)) + val progress = (ThisBuild / useSuperShell).value + if (progress) None + else Some(new CoursierLogger(st.log)) } val artifactDownload: Seq[Setting[_]] = Seq( - artifactDownloadTask := keysAdapterEx.artifactDownloadCsrLogger.value, Keys.csrLogger := keysAdapterEx.artifactDownloadCsrLogger.value ) diff --git a/extractor/src/main/scala/org/jetbrains/sbt/CreateTasks.scala b/extractor/src/main/scala/org/jetbrains/sbt/CreateTasks.scala index ad339de1..b40ddcd8 100644 --- a/extractor/src/main/scala/org/jetbrains/sbt/CreateTasks.scala +++ b/extractor/src/main/scala/org/jetbrains/sbt/CreateTasks.scala @@ -46,7 +46,7 @@ object CreateTasks extends (State => State) with SbtStateOps { def apply(state: State): State = applySettings(state, globalSettings, projectSettings) - private def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { + def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { val extracted = Project.extract(state) import extracted.{structure => extractedStructure, _} val transformedGlobalSettings = Project.transform(_ => GlobalScope, globalSettings) diff --git a/extractor/src/main/scala/org/jetbrains/sbt/StructurePlugin.scala b/extractor/src/main/scala/org/jetbrains/sbt/StructurePlugin.scala index 2d161eca..b48d7612 100644 --- a/extractor/src/main/scala/org/jetbrains/sbt/StructurePlugin.scala +++ b/extractor/src/main/scala/org/jetbrains/sbt/StructurePlugin.scala @@ -17,15 +17,13 @@ object StructurePlugin extends AutoPlugin { override def requires: Plugins = JvmPlugin override def trigger: PluginTrigger = allRequirements - override def buildSettings: Seq[Def.Setting[_]] = super.buildSettings ++ keysAdapterEx.artifactDownload - override lazy val globalSettings: Seq[Setting[_]] = Seq( StructureKeys.sbtStructureOutputFile := None, StructureKeys.sbtStructureOptions := "prettyPrint download", StructureKeys.dumpStructureTo := pluginOnlyTasks.dumpStructureTo.evaluated ) ++ keysAdapterEx.artifactDownload ++ CreateTasks.globalSettings - override lazy val projectSettings: Seq[Setting[_]] = CreateTasks.projectSettings ++ keysAdapterEx.artifactDownload + override lazy val projectSettings: Seq[Setting[_]] = CreateTasks.projectSettings } From 0f3055ce6f753612897f8cee807d5f295a8a36be Mon Sep 17 00:00:00 2001 From: spawlak Date: Fri, 12 Apr 2024 11:41:58 +0200 Subject: [PATCH 3/3] Moving applySettings method to SbtStateOps trait #SCL-22163 --- .DS_Store | Bin 8196 -> 0 bytes .../sbt/jetbrains/LogDownloadArtifacts.scala | 4 ++-- .../sbt/jetbrains/keysAdapterEx.scala | 2 +- .../org.jetbrains/LogDownloadArtifacts.scala | 4 ++-- .../org.jetbrains/keysAdapterEx.scala | 2 +- .../sbt/jetbrains/LogDownloadArtifacts.scala | 4 ++-- .../sbt/jetbrains/keysAdapterEx.scala | 2 +- .../scala/org/jetbrains/sbt/CreateTasks.scala | 17 ---------------- .../scala/org/jetbrains/sbt/operations.scala | 19 ++++++++++++++++++ 9 files changed, 28 insertions(+), 26 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index a501817c0196d17d98ed28432a630b8213588ad1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMTWl3Y7@lui=X`RDs*I;V^=v=wsqGFHPFhul>G08}#A~_~y2&FOQ>j4oI(Gvp_PWGhePBInAF)1aSLBbiLFC%)PApAPv zl3{m-l$3E9dm#3}WDkh&QJKY#(z`u>{rlY?$v9qytmiT#j_n7HjbB44E1x#Kf>-bv ze1Ff7H`)`JLBVe`^Ls_B*YliAscvTaY-=>FSG9X?VA`&g4*_=0qAvUTZ8ztQws{3N z=ZDxHY2YeX(|YyshzAddw)n*ud{R3KBpIfBKcaH?N=lXqC-Y1#X=lHb9?OD&= znYV(rx4eW!ql~>hDq$QBKkg<;x?BJOEhLK#N za{a@7IhxlFFDFLKg%-m|F6Df$(6{F;Dy3R8>Q)fI?Dc7B(KJ`BR#n~aJxtpyp<2^g zuIjnnj+wEXNY&gzs?PqR^lzkmU=yd=Hw)j4h1 z%DH}F&>u4MR`)3JEJAGQW&JMi1bV$CQ6PD!QSzv3(RnBkUM^mc7nSv-j9J_A$G_ zzGRo!ckFxi1N(*j&Mvb*QI2V-07oSj;tnjrV$@?T)?q!`(1|YWKsS1^9|w?ziG%Pk zf+O&83{T)BPT?s$hnMjRUd3y82WRj;KENlqfY0zbzQ8y55kKK)T*hDc8&?!nnX4>S z?opO2b;=5*NoiJE<hT^yPnA*dB;&cByYIi6M085Wh~SdC3X|Lt)tgsNyb(w()0?! zV=f41+^H=|=+lV*vU#_*ETK;)?#pIfqCTN36mqh;D$%IvWfV|qh;2&LYdW}W+^4l@ zdO3xbY;M#xX*v_pF59hQB;xD8C+t~vo_$J$y-0-pmHo#4U{{Ewvr$6?U54eTLjzV4 zNt@Av4cLedY{fP_M3n7CANsKegUG@n!VbYk9svp{;xRl State) with SbtStateOps { def apply(state: State): State = - CreateTasks.applySettings(state, Seq[Setting[_]](), Seq[Setting[_]]()) + applySettings(state, Seq[Setting[_]](), Seq[Setting[_]]()) } diff --git a/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/keysAdapterEx.scala b/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/keysAdapterEx.scala index dec23359..d5e8b302 100644 --- a/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/keysAdapterEx.scala +++ b/extractor/src/main/scala-sbt-0.13/sbt/jetbrains/keysAdapterEx.scala @@ -1,6 +1,6 @@ package sbt.jetbrains -import sbt.{Def, File, Task, Setting, TaskKey} +import sbt.{Def, File, Task, Setting} object keysAdapterEx { val myScalaCompilerBridgeBinaryJar: Def.Initialize[Task[Option[File]]] = Def.taskDyn { diff --git a/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala b/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala index fa1cdc4e..88c50168 100644 --- a/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala +++ b/extractor/src/main/scala-sbt-1.2/org.jetbrains/LogDownloadArtifacts.scala @@ -1,10 +1,10 @@ package sbt.jetbrains import sbt._ -import org.jetbrains.sbt.{CreateTasks, SbtStateOps} +import org.jetbrains.sbt.SbtStateOps object LogDownloadArtifacts extends (State => State) with SbtStateOps { def apply(state: State): State = - CreateTasks.applySettings(state, Seq[Setting[_]](), Seq[Setting[_]]()) + applySettings(state, Seq[Setting[_]](), Seq[Setting[_]]()) } diff --git a/extractor/src/main/scala-sbt-1.2/org.jetbrains/keysAdapterEx.scala b/extractor/src/main/scala-sbt-1.2/org.jetbrains/keysAdapterEx.scala index dec23359..d5e8b302 100644 --- a/extractor/src/main/scala-sbt-1.2/org.jetbrains/keysAdapterEx.scala +++ b/extractor/src/main/scala-sbt-1.2/org.jetbrains/keysAdapterEx.scala @@ -1,6 +1,6 @@ package sbt.jetbrains -import sbt.{Def, File, Task, Setting, TaskKey} +import sbt.{Def, File, Task, Setting} object keysAdapterEx { val myScalaCompilerBridgeBinaryJar: Def.Initialize[Task[Option[File]]] = Def.taskDyn { diff --git a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala index a820169d..18f03529 100644 --- a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala +++ b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/LogDownloadArtifacts.scala @@ -1,6 +1,6 @@ package sbt.jetbrains -import org.jetbrains.sbt.{CreateTasks, SbtStateOps} +import org.jetbrains.sbt.SbtStateOps import sbt.Keys.csrLogger import sbt._ @@ -11,5 +11,5 @@ object LogDownloadArtifacts extends (State => State) with SbtStateOps { ) def apply(state: State): State = - CreateTasks.applySettings(state, globalSettings, Seq[Setting[_]]()) + applySettings(state, globalSettings, Seq[Setting[_]]()) } diff --git a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala index beb60b77..54fa8780 100644 --- a/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala +++ b/extractor/src/main/scala-sbt-1.3/sbt/jetbrains/keysAdapterEx.scala @@ -2,7 +2,7 @@ package sbt.jetbrains import lmcoursier.definitions.CacheLogger import sbt.Keys.useSuperShell -import sbt.{Def, File, Keys, Logger, Setting, Task, TaskKey, ThisBuild} +import sbt.{Def, File, Keys, Logger, Setting, Task, ThisBuild} object keysAdapterEx { //NOTE: sbt.Keys.scalaCompilerBridgeBinaryJar exists since SBT 1.2.3, so we detect it only since 1.3.0 diff --git a/extractor/src/main/scala/org/jetbrains/sbt/CreateTasks.scala b/extractor/src/main/scala/org/jetbrains/sbt/CreateTasks.scala index b40ddcd8..17fd8f68 100644 --- a/extractor/src/main/scala/org/jetbrains/sbt/CreateTasks.scala +++ b/extractor/src/main/scala/org/jetbrains/sbt/CreateTasks.scala @@ -46,21 +46,4 @@ object CreateTasks extends (State => State) with SbtStateOps { def apply(state: State): State = applySettings(state, globalSettings, projectSettings) - def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { - val extracted = Project.extract(state) - import extracted.{structure => extractedStructure, _} - val transformedGlobalSettings = Project.transform(_ => GlobalScope, globalSettings) - val transformedProjectSettings = extractedStructure.allProjectRefs.flatMap { projectRef => - transformSettings(projectScope(projectRef), projectRef.build, rootProject, projectSettings) - } - reapply(extracted.session.appendRaw(transformedGlobalSettings ++ transformedProjectSettings), state) - } - - // copied from sbt.internal.Load - private def transformSettings(thisScope: Scope, uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] = - Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings) - - // copied from sbt.internal.SessionSettings - private def reapply(session: SessionSettings, s: State): State = - BuiltinCommands.reapply(session, Project.structure(s), s) } diff --git a/extractor/src/main/scala/org/jetbrains/sbt/operations.scala b/extractor/src/main/scala/org/jetbrains/sbt/operations.scala index 4cb960ad..0977c6e9 100644 --- a/extractor/src/main/scala/org/jetbrains/sbt/operations.scala +++ b/extractor/src/main/scala/org/jetbrains/sbt/operations.scala @@ -9,6 +9,25 @@ import sbt.jetbrains.apiAdapter._ * @since 4/10/15. */ trait SbtStateOps { + + def applySettings(state: State, globalSettings: Seq[Setting[_]], projectSettings: Seq[Setting[_]]): State = { + val extracted = Project.extract(state) + import extracted.{structure => extractedStructure, _} + val transformedGlobalSettings = Project.transform(_ => GlobalScope, globalSettings) + val transformedProjectSettings = extractedStructure.allProjectRefs.flatMap { projectRef => + transformSettings(projectScope(projectRef), projectRef.build, rootProject, projectSettings) + } + reapply(extracted.session.appendRaw(transformedGlobalSettings ++ transformedProjectSettings), state) + } + + // copied from sbt.internal.Load + private def transformSettings(thisScope: Scope, uri: URI, rootProject: URI => String, settings: Seq[Setting[_]]): Seq[Setting[_]] = + Project.transform(Scope.resolveScope(thisScope, uri, rootProject), settings) + + // copied from sbt.internal.SessionSettings + private def reapply(session: SessionSettings, s: State): State = + BuiltinCommands.reapply(session, Project.structure(s), s) + def structure(state: State): BuildStructure = sbt.Project.structure(state)