[2.x] refactor: Gate Ivy-specific tasks behind useIvy

**Problem**
Several tasks (makePom, makeMavenPomOfSbtPlugin, deliverTask, publisher,
publishOrSkip, depMap, GlobalPlugin dependency mapping) unconditionally
depend on Ivy infrastructure, preventing ivyless operation.

**Solution**
Add useIvy guards to each task:
- makePom and makeMavenPomOfSbtPlugin: error when useIvy=false
- deliverTask: error when useIvy=false
- publisher: error when useIvy=false
- publishOrSkip: error when useIvy=false
- depMap: return empty map when useIvy=false
- GlobalPlugin.extract: skip ivyModule.dependencyMapping when useIvy=false

Generated-by: Claude claude-opus-4-6
This commit is contained in:
eureka928 2026-03-03 01:19:56 +01:00
parent 8746f5b291
commit e7882b9cd0
2 changed files with 11 additions and 4 deletions

View File

@ -3724,6 +3724,7 @@ object Classpaths {
def deliverTask(config: TaskKey[PublishConfiguration]): Initialize[Task[File]] =
Def.task {
Def.unit(update.value)
if !useIvy.value then sys.error("deliver/makeIvyXml requires useIvy := true")
IvyActions.deliver(ivyModule.value, config.value, streams.value.log)
}
@ -3755,6 +3756,10 @@ object Classpaths {
val log = streams.value.log
val ref = thisProjectRef.value
logSkipPublish(log, ref)
} else if (!useIvy.value) {
sys.error(
"publishOrSkip requires useIvy := true. Use publish/publishLocal for ivyless publishing."
)
} else {
val conf = config.value
val log = streams.value.log
@ -4212,10 +4217,10 @@ object Classpaths {
private[sbt] def depMap: Initialize[Task[Map[ModuleRevisionId, ModuleDescriptor]]] =
import sbt.TupleSyntax.*
(buildDependencies.toTaskable, thisProjectRef.toTaskable, settingsData, streams).flatMapN {
(bd, thisProj, data, s) =>
(buildDependencies.toTaskable, thisProjectRef.toTaskable, settingsData, streams)
.flatMapN { (bd, thisProj, data, s) =>
depMap(bd.classpathTransitiveRefs(thisProj), data, s.log)
}
}
private[sbt] def depMap(
projects: Seq[ProjectRef],

View File

@ -79,7 +79,9 @@ object GlobalPlugin {
val taskInit = Def.task {
val intcp = (Runtime / internalDependencyClasspath).value
val prods = (Runtime / exportedProducts).value
val depMap = projectDescriptors.value + ivyModule.value.dependencyMapping(state.log)
val depMap =
if useIvy.value then projectDescriptors.value + ivyModule.value.dependencyMapping(state.log)
else projectDescriptors.value
GlobalPluginData(
projectID.value,