All Downloads are FREE. Search and download functionalities are using the official Maven repository.

er.lm-coursier-shaded_2.12.2.1.5.source-code.IvyXml.scala Maven / Gradle / Ivy

The newest version!
package lmcoursier

import lmcoursier.definitions.{Configuration, Project}

import scala.xml.{Node, PrefixedAttribute}

object IvyXml {

  @deprecated("Use the override accepting 3 arguments", "2.0.0-RC6-6")
  def apply(
    currentProject: Project,
    exclusions: Seq[(String, String)]
  ): String =
    apply(currentProject, exclusions, Nil)

  def apply(
    currentProject: Project,
    exclusions: Seq[(String, String)],
    overrides: Seq[(String, String, String)]
  ): String = {

    // Important: width = Int.MaxValue, so that no tag gets truncated.
    // In particular, that prevents things like  to be split to
    // 
    // 
    // by the pretty-printer.
    // See https://github.com/sbt/sbt/issues/3412.
    val printer = new scala.xml.PrettyPrinter(Int.MaxValue, 2)

    """""" + '\n' +
      printer.format(content(currentProject, exclusions, overrides))
  }

  // These are required for publish to be fine, later on.
  private def content(
    project: Project,
    exclusions: Seq[(String, String)],
    overrides: Seq[(String, String, String)]
  ): Node = {

    val props = project.module.attributes.toSeq ++ project.properties
    val infoAttrs = props.foldLeft[xml.MetaData](xml.Null) {
      case (acc, (k, v)) =>
        new PrefixedAttribute("e", k, v, acc)
    }

    val licenseElems = project.info.licenses.map {
      case (name, urlOpt) =>
        val n = 

        urlOpt.fold(n) { url =>
          n % .attributes
        }
    }

    val infoElem = {
      
        {licenseElems}
        {project.info.description}
      
    } % infoAttrs

    val confElems = project.configurations.toVector.collect {
      case (name, extends0) =>
        val n = 
        if (extends0.nonEmpty)
          n % .attributes
        else
          n
    }

    val publications = project
      .publications
      .groupBy { case (_, p) => p }
      .mapValues { _.map { case (cfg, _) => cfg } }

    val publicationElems = publications.map {
      case (pub, configs) =>
        val n = 

        if (pub.classifier.value.nonEmpty)
          n % .attributes
        else
          n
    }

    val dependencyElems = project.dependencies.toVector.map {
      case (conf, dep) =>
        val excludes = dep.exclusions.toSeq.map {
          case (org, name) =>
            
        }

        val n = ${dep.configuration.value}"}>
          {excludes}
        

        val moduleAttrs = dep.module.attributes.foldLeft[xml.MetaData](xml.Null) {
          case (acc, (k, v)) =>
            new PrefixedAttribute("e", k, v, acc)
        }

        n % moduleAttrs
    }

    val excludeElems = exclusions.toVector.map {
      case (org, name) =>
        
    }

    val overrideElems = overrides.toVector.map {
      case (org, name, ver) =>
        
    }

    
      {infoElem}
      {confElems}
      {publicationElems}
      {dependencyElems}{excludeElems}{overrideElems}
    
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy