Write exclusions and transitiveness in sbt update reports

Makes it unnecessary to add a jboss repository for plugins in some
cases, like when using sbt-assembly
This commit is contained in:
Alexandre Archambault 2017-12-11 01:25:49 +01:00
parent da7fd6585f
commit 97a137b0bb
9 changed files with 90 additions and 0 deletions

View File

@ -23,6 +23,10 @@ object SbtCompatibility {
id.copy(configurations = configurations)
def withExtraAttributes(extraAttributes: Map[String, String]): sbt.ModuleID =
id.copy(extraAttributes = extraAttributes)
def withExclusions(exclusions: Seq[sbt.librarymanagement.InclExclRule]): sbt.ModuleID =
exclusions.foldLeft(id)((id0, rule) => id0.exclude(rule.org, rule.name))
def withIsTransitive(isTransitive: Boolean): sbt.ModuleID =
id.copy(isTransitive = isTransitive)
}
implicit class ArtifactOps(val artifact: sbt.Artifact) extends AnyVal {

View File

@ -33,6 +33,18 @@ object ToSbt {
Some(dependency.configuration)
).withExtraAttributes(
dependency.module.attributes ++ extraProperties
).withExclusions(
dependency
.exclusions
.toVector
.map {
case (org, name) =>
sbt.librarymanagement.InclExclRule()
.withOrganization(org)
.withName(name)
}
).withIsTransitive(
dependency.transitive
)
}

View File

@ -0,0 +1,32 @@
import Compatibility._
lazy val noJbossInterceptorCheck = TaskKey[Unit]("noJbossInterceptorCheck")
noJbossInterceptorCheck := {
val log = streams.value.log
val configReport = updateSbtClassifiers.value
.configuration(Default)
.getOrElse {
throw new Exception(
"compile configuration not found in update report"
)
}
val artifacts = configReport
.modules
.flatMap(_.artifacts)
.map(_._1)
val jbossInterceptorArtifacts = artifacts
.filter { a =>
a.name.contains("jboss-interceptor")
}
for (a <- jbossInterceptorArtifacts)
log.error(s"Found jboss-interceptor artifact $a")
assert(jbossInterceptorArtifacts.isEmpty)
}

View File

@ -0,0 +1,13 @@
{
val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
)
)
addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion)
}
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")

View File

@ -0,0 +1,11 @@
{
val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
)
)
addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion)
}

View File

@ -0,0 +1,8 @@
object Compatibility {
implicit class UpdateReportOps(val rep: sbt.UpdateReport) extends AnyVal {
def configuration(conf: sbt.Configuration) =
rep.configuration(conf.name)
}
}

View File

@ -0,0 +1 @@
> noJbossInterceptorCheck

View File

@ -0,0 +1,8 @@
package sbt.librarymanagement
final case class InclExclRule(org: String = "*", name: String = "*") {
def withOrganization(org: String): InclExclRule =
copy(org = org)
def withName(name: String): InclExclRule =
copy(name = name)
}