mirror of https://github.com/sbt/sbt.git
Keep global exclusions as such in generated ivy.xml
This commit is contained in:
parent
3d374247ca
commit
6cebc8fe7a
|
|
@ -123,12 +123,12 @@ object Inputs {
|
|||
sets.values.toVector.distinct.map(_.set.toSet)
|
||||
}
|
||||
|
||||
def exclusions(
|
||||
def exclusionsSeq(
|
||||
excludeDeps: Seq[InclExclRule],
|
||||
sv: String,
|
||||
sbv: String,
|
||||
log: Logger
|
||||
): Set[(Organization, ModuleName)] = {
|
||||
): Seq[(Organization, ModuleName)] = {
|
||||
|
||||
var anyNonSupportedExclusionRule = false
|
||||
|
||||
|
|
@ -144,7 +144,6 @@ object Inputs {
|
|||
Seq((Organization(rule.organization), ModuleName(name)))
|
||||
}
|
||||
}
|
||||
.toSet
|
||||
|
||||
if (anyNonSupportedExclusionRule)
|
||||
log.warn("Only supported exclusion rule fields: organization, name")
|
||||
|
|
@ -152,6 +151,14 @@ object Inputs {
|
|||
res
|
||||
}
|
||||
|
||||
def exclusions(
|
||||
excludeDeps: Seq[InclExclRule],
|
||||
sv: String,
|
||||
sbv: String,
|
||||
log: Logger
|
||||
): Set[(Organization, ModuleName)] =
|
||||
exclusionsSeq(excludeDeps, sv, sbv, log).toSet
|
||||
|
||||
def forceVersions(depOverrides: Seq[ModuleID], sv: String, sbv: String): Seq[(Module, String)] =
|
||||
depOverrides.map(FromSbt.moduleVersion(_, sv, sbv))
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,12 @@ package coursier.sbtcoursiershared
|
|||
import java.nio.charset.StandardCharsets.UTF_8
|
||||
import java.nio.file.Files
|
||||
|
||||
import lmcoursier.Inputs
|
||||
import lmcoursier.definitions.{Configuration, Project}
|
||||
import org.apache.ivy.core.module.id.ModuleRevisionId
|
||||
import sbt.{Def, Setting, Task, TaskKey}
|
||||
import sbt.internal.librarymanagement.IvySbt
|
||||
import sbt.librarymanagement.PublishConfiguration
|
||||
import sbt.librarymanagement.{CrossVersion, PublishConfiguration}
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.xml.{Node, PrefixedAttribute}
|
||||
|
|
@ -16,6 +17,7 @@ object IvyXml {
|
|||
|
||||
private[sbtcoursiershared] def rawContent(
|
||||
currentProject: Project,
|
||||
exclusions: Seq[(String, String)],
|
||||
shadedConfigOpt: Option[Configuration]
|
||||
): String = {
|
||||
|
||||
|
|
@ -28,12 +30,13 @@ object IvyXml {
|
|||
val printer = new scala.xml.PrettyPrinter(Int.MaxValue, 2)
|
||||
|
||||
"""<?xml version="1.0" encoding="UTF-8"?>""" + '\n' +
|
||||
printer.format(content(currentProject, shadedConfigOpt))
|
||||
printer.format(content(currentProject, exclusions, shadedConfigOpt))
|
||||
}
|
||||
|
||||
// These are required for publish to be fine, later on.
|
||||
private def writeFiles(
|
||||
currentProject: Project,
|
||||
exclusions: Seq[(String, String)],
|
||||
shadedConfigOpt: Option[Configuration],
|
||||
ivySbt: IvySbt,
|
||||
log: sbt.util.Logger
|
||||
|
|
@ -53,7 +56,7 @@ object IvyXml {
|
|||
val cacheIvyFile = ivyCacheManager.getResolvedIvyFileInCache(ivyModule)
|
||||
val cacheIvyPropertiesFile = ivyCacheManager.getResolvedIvyPropertiesInCache(ivyModule)
|
||||
|
||||
val content0 = rawContent(currentProject, shadedConfigOpt)
|
||||
val content0 = rawContent(currentProject, exclusions, shadedConfigOpt)
|
||||
cacheIvyFile.getParentFile.mkdirs()
|
||||
log.info(s"Writing Ivy file $cacheIvyFile")
|
||||
Files.write(cacheIvyFile.toPath, content0.getBytes(UTF_8))
|
||||
|
|
@ -63,7 +66,11 @@ object IvyXml {
|
|||
Files.write(cacheIvyPropertiesFile.toPath, Array.emptyByteArray)
|
||||
}
|
||||
|
||||
private def content(project0: Project, shadedConfigOpt: Option[Configuration]): Node = {
|
||||
private def content(
|
||||
project0: Project,
|
||||
exclusions: Seq[(String, String)],
|
||||
shadedConfigOpt: Option[Configuration]
|
||||
): Node = {
|
||||
|
||||
val filterOutDependencies =
|
||||
shadedConfigOpt.toSet[Configuration].flatMap { shadedConfig =>
|
||||
|
|
@ -148,11 +155,16 @@ object IvyXml {
|
|||
n % moduleAttrs
|
||||
}
|
||||
|
||||
val excludeElems = exclusions.toVector.map {
|
||||
case (org, name) =>
|
||||
<exclude org={org} module={name} artifact="*" type="*" ext="*" matcher="exact"/>
|
||||
}
|
||||
|
||||
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
|
||||
{infoElem}
|
||||
<configurations>{confElems}</configurations>
|
||||
<publications>{publicationElems}</publications>
|
||||
<dependencies>{dependencyElems}</dependencies>
|
||||
<dependencies>{dependencyElems}{excludeElems}</dependencies>
|
||||
</ivy-module>
|
||||
}
|
||||
|
||||
|
|
@ -166,12 +178,20 @@ object IvyXml {
|
|||
val doGen = coursierGenerateIvyXml.value
|
||||
if (doGen)
|
||||
Def.task {
|
||||
val sv = sbt.Keys.scalaVersion.value
|
||||
val sbv = sbt.Keys.scalaBinaryVersion.value
|
||||
val log = sbt.Keys.streams.value.log
|
||||
val currentProject = {
|
||||
val proj = coursierProject.value
|
||||
val publications = coursierPublications.value
|
||||
proj.withPublications(publications)
|
||||
}
|
||||
writeFiles(currentProject, shadedConfigOpt, sbt.Keys.ivySbt.value, sbt.Keys.streams.value.log)
|
||||
val excludeDeps = Inputs.exclusionsSeq(InputsTasks.actualExcludeDependencies.value, sv, sbv, log)
|
||||
.map {
|
||||
case (org, name) =>
|
||||
(org.value, name.value)
|
||||
}
|
||||
writeFiles(currentProject, excludeDeps, shadedConfigOpt, sbt.Keys.ivySbt.value, log)
|
||||
}
|
||||
else
|
||||
Def.task(())
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ object IvyXmlTests extends TestSuite {
|
|||
Info("", "", Nil, Nil, None)
|
||||
)
|
||||
|
||||
val content = IvyXml.rawContent(project, None)
|
||||
val content = IvyXml.rawContent(project, Nil, None)
|
||||
|
||||
assert(!content.contains("</conf>"))
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -3,5 +3,4 @@
|
|||
$ exec java -jar coursier launch io.get-coursier.test:sbt-coursier-exclude-dependencies_2.12:0.1.0-SNAPSHOT
|
||||
> b/run
|
||||
> b/publishLocal
|
||||
# doesn't pass yet (missing exclusions of root deps in ivy.xml?)
|
||||
# $ exec java -jar coursier launch io.get-coursier.test:sbt-coursier-exclude-dependencies-2_2.12:0.1.0-SNAPSHOT
|
||||
$ exec java -jar coursier launch io.get-coursier.test:sbt-coursier-exclude-dependencies-2_2.12:0.1.0-SNAPSHOT
|
||||
|
|
|
|||
Loading…
Reference in New Issue