
mill.scalalib.publish.Ivy.scala Maven / Gradle / Ivy
The newest version!
package mill.scalalib.publish
import mill.api.Loose.Agg
import scala.xml.{Elem, PrettyPrinter}
object Ivy {
val head = "\n"
case class Override(organization: String, name: String, version: String)
/**
* Generates the content of an ivy.xml file
*
* @param artifact Coordinates of the module
* @param dependencies Dependencies of the module
* @param extras Extra artifacts published alongside the module
* @param overrides Version overrides
* @param hasJar Whether the module has a JAR
* @return ivy.xml content
*/
def apply(
artifact: Artifact,
dependencies: Agg[Dependency],
extras: Seq[PublishInfo] = Seq.empty,
overrides: Seq[Override] = Nil,
hasJar: Boolean = true
): String = {
val mainPublishInfo = {
val pomInfo = PublishInfo(null, ivyType = "pom", ext = "pom", ivyConfig = "pom")
if (hasJar)
Seq(
pomInfo,
PublishInfo.jar(null),
PublishInfo.sourcesJar(null),
PublishInfo.docJar(null)
)
else
Seq(pomInfo)
}
def renderArtifact(e: PublishInfo): Elem = {
e.classifier match {
case None =>
case Some(c) =>
}
}
val xml =
{(mainPublishInfo ++ extras).map(renderArtifact)}
{dependencies.map(renderDependency).toSeq}
{overrides.map(renderOverride)}
val pp = new PrettyPrinter(120, 4)
head + pp.format(xml).replaceAll(">", ">")
}
// bin-compat shim
def apply(
artifact: Artifact,
dependencies: Agg[Dependency],
extras: Seq[PublishInfo],
overrides: Seq[Override]
): String =
apply(
artifact,
dependencies,
extras,
overrides,
hasJar = true
)
// bin-compat shim
def apply(
artifact: Artifact,
dependencies: Agg[Dependency],
extras: Seq[PublishInfo]
): String =
apply(
artifact,
dependencies,
extras,
Nil
)
private def renderDependency(dep: Dependency): Elem = {
if (dep.exclusions.isEmpty)
else
{dep.exclusions.map(ex => )}
}
private def renderOverride(override0: Override): Elem =
private def depIvyConf(d: Dependency): String = {
def target(value: String) = d.configuration.getOrElse(value)
if (d.optional) s"optional->${target("runtime")}"
else d.scope match {
case Scope.Compile => s"compile->${target("compile")};runtime->${target("runtime")}"
case Scope.Provided => s"provided->${target("compile")}"
case Scope.Test => s"test->${target("runtime")}"
case Scope.Runtime => s"runtime->${target("runtime")}"
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy