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

scala.coursier.util.Artifact.scala Maven / Gradle / Ivy

There is a newer version: 2.1.13
Show newest version
package coursier.util

import coursier.core.Authentication
import dataclass.data

@data class Artifact(
  url: String,
  checksumUrls: Map[String, String] = Map.empty,
  extra: Map[String, Artifact] = Map.empty,
  changing: Boolean = false,
  optional: Boolean = false,
  authentication: Option[Authentication] = None
) {
  final override lazy val hashCode = tuple.hashCode()
}

object Artifact {

  /** Creates an artifact out of the passed URL, taking into account any "?changing" query string */
  def fromUrl(url: String): Artifact = {
    val (url0, changing) =
      if (url.endsWith("?changing")) (url.stripSuffix("?changing"), true)
      else if (url.endsWith("?changing=true")) (url.stripSuffix("?changing=true"), true)
      else if (url.endsWith("?changing=false")) (url.stripSuffix("?changing=false"), false)
      else (url, false)
    Artifact(url).withChanging(changing)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy