mirror of https://github.com/sbt/sbt.git
Better file URI handling
Next step would be to make Artifact generic, and use java.net.URI / java.io.File instead of strings.
This commit is contained in:
parent
a1be48eeac
commit
7f774319e6
|
|
@ -15,7 +15,7 @@ case class MavenRepository(
|
|||
logger: Option[MavenRepository.Logger] = None
|
||||
) extends BaseMavenRepository(root, ivyLike) {
|
||||
|
||||
val isLocal = root.startsWith("file:///")
|
||||
val isLocal = root.startsWith("file:/")
|
||||
|
||||
def fetch(
|
||||
artifact: Artifact,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package coursier.core
|
|||
import scalaz.{ -\/, \/-, \/, EitherT }
|
||||
import scalaz.concurrent.Task
|
||||
|
||||
import java.io.File
|
||||
|
||||
import coursier.core.compatibility.encodeURIComponent
|
||||
|
||||
trait Repository {
|
||||
|
|
@ -21,7 +23,7 @@ object Repository {
|
|||
val sonatypeReleases = MavenRepository("https://oss.sonatype.org/content/repositories/releases/")
|
||||
val sonatypeSnapshots = MavenRepository("https://oss.sonatype.org/content/repositories/snapshots/")
|
||||
|
||||
lazy val ivy2Local = MavenRepository("file://" + sys.props("user.home") + "/.ivy2/local/", ivyLike = true)
|
||||
lazy val ivy2Local = MavenRepository(new File(sys.props("user.home") + "/.ivy2/local/").toURI.toString, ivyLike = true)
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ case class Cache(cache: File) {
|
|||
add("central", "https://repo1.maven.org/maven2/", ivyLike = false)
|
||||
|
||||
def addIvy2Local(): Unit =
|
||||
add("ivy2local", "file://" + sys.props("user.home") + "/.ivy2/local/", ivyLike = true)
|
||||
add("ivy2local", new File(sys.props("user.home") + "/.ivy2/local/").toURI.toString, ivyLike = true)
|
||||
|
||||
def init(ifEmpty: Boolean = true): Unit =
|
||||
if (!ifEmpty || !cache.exists()) {
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@ case class Files(
|
|||
|
||||
def withLocal(artifact: Artifact): Artifact = {
|
||||
val isLocal =
|
||||
artifact.url.startsWith("file://") &&
|
||||
artifact.checksumUrls.values.forall(_.startsWith("file://"))
|
||||
artifact.url.startsWith("file:/") &&
|
||||
artifact.checksumUrls.values.forall(_.startsWith("file:/"))
|
||||
|
||||
def local(url: String) =
|
||||
if (url.startsWith("file://"))
|
||||
if (url.startsWith("file:///"))
|
||||
url.stripPrefix("file://")
|
||||
else if (url.startsWith("file:/"))
|
||||
url.stripPrefix("file:")
|
||||
else
|
||||
cache.find{case (base, _) => url.startsWith(base)} match {
|
||||
case None => ???
|
||||
|
|
@ -139,7 +141,7 @@ case class Files(
|
|||
|
||||
|
||||
val tasks =
|
||||
for ((f, url) <- pairs if url != ("file://" + f)) yield {
|
||||
for ((f, url) <- pairs if url != ("file:" + f) && url != ("file://" + f)) yield {
|
||||
val file = new File(f)
|
||||
cachePolicy(locally(file))(remote(file, url))
|
||||
.map(e => (file, url) -> e.map(_ => ()))
|
||||
|
|
|
|||
Loading…
Reference in New Issue