backport withXXX for ModuleID and Artifact

Fixes sbt/sbt#3159

This helps keep source compat.
This commit is contained in:
Eugene Yokota 2017-05-24 19:59:01 -04:00
parent 0ca24b69a8
commit 9b944f74fa
2 changed files with 68 additions and 0 deletions

View File

@ -9,6 +9,30 @@ import sbt.serialization._
final case class Artifact(name: String, `type`: String, extension: String, classifier: Option[String], configurations: Iterable[Configuration], url: Option[URL], extraAttributes: Map[String, String]) {
def extra(attributes: (String, String)*) = Artifact(name, `type`, extension, classifier, configurations, url, extraAttributes ++ ModuleID.checkE(attributes))
/** Copy with a new type. */
def withType(`type`: String): Artifact =
copy(`type` = `type`)
/** Copy with a new extension. */
def withExtension(extension: String): Artifact =
copy(extension = extension)
/** Copy with a new classifier. */
def withClassifier(classifier: Option[String]): Artifact =
copy(classifier = classifier)
/** Copy with new configurations. */
def withConfigurations(configurations: Vector[Configuration]): Artifact =
copy(configurations = configurations)
/** Copy with a new url. */
def withUrl(url: Option[URL]): Artifact =
copy(url = url)
/** Copy with new extraAttributes. */
def withExtraAttributes(extraAttributes: Map[String, String]): Artifact =
copy(extraAttributes = extraAttributes)
}
import Configurations.{ config, Docs, Optional, Pom, Sources, Test }

View File

@ -29,6 +29,50 @@ final case class ModuleID(organization: String, name: String, revision: String,
/** Specifies the cross-version behavior for this module. See [CrossVersion] for details.*/
def cross(v: CrossVersion): ModuleID = copy(crossVersion = v)
/** Copy with a new organization. */
def withOrganization(organization: String): ModuleID =
copy(organization = organization)
/** Copy with a new name. */
def withName(name: String): ModuleID =
copy(name = name)
/** Copy with a new revision. */
def withRevision(revision: String): ModuleID =
copy(revision = revision)
/** Copy with new configurations. */
def withConfigurations(configurations: Option[String]): ModuleID =
copy(configurations = configurations)
/** Copy with new isChanging. */
def withIsChanging(isChanging: Boolean): ModuleID =
copy(isChanging = isChanging)
/** Copy with new isTransitive. */
def withIsTransitive(isTransitive: Boolean): ModuleID =
copy(isTransitive = isTransitive)
/** Copy with new isForce. */
def withIsForce(isForce: Boolean): ModuleID =
copy(isForce = isForce)
/** Copy with new explicitArtifacts. */
def withExplicitArtifacts(explicitArtifacts: Vector[Artifact]): ModuleID =
copy(explicitArtifacts = explicitArtifacts)
/** Copy with new exclusions. */
def withExclusions(exclusions: Vector[ExclusionRule]): ModuleID =
copy(exclusions = exclusions)
/** Copy with new extraAttributes. */
def withExtraAttributes(extraAttributes: Map[String, String]): ModuleID =
copy(extraAttributes = extraAttributes)
/** Copy with new crossVersion. */
def withCrossVersion(crossVersion: CrossVersion): ModuleID =
copy(crossVersion = crossVersion)
// () required for chaining
/** Do not follow dependencies of this module. Synonym for `intransitive`.*/
def notTransitive() = intransitive()