Skip to content

Commit

Permalink
remove a few more java.net.URL
Browse files Browse the repository at this point in the history
  • Loading branch information
jtjeferreira committed Jun 17, 2024
1 parent dc76e6b commit 96640f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ object IfMissing {
object ComponentManager {
lazy val (version, timestamp) = {
val properties = new java.util.Properties
val propertiesStream = versionResource.openStream
val propertiesStream = getClass.getResourceAsStream("/xsbt.version.properties")
try {
properties.load(propertiesStream)
} finally {
Expand All @@ -110,7 +110,4 @@ object ComponentManager {
(properties.getProperty("version"), properties.getProperty("timestamp"))
}
lazy val stampedVersion = version + "_" + timestamp

import java.net.URL
private def versionResource: URL = getClass.getResource("/xsbt.version.properties")
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,17 @@ 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 URI(source).toURL
if (url.getProtocol == IO.FileScheme)
new FileResource(repo, IO.toFile(url))
val uri = new URI(source)
if (uri.getScheme == IO.FileScheme)
new FileResource(repo, IO.toFile(uri))
else
super.getResource(source)
}

override def put(source: File, destination: String, overwrite: Boolean): Unit = {
val url = new URI(destination).toURL
val uri = new URI(destination)
try {
if (url.getProtocol != IO.FileScheme) super.put(source, destination, overwrite)
if (uri.getScheme != IO.FileScheme) super.put(source, destination, overwrite)
else {
// Here we duplicate the put method for files so we don't just bail on trying ot use Http handler
val resource = getResource(destination)
Expand All @@ -417,7 +417,7 @@ private[sbt] object ConvertResolver {
if (totalLength > 0) {
progress.setTotalLength(totalLength);
}
FileUtil.copy(source, new java.io.File(url.toURI), progress, overwrite)
FileUtil.copy(source, new java.io.File(uri), progress, overwrite)
()
} catch {
case ex: IOException =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 URI(artifact.getLocation).toURL.toURI.getPath
val path = new URI(artifact.getLocation).getPath
val localFile = new File(path)

if (path.nonEmpty && localFile.exists) {
Expand Down

0 comments on commit 96640f7

Please sign in to comment.