mirror of https://github.com/sbt/sbt.git
[2.0.x] Deprecate Resolver.url
This adds Resolver.uri instead.
This commit is contained in:
parent
8bac5b9a82
commit
be3a396853
|
|
@ -132,17 +132,15 @@ private[librarymanagement] abstract class ResolverFunctions {
|
|||
|
||||
def typesafeRepo(status: String) =
|
||||
MavenRepository("typesafe-" + status, TypesafeRepositoryRoot + "/" + status)
|
||||
def typesafeIvyRepo(status: String) =
|
||||
url("typesafe-ivy-" + status, new URI(TypesafeRepositoryRoot + "/ivy-" + status + "/").toURL)(
|
||||
using ivyStylePatterns
|
||||
)
|
||||
def sbtIvyRepo(status: String) =
|
||||
url(s"sbt-ivy-$status", new URI(s"$SbtRepositoryRoot/ivy-$status/").toURL)(using
|
||||
def typesafeIvyRepo(status: String): URLRepository =
|
||||
uri("typesafe-ivy-" + status, URI(TypesafeRepositoryRoot + "/ivy-" + status + "/"))(using
|
||||
ivyStylePatterns
|
||||
)
|
||||
def sbtIvyRepo(status: String) =
|
||||
uri(s"sbt-ivy-$status", URI(s"$SbtRepositoryRoot/ivy-$status/"))(using ivyStylePatterns)
|
||||
def sbtPluginRepo(status: String) =
|
||||
url("sbt-plugin-" + status, new URI(SbtRepositoryRoot + "/sbt-plugin-" + status + "/").toURL)(
|
||||
using ivyStylePatterns
|
||||
uri("sbt-plugin-" + status, URI(SbtRepositoryRoot + "/sbt-plugin-" + status + "/"))(using
|
||||
ivyStylePatterns
|
||||
)
|
||||
|
||||
@deprecated(
|
||||
|
|
@ -325,18 +323,38 @@ private[librarymanagement] abstract class ResolverFunctions {
|
|||
|
||||
private def toUri(dir: File): URI = dir.toPath.toUri
|
||||
}
|
||||
object url {
|
||||
object url:
|
||||
|
||||
/**
|
||||
* Constructs a URL resolver with the given name. The patterns to use must be explicitly specified
|
||||
* using the `withPatterns` method on the constructed resolver object.
|
||||
*/
|
||||
@deprecated("Use Resolver.uri(...) instead", "2.0.2")
|
||||
def apply(name: String): URLRepository = uri(name)
|
||||
|
||||
/** Constructs a URL resolver with the given name and base URL. */
|
||||
@deprecated("Use Resolver.uri(...) instead", "2.0.2")
|
||||
def apply(name: String, baseURL: URL)(implicit basePatterns: Patterns): URLRepository =
|
||||
uri(name, baseURL.toURI)(using basePatterns)
|
||||
|
||||
/** Constructs a URL resolver with the given name and base URI. */
|
||||
@deprecated("Use Resolver.uri(...) instead", "2.0.2")
|
||||
def apply(name: String, baseURI: URI)(using Patterns): URLRepository =
|
||||
uri(name, baseURI)
|
||||
end url
|
||||
|
||||
object uri:
|
||||
/**
|
||||
* Constructs a URI resolver with the given name. The patterns to use must be explicitly specified
|
||||
* using the `withPatterns` method on the constructed resolver object.
|
||||
*/
|
||||
def apply(name: String): URLRepository = URLRepository(name, Patterns(false))
|
||||
|
||||
/** Constructs a file resolver with the given name and base directory. */
|
||||
def apply(name: String, baseURL: URL)(implicit basePatterns: Patterns): URLRepository =
|
||||
baseRepository(baseURL.toURI.normalize.toString)(URLRepository(name, _))
|
||||
}
|
||||
/** Constructs a URI resolver with the given name and base URI. */
|
||||
def apply(name: String, baseURI: URI)(using Patterns): URLRepository =
|
||||
baseRepository(baseURI.normalize.toString)(URLRepository(name, _))
|
||||
end uri
|
||||
|
||||
private def baseRepository[T](base: String)(construct: Patterns => T)(implicit
|
||||
basePatterns: Patterns
|
||||
): T =
|
||||
|
|
@ -474,7 +492,7 @@ private[librarymanagement] abstract class ResolverFunctions {
|
|||
if (ivy || art) {
|
||||
warnHttp(
|
||||
patterns.toString,
|
||||
s""" or opt-in as Resolver.url("${repo.name}", url(...)).withAllowInsecureProtocol(true), or by using allowInsecureProtocol in repositories file""",
|
||||
s""" or opt-in as Resolver.uri("${repo.name}", url(...)).withAllowInsecureProtocol(true), or by using allowInsecureProtocol in repositories file""",
|
||||
logger
|
||||
)
|
||||
true
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import sbt.internal.librarymanagement.UnitSpec
|
|||
|
||||
object ResolverTest extends UnitSpec {
|
||||
|
||||
"Resolver url" should "propagate pattern descriptorOptional and skipConsistencyCheck." in {
|
||||
"Resolver uri" should "propagate pattern descriptorOptional and skipConsistencyCheck." in {
|
||||
val pats = Vector("[orgPath]")
|
||||
val patsExpected = Vector("http://foo.com/test/[orgPath]")
|
||||
val patterns = Resolver
|
||||
.url("test", new URI("http://foo.com/test").toURL)(using
|
||||
.uri("test", new URI("http://foo.com/test"))(using
|
||||
Patterns(
|
||||
pats,
|
||||
pats,
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ object IvyRepoSpec extends BaseIvySpecification {
|
|||
override lazy val resolvers: Vector[Resolver] = Vector(testIvy)
|
||||
|
||||
lazy val testIvy = {
|
||||
val repoUrl = getClass.getResource("/test-ivy-repo")
|
||||
Resolver.url("Test Repo", repoUrl)(using Resolver.ivyStylePatterns)
|
||||
val repoUrl = getClass.getResource("/test-ivy-repo").toURI()
|
||||
Resolver.uri("Test Repo", repoUrl)(using Resolver.ivyStylePatterns)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import sbt.librarymanagement.syntax.*
|
|||
import verify.BasicTestSuite
|
||||
|
||||
class ResolverSpec extends BasicTestSuite {
|
||||
test("Resolver.url") {
|
||||
Resolver.url("Test Repo", new URI("http://example.com/").toURL)(using Resolver.ivyStylePatterns)
|
||||
test("Resolver.uri") {
|
||||
Resolver.uri("Test Repo", new URI("http://example.com/"))(using Resolver.ivyStylePatterns)
|
||||
()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ val publishPort = 3030
|
|||
// Publish to HTTP server (localhost) - ivyless publish uses PUT
|
||||
// Resolver.url expects java.net.URL; in build.sbt "url" is sbt.URI, so use java.net.URL explicitly
|
||||
publishTo := Some(
|
||||
Resolver.url("test-repo", new java.net.URL(s"http://localhost:$publishPort/"))(Resolver.ivyStylePatterns)
|
||||
Resolver.uri("test-repo", uri(s"http://localhost:$publishPort/"))(using Resolver.ivyStylePatterns)
|
||||
.withAllowInsecureProtocol(true)
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
def snapshotPattern = "https://repo.typesafe.com/typesafe/scala-tools-snapshots/[organization]/[module]/2.10.0-SNAPSHOT/[artifact]-[revision].[ext]"
|
||||
def scalaSnapshots = Resolver.url("Scala Tools Snapshots (Typesafe)") ivys(snapshotPattern) artifacts(snapshotPattern) mavenStyle()
|
||||
def scalaSnapshots = Resolver.uri("Scala Tools Snapshots (Typesafe)") ivys(snapshotPattern) artifacts(snapshotPattern) mavenStyle()
|
||||
moduleConfigurations += ModuleConfiguration("org.scala-lang", "*", "2.10.0-.*", scalaSnapshots)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
def snapshotPattern = "https://repo.typesafe.com/typesafe/scala-tools-snapshots/[organization]/[module]/2.10.0-SNAPSHOT/[artifact]-[revision].[ext]"
|
||||
def scalaSnapshots = Resolver.url("Scala Tools Snapshots") artifacts(snapshotPattern) ivys(snapshotPattern) mavenStyle()
|
||||
def scalaSnapshots = Resolver.uri("Scala Tools Snapshots") artifacts(snapshotPattern) ivys(snapshotPattern) mavenStyle()
|
||||
moduleConfigurations += ModuleConfiguration("org.not-scala-lang", "*", "2.10.0-.*", scalaSnapshots)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
def snapshotPattern = "https://repo.typesafe.com/typesafe/scala-tools-snapshots/[organization]/[module]/2.10.a-SNAPSHOT/[artifact]-[revision].[ext]"
|
||||
def scalaSnapshots = Resolver.url("Scala Tools Snapshots") artifacts(snapshotPattern) ivys(snapshotPattern) mavenStyle()
|
||||
def scalaSnapshots = Resolver.uri("Scala Tools Snapshots") artifacts(snapshotPattern) ivys(snapshotPattern) mavenStyle()
|
||||
moduleConfigurations += ModuleConfiguration("org.scala-lang", "*", "2.10.0-.*", scalaSnapshots)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
def snapshotPattern = "https://repo.typesafe.com/typesafe/scala-tools-snapshots/[organization]/[module]/2.10.0-SNAPSHOT/[artifact]-[revision].[ext]"
|
||||
def scalaSnapshots = Resolver.url("Scala Tools Snapshots") artifacts(snapshotPattern) ivys(snapshotPattern) mavenStyle()
|
||||
def scalaSnapshots = Resolver.uri("Scala Tools Snapshots") artifacts(snapshotPattern) ivys(snapshotPattern) mavenStyle()
|
||||
moduleConfigurations += ModuleConfiguration("org.scala-lang", "*", "2.10.0-.*", scalaSnapshots)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
scalaVersion := "2.12.8"
|
||||
|
||||
resolvers += Resolver.url(
|
||||
resolvers += Resolver.uri(
|
||||
"jitpack",
|
||||
new URL("https://jitpack.io")
|
||||
uri("https://jitpack.io")
|
||||
)(
|
||||
// patterns should be ignored - and the repo be considered a maven one - because
|
||||
// isMavenCompatible is true
|
||||
Patterns(
|
||||
using Patterns(
|
||||
Resolver.ivyStylePatterns.ivyPatterns,
|
||||
Resolver.ivyStylePatterns.artifactPatterns,
|
||||
isMavenCompatible = true,
|
||||
|
|
|
|||
Loading…
Reference in New Issue