mirror of https://github.com/sbt/sbt.git
Merge pull request #7165 from mdedetrich/make-skip-work-on-publish-local
Make skip work on publishLocal
This commit is contained in:
commit
51da437f22
|
|
@ -2614,6 +2614,7 @@ object Defaults extends BuildCommon {
|
|||
if (turbo.value) ClassLoaderLayeringStrategy.AllLibraryJars
|
||||
else ClassLoaderLayeringStrategy.ScalaLibrary
|
||||
},
|
||||
publishLocal / skip := (publish / skip).value, // So we don't break previous behaviour
|
||||
)
|
||||
// build.sbt is treated a Scala source of metabuild, so to enable deprecation flag on build.sbt we set the option here.
|
||||
lazy val deprecationSettings: Seq[Setting[_]] =
|
||||
|
|
@ -3585,15 +3586,57 @@ object Classpaths {
|
|||
): Initialize[Task[Unit]] =
|
||||
publishTask(config)
|
||||
|
||||
private def logSkipPublish(log: Logger, ref: ProjectRef): Unit =
|
||||
log.debug(s"Skipping publish* for ${ref.project}")
|
||||
|
||||
private def checkAndPublishLocal(
|
||||
currentCon: PublishConfiguration,
|
||||
publishLocalConf: PublishConfiguration,
|
||||
publishSkipLocal: Boolean,
|
||||
module: IvySbt#Module,
|
||||
log: Logger,
|
||||
ref: ProjectRef
|
||||
)(notPublishLocal: () => Unit): Unit = {
|
||||
if (currentCon == publishLocalConf) {
|
||||
if (publishSkipLocal) {
|
||||
logSkipPublish(log, ref)
|
||||
} else {
|
||||
IvyActions.publish(module, currentCon, log)
|
||||
}
|
||||
} else {
|
||||
notPublishLocal()
|
||||
}
|
||||
}
|
||||
|
||||
def publishTask(config: TaskKey[PublishConfiguration]): Initialize[Task[Unit]] =
|
||||
Def.taskIf {
|
||||
if ((publish / skip).value) {
|
||||
val s = streams.value
|
||||
val log = streams.value.log
|
||||
val ref = thisProjectRef.value
|
||||
s.log.debug(s"Skipping publish* for ${ref.project}")
|
||||
checkAndPublishLocal(
|
||||
config.value,
|
||||
publishLocalConfiguration.value,
|
||||
(publishLocal / skip).value,
|
||||
ivyModule.value,
|
||||
log,
|
||||
ref
|
||||
) { () =>
|
||||
logSkipPublish(log, ref)
|
||||
}
|
||||
} else {
|
||||
val s = streams.value
|
||||
IvyActions.publish(ivyModule.value, config.value, s.log)
|
||||
val conf = config.value
|
||||
val log = streams.value.log
|
||||
val module = ivyModule.value
|
||||
checkAndPublishLocal(
|
||||
conf,
|
||||
publishLocalConfiguration.value,
|
||||
(publishLocal / skip).value,
|
||||
module,
|
||||
log,
|
||||
thisProjectRef.value
|
||||
) { () =>
|
||||
IvyActions.publish(module, conf, log)
|
||||
}
|
||||
}
|
||||
} tag (Tags.Publish, Tags.Network)
|
||||
|
||||
|
|
|
|||
|
|
@ -566,7 +566,7 @@ object Keys {
|
|||
val sbtDependency = settingKey[ModuleID]("Provides a definition for declaring the current version of sbt.").withRank(BMinusSetting)
|
||||
val sbtVersion = settingKey[String]("Provides the version of sbt. This setting should not be modified.").withRank(AMinusSetting)
|
||||
val sbtBinaryVersion = settingKey[String]("Defines the binary compatibility version substring.").withRank(BPlusSetting)
|
||||
val skip = taskKey[Boolean]("For tasks that support it (currently only 'compile', 'update', and 'publish'), setting skip to true will force the task to not to do its work. This exact semantics may vary by task.").withRank(BSetting)
|
||||
val skip = taskKey[Boolean]("For tasks that support it (currently only 'compile', 'update', 'publish' and 'publishLocal'), setting skip to true will force the task to not to do its work. This exact semantics may vary by task.").withRank(BSetting)
|
||||
val templateResolverInfos = settingKey[Seq[TemplateResolverInfo]]("Template resolvers used for 'new'.").withRank(BSetting)
|
||||
val interactionService = taskKey[InteractionService]("Service used to ask for user input through the current user interface(s).").withRank(CTask)
|
||||
val insideCI = SettingKey[Boolean]("insideCI", "Determines if the sbt is running in a Continuous Integration environment", AMinusSetting)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
publish / skip := true
|
||||
|
||||
lazy val check = taskKey[Unit]("check")
|
||||
|
||||
lazy val a = project
|
||||
.in(file("a"))
|
||||
.settings(
|
||||
publishLocal / skip := true
|
||||
)
|
||||
|
||||
lazy val b = project
|
||||
.in(file("b"))
|
||||
|
||||
check := {
|
||||
assert((publishLocal / skip).value, "Expected true, got false")
|
||||
assert((a / publishLocal / skip).value, "Expected true, got false")
|
||||
assert(!(a / publish / skip).value, "Expected false, got true")
|
||||
assert(!(b / publish / skip).value, "Expected false, got true")
|
||||
assert(!(b / publishLocal / skip).value, "Expected false, got true")
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
> check
|
||||
Loading…
Reference in New Issue