mirror of https://github.com/sbt/sbt.git
Replace abstract protected[this] copy with abstract withX methods
This commit is contained in:
parent
95544d5175
commit
76d1f73333
26
build.sbt
26
build.sbt
|
|
@ -114,6 +114,32 @@ lazy val lmCore = (project in file("core"))
|
|||
// Configuration's copy method was never meant to be public
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.Configuration.copy"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.Configuration.copy$default$*"),
|
||||
|
||||
// the data type copy methods were never meant to be public
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.copy"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.copy$default$*"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ModuleReportExtra.copy"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ModuleReportExtra.copy$default$*"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactTypeFilterExtra.copy"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactTypeFilterExtra.copy$default$*"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ModuleIDExtra.copy"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ModuleIDExtra.copy$default$*"),
|
||||
|
||||
// these abstract classes are private[librarymanagement] so it's fine if they have more methods
|
||||
exclude[ReversedMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.*"),
|
||||
exclude[ReversedMissingMethodProblem]("sbt.librarymanagement.ModuleReportExtra.*"),
|
||||
exclude[ReversedMissingMethodProblem]("sbt.librarymanagement.ArtifactTypeFilterExtra.*"),
|
||||
exclude[ReversedMissingMethodProblem]("sbt.librarymanagement.ModuleIDExtra.*"),
|
||||
|
||||
// these abstract classes are private[librarymanagement] so they can lose these abstract methods
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.type"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.url"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.checksum"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.name"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.configurations"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.classifier"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactExtra.extension"),
|
||||
exclude[DirectMissingMethodProblem]("sbt.librarymanagement.ArtifactTypeFilterExtra.types"),
|
||||
),
|
||||
)
|
||||
.configure(addSbtIO, addSbtUtilLogging, addSbtUtilPosition, addSbtUtilCache)
|
||||
|
|
|
|||
|
|
@ -7,28 +7,12 @@ import java.io.File
|
|||
import java.net.URL
|
||||
|
||||
private[librarymanagement] abstract class ArtifactExtra {
|
||||
def name: String
|
||||
def `type`: String
|
||||
def extension: String
|
||||
def classifier: Option[String]
|
||||
def configurations: Vector[ConfigRef]
|
||||
def url: Option[URL]
|
||||
def extraAttributes: Map[String, String]
|
||||
def checksum: Option[Checksum]
|
||||
|
||||
protected[this] def copy(
|
||||
name: String = name,
|
||||
`type`: String = `type`,
|
||||
extension: String = extension,
|
||||
classifier: Option[String] = classifier,
|
||||
configurations: Vector[ConfigRef] = configurations,
|
||||
url: Option[URL] = url,
|
||||
extraAttributes: Map[String, String] = extraAttributes,
|
||||
checksum: Option[Checksum] = checksum
|
||||
): Artifact
|
||||
def withExtraAttributes(extraAttributes: Map[String, String]): Artifact
|
||||
|
||||
def extra(attributes: (String, String)*) =
|
||||
copy(extraAttributes = extraAttributes ++ ModuleID.checkE(attributes))
|
||||
withExtraAttributes(extraAttributes ++ ModuleID.checkE(attributes))
|
||||
}
|
||||
|
||||
import Configurations.{ Optional, Pom, Test }
|
||||
|
|
|
|||
|
|
@ -30,15 +30,11 @@ private[librarymanagement] abstract class InclExclRuleFunctions {
|
|||
}
|
||||
|
||||
private[librarymanagement] abstract class ArtifactTypeFilterExtra {
|
||||
def types: Set[String]
|
||||
def inverted: Boolean
|
||||
|
||||
protected[this] def copy(
|
||||
types: Set[String] = types,
|
||||
inverted: Boolean = inverted
|
||||
): ArtifactTypeFilter
|
||||
def withInverted(inverted: Boolean): ArtifactTypeFilter
|
||||
|
||||
def invert = copy(inverted = !inverted)
|
||||
def invert = withInverted(!inverted)
|
||||
}
|
||||
|
||||
private[librarymanagement] abstract class ArtifactTypeFilterFunctions {
|
||||
|
|
|
|||
|
|
@ -24,21 +24,14 @@ private[librarymanagement] abstract class ModuleIDExtra {
|
|||
def crossVersion: CrossVersion
|
||||
def branchName: Option[String]
|
||||
|
||||
protected[this] def copy(
|
||||
organization: String = organization,
|
||||
name: String = name,
|
||||
revision: String = revision,
|
||||
configurations: Option[String] = configurations,
|
||||
isChanging: Boolean = isChanging,
|
||||
isTransitive: Boolean = isTransitive,
|
||||
isForce: Boolean = isForce,
|
||||
explicitArtifacts: Vector[Artifact] = explicitArtifacts,
|
||||
inclusions: Vector[InclusionRule] = inclusions,
|
||||
exclusions: Vector[ExclusionRule] = exclusions,
|
||||
extraAttributes: Map[String, String] = extraAttributes,
|
||||
crossVersion: CrossVersion = crossVersion,
|
||||
branchName: Option[String] = branchName
|
||||
): ModuleID
|
||||
def withIsChanging(isChanging: Boolean): ModuleID
|
||||
def withIsTransitive(isTransitive: Boolean): ModuleID
|
||||
def withIsForce(isForce: Boolean): ModuleID
|
||||
def withExplicitArtifacts(explicitArtifacts: Vector[Artifact]): ModuleID
|
||||
def withExclusions(exclusions: Vector[InclExclRule]): ModuleID
|
||||
def withExtraAttributes(extraAttributes: Map[String, String]): ModuleID
|
||||
def withCrossVersion(crossVersion: CrossVersion): ModuleID
|
||||
def withBranchName(branchName: Option[String]): ModuleID
|
||||
|
||||
protected def toStringImpl: String =
|
||||
s"""$organization:$name:$revision""" +
|
||||
|
|
@ -78,14 +71,14 @@ private[librarymanagement] abstract class ModuleIDExtra {
|
|||
def cross(v: Boolean): ModuleID = cross(if (v) CrossVersion.binary else Disabled())
|
||||
|
||||
/** Specifies the cross-version behavior for this module. See [CrossVersion] for details.*/
|
||||
def cross(v: CrossVersion): ModuleID = copy(crossVersion = v)
|
||||
def cross(v: CrossVersion): ModuleID = withCrossVersion(v)
|
||||
|
||||
// () required for chaining
|
||||
/** Do not follow dependencies of this module. Synonym for `intransitive`.*/
|
||||
def notTransitive() = intransitive()
|
||||
|
||||
/** Do not follow dependencies of this module. Synonym for `notTransitive`.*/
|
||||
def intransitive() = copy(isTransitive = false)
|
||||
def intransitive() = withIsTransitive(false)
|
||||
|
||||
/**
|
||||
* Marks this dependency as "changing". Ivy will always check if the metadata has changed and then if the artifact has changed,
|
||||
|
|
@ -93,13 +86,13 @@ private[librarymanagement] abstract class ModuleIDExtra {
|
|||
*
|
||||
* See the "Changes in artifacts" section of https://ant.apache.org/ivy/history/trunk/concept.html for full details.
|
||||
*/
|
||||
def changing() = copy(isChanging = true)
|
||||
def changing() = withIsChanging(true)
|
||||
|
||||
/**
|
||||
* Indicates that conflict resolution should only select this module's revision.
|
||||
* This prevents a newer revision from being pulled in by a transitive dependency, for example.
|
||||
*/
|
||||
def force() = copy(isForce = true)
|
||||
def force() = withIsForce(true)
|
||||
|
||||
/**
|
||||
* Specifies a URL from which the main artifact for this dependency can be downloaded.
|
||||
|
|
@ -116,13 +109,13 @@ private[librarymanagement] abstract class ModuleIDExtra {
|
|||
* these artifact definitions override the information in the dependency's published metadata.
|
||||
*/
|
||||
def artifacts(newArtifacts: Artifact*) =
|
||||
copy(explicitArtifacts = newArtifacts.toVector ++ explicitArtifacts)
|
||||
withExplicitArtifacts(newArtifacts.toVector ++ explicitArtifacts)
|
||||
|
||||
/**
|
||||
* Applies the provided exclusions to dependencies of this module. Note that only exclusions that specify
|
||||
* both the exact organization and name and nothing else will be included in a pom.xml.
|
||||
*/
|
||||
def excludeAll(rules: ExclusionRule*) = copy(exclusions = this.exclusions ++ rules)
|
||||
def excludeAll(rules: ExclusionRule*) = withExclusions(exclusions ++ rules)
|
||||
|
||||
/** Excludes the dependency with organization `org` and `name` from being introduced by this dependency during resolution. */
|
||||
def exclude(org: String, name: String) =
|
||||
|
|
@ -133,7 +126,7 @@ private[librarymanagement] abstract class ModuleIDExtra {
|
|||
* This information will only be published in an ivy.xml and not in a pom.xml.
|
||||
*/
|
||||
def extra(attributes: (String, String)*) =
|
||||
copy(extraAttributes = this.extraAttributes ++ ModuleID.checkE(attributes))
|
||||
withExtraAttributes(extraAttributes ++ ModuleID.checkE(attributes))
|
||||
|
||||
/**
|
||||
* Not recommended for new use. This method is not deprecated, but the `update-classifiers` task is preferred
|
||||
|
|
@ -176,9 +169,9 @@ private[librarymanagement] abstract class ModuleIDExtra {
|
|||
/**
|
||||
* Sets the Ivy branch of this module.
|
||||
*/
|
||||
def branch(branchName: String) = copy(branchName = Some(branchName))
|
||||
def branch(branchName: String) = withBranchName(Some(branchName))
|
||||
|
||||
def branch(branchName: Option[String]) = copy(branchName = branchName)
|
||||
def branch(branchName: Option[String]) = withBranchName(branchName)
|
||||
}
|
||||
|
||||
private[librarymanagement] abstract class ModuleIDFunctions {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ private[librarymanagement] abstract class ModuleReportExtra {
|
|||
def licenses: Vector[(String, Option[String])]
|
||||
def callers: Vector[Caller]
|
||||
|
||||
def withArtifacts(artifacts: Vector[(Artifact, File)]): ModuleReport
|
||||
|
||||
protected[this] def arts: Vector[String] =
|
||||
artifacts.map(_.toString) ++ missingArtifacts.map(art => "(MISSING) " + art)
|
||||
|
||||
|
|
@ -102,28 +104,7 @@ private[librarymanagement] abstract class ModuleReportExtra {
|
|||
}
|
||||
|
||||
def retrieve(f: (ModuleID, Artifact, File) => File): ModuleReport =
|
||||
copy(artifacts = artifacts.map { case (art, file) => (art, f(module, art, file)) })
|
||||
|
||||
protected[this] def copy(
|
||||
module: ModuleID = module,
|
||||
artifacts: Vector[(Artifact, File)] = artifacts,
|
||||
missingArtifacts: Vector[Artifact] = missingArtifacts,
|
||||
status: Option[String] = status,
|
||||
publicationDate: Option[ju.Calendar] = publicationDate,
|
||||
resolver: Option[String] = resolver,
|
||||
artifactResolver: Option[String] = artifactResolver,
|
||||
evicted: Boolean = evicted,
|
||||
evictedData: Option[String] = evictedData,
|
||||
evictedReason: Option[String] = evictedReason,
|
||||
problem: Option[String] = problem,
|
||||
homepage: Option[String] = homepage,
|
||||
extraAttributes: Map[String, String] = extraAttributes,
|
||||
isDefault: Option[Boolean] = isDefault,
|
||||
branch: Option[String] = branch,
|
||||
configurations: Vector[ConfigRef] = configurations,
|
||||
licenses: Vector[(String, Option[String])] = licenses,
|
||||
callers: Vector[Caller] = callers
|
||||
): ModuleReport
|
||||
withArtifacts(artifacts.map { case (art, file) => (art, f(module, art, file)) })
|
||||
}
|
||||
|
||||
private[librarymanagement] abstract class UpdateReportExtra {
|
||||
|
|
|
|||
Loading…
Reference in New Issue