mirror of https://github.com/sbt/sbt.git
Merge pull request #418 from xuwei-k/java-net-URL
avoid deprecated `java.net.URL` constructor
This commit is contained in:
commit
cbd7195aee
|
|
@ -1,6 +1,7 @@
|
|||
package sbt.librarymanagement
|
||||
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
|
||||
/**
|
||||
* Commonly used software licenses
|
||||
|
|
@ -9,16 +10,16 @@ import java.net.URL
|
|||
*/
|
||||
object License {
|
||||
lazy val Apache2: (String, URL) =
|
||||
("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt"))
|
||||
("Apache-2.0", new URI("https://www.apache.org/licenses/LICENSE-2.0.txt").toURL)
|
||||
|
||||
lazy val MIT: (String, URL) =
|
||||
("MIT", new URL("https://opensource.org/licenses/MIT"))
|
||||
("MIT", new URI("https://opensource.org/licenses/MIT").toURL)
|
||||
|
||||
lazy val CC0: (String, URL) =
|
||||
("CC0-1.0", new URL("https://creativecommons.org/publicdomain/zero/1.0/legalcode"))
|
||||
("CC0-1.0", new URI("https://creativecommons.org/publicdomain/zero/1.0/legalcode").toURL)
|
||||
|
||||
def PublicDomain: (String, URL) = CC0
|
||||
|
||||
lazy val GPL3_or_later: (String, URL) =
|
||||
("GPL-3.0-or-later", new URL("https://spdx.org/licenses/GPL-3.0-or-later.html"))
|
||||
("GPL-3.0-or-later", new URI("https://spdx.org/licenses/GPL-3.0-or-later.html").toURL)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
package sbt.librarymanagement
|
||||
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
|
||||
import sbt.internal.librarymanagement.mavenint.SbtPomExtraProperties
|
||||
import scala.collection.mutable.ListBuffer
|
||||
|
|
@ -132,7 +132,7 @@ private[librarymanagement] abstract class ModuleIDExtra {
|
|||
* It is not included in published metadata.
|
||||
*/
|
||||
def from(url: String, allowInsecureProtocol: Boolean): ModuleID =
|
||||
artifacts(Artifact(name, new URL(url), allowInsecureProtocol))
|
||||
artifacts(Artifact(name, new URI(url).toURL, allowInsecureProtocol))
|
||||
|
||||
/** Adds a dependency on the artifact for this module with classifier `c`. */
|
||||
def classifier(c: String): ModuleID = artifacts(Artifact(name, c))
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import scala.annotation.nowarn
|
|||
import scala.xml.XML
|
||||
import org.xml.sax.SAXParseException
|
||||
import sbt.util.Logger
|
||||
import java.net.URI
|
||||
|
||||
final class RawRepository(val resolver: AnyRef, name: String) extends Resolver(name) {
|
||||
override def toString = "Raw(" + resolver.toString + ")"
|
||||
|
|
@ -146,13 +147,13 @@ private[librarymanagement] abstract class ResolverFunctions {
|
|||
def typesafeRepo(status: String) =
|
||||
MavenRepository("typesafe-" + status, TypesafeRepositoryRoot + "/" + status)
|
||||
def typesafeIvyRepo(status: String) =
|
||||
url("typesafe-ivy-" + status, new URL(TypesafeRepositoryRoot + "/ivy-" + status + "/"))(
|
||||
url("typesafe-ivy-" + status, new URI(TypesafeRepositoryRoot + "/ivy-" + status + "/").toURL)(
|
||||
ivyStylePatterns
|
||||
)
|
||||
def sbtIvyRepo(status: String) =
|
||||
url(s"sbt-ivy-$status", new URL(s"$SbtRepositoryRoot/ivy-$status/"))(ivyStylePatterns)
|
||||
url(s"sbt-ivy-$status", new URI(s"$SbtRepositoryRoot/ivy-$status/").toURL)(ivyStylePatterns)
|
||||
def sbtPluginRepo(status: String) =
|
||||
url("sbt-plugin-" + status, new URL(SbtRepositoryRoot + "/sbt-plugin-" + status + "/"))(
|
||||
url("sbt-plugin-" + status, new URI(SbtRepositoryRoot + "/sbt-plugin-" + status + "/").toURL)(
|
||||
ivyStylePatterns
|
||||
)
|
||||
@deprecated(
|
||||
|
|
@ -175,7 +176,7 @@ private[librarymanagement] abstract class ResolverFunctions {
|
|||
def bintrayRepo(owner: String, repo: String) =
|
||||
MavenRepository(s"bintray-$owner-$repo", s"https://dl.bintray.com/$owner/$repo/")
|
||||
def bintrayIvyRepo(owner: String, repo: String) =
|
||||
url(s"bintray-$owner-$repo", new URL(s"https://dl.bintray.com/$owner/$repo/"))(
|
||||
url(s"bintray-$owner-$repo", new URI(s"https://dl.bintray.com/$owner/$repo/").toURL)(
|
||||
Resolver.ivyStylePatterns
|
||||
)
|
||||
def jcenterRepo = JCenterRepository
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package sbt.librarymanagement
|
||||
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
|
||||
import sbt.internal.librarymanagement.UnitSpec
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ object ResolverTest extends UnitSpec {
|
|||
val pats = Vector("[orgPath]")
|
||||
val patsExpected = Vector("http://foo.com/test/[orgPath]")
|
||||
val patterns = Resolver
|
||||
.url("test", new URL("http://foo.com/test"))(
|
||||
.url("test", new URI("http://foo.com/test").toURL)(
|
||||
Patterns(
|
||||
pats,
|
||||
pats,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
package sbt.internal.librarymanagement
|
||||
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
import java.util.Collections
|
||||
|
||||
import org.apache.ivy.core.module.descriptor.DependencyDescriptor
|
||||
|
|
@ -394,7 +394,7 @@ private[sbt] object ConvertResolver {
|
|||
private[this] val repo = new WarnOnOverwriteFileRepo()
|
||||
private[this] val progress = new RepositoryCopyProgressListener(this);
|
||||
override def getResource(source: String) = {
|
||||
val url = new URL(source)
|
||||
val url = new URI(source).toURL
|
||||
if (url.getProtocol == IO.FileScheme)
|
||||
new FileResource(repo, IO.toFile(url))
|
||||
else
|
||||
|
|
@ -402,7 +402,7 @@ private[sbt] object ConvertResolver {
|
|||
}
|
||||
|
||||
override def put(source: File, destination: String, overwrite: Boolean): Unit = {
|
||||
val url = new URL(destination)
|
||||
val url = new URI(destination).toURL
|
||||
try {
|
||||
if (url.getProtocol != IO.FileScheme) super.put(source, destination, overwrite)
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package sbt
|
||||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
|
||||
import org.apache.ivy.core.cache.ArtifactOrigin
|
||||
import org.apache.ivy.core.cache.{ DefaultRepositoryCacheManager, RepositoryCacheManager }
|
||||
|
|
@ -69,7 +69,7 @@ private[sbt] class FakeResolver(private var name: String, cacheDir: File, module
|
|||
): ArtifactDownloadReport = {
|
||||
|
||||
val report = new ArtifactDownloadReport(artifact.getArtifact)
|
||||
val path = new URL(artifact.getLocation).toURI.getPath
|
||||
val path = new URI(artifact.getLocation).toURL.toURI.getPath
|
||||
val localFile = new File(path)
|
||||
|
||||
if (path.nonEmpty && localFile.exists) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package sbt.internal.librarymanagement
|
||||
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
import java.io.File
|
||||
|
||||
import sbt.librarymanagement._
|
||||
|
|
@ -43,7 +43,7 @@ object DMSerializationSpec extends BasicTestSuite {
|
|||
}
|
||||
|
||||
test("""Artifact("foo", url("http://example.com/")) should roundtrip""") {
|
||||
roundtrip(Artifact("foo", new URL("http://example.com/")))
|
||||
roundtrip(Artifact("foo", new URI("http://example.com/").toURL))
|
||||
}
|
||||
|
||||
test("""Artifact("foo").extra(("key", "value")) should roundtrip""") {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package sbttest
|
||||
|
||||
import java.net.URL
|
||||
import java.net.URI
|
||||
import sbt.librarymanagement._
|
||||
import sbt.librarymanagement.syntax._
|
||||
import verify.BasicTestSuite
|
||||
|
||||
class ResolverSpec extends BasicTestSuite {
|
||||
test("Resolver.url") {
|
||||
Resolver.url("Test Repo", new URL("http://example.com/"))(Resolver.ivyStylePatterns)
|
||||
Resolver.url("Test Repo", new URI("http://example.com/").toURL)(Resolver.ivyStylePatterns)
|
||||
()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue