Skip to content

Commit

Permalink
adressing github comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sa1to committed Apr 3, 2024
1 parent 6d63dd5 commit e59fa0e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package sbt.jetbrains

import org.jetbrains.sbt.extractors._
import sbt._
import org.jetbrains.sbt.SbtStateOps
import org.jetbrains.sbt.{CreateTasks, SbtStateOps}
import sbt.jetbrains.apiAdapter._

object LogDownloadArtifacts extends (State => State) with SbtStateOps {
Expand All @@ -14,23 +14,5 @@ object LogDownloadArtifacts 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 = {
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, projectSettings)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package sbt.jetbrains

import org.jetbrains.sbt.extractors._
import sbt._
import org.jetbrains.sbt.SbtStateOps
import org.jetbrains.sbt.{CreateTasks, SbtStateOps}
import sbt.jetbrains.apiAdapter._
import sbt.jetbrains.keysAdapterEx

Expand All @@ -15,23 +15,5 @@ object LogDownloadArtifacts 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 = {
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, projectSettings)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package sbt.jetbrains

import org.jetbrains.sbt.SbtStateOps
import sbt._
import org.jetbrains.sbt.{CreateTasks, SbtStateOps}
import sbt.Keys.csrLogger
import sbt.jetbrains.apiAdapter._

object LogDownloadArtifacts extends (State => State) with SbtStateOps {

Expand All @@ -15,23 +13,5 @@ object LogDownloadArtifacts 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 = {
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, projectSettings)
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
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.KeyRanks.DTask
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
Expand All @@ -12,7 +13,9 @@ object keysAdapterEx {
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))

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e59fa0e

Please sign in to comment.