mirror of https://github.com/sbt/sbt.git
commit
8554d11d3d
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
package sbt
|
package sbt
|
||||||
|
|
||||||
import java.io.File
|
import java.io.{ IOException, File }
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
import scala.xml.{ Text, NodeSeq, Elem, XML }
|
import scala.xml.{ Text, NodeSeq, Elem, XML }
|
||||||
import org.apache.ivy.plugins.resolver.DependencyResolver
|
import org.apache.ivy.plugins.resolver.DependencyResolver
|
||||||
|
|
@ -304,14 +304,17 @@ object Resolver {
|
||||||
private[this] def mavenLocalDir: File = {
|
private[this] def mavenLocalDir: File = {
|
||||||
def loadHomeFromSettings(f: () => File): Option[File] =
|
def loadHomeFromSettings(f: () => File): Option[File] =
|
||||||
try {
|
try {
|
||||||
val file = XML.loadFile(f())
|
val file = f()
|
||||||
(file \ "localRepository").text match {
|
if(!file.exists) None
|
||||||
|
else ((XML.loadFile(file) \ "localRepository").text match {
|
||||||
case "" => None
|
case "" => None
|
||||||
case e @ _ => Some(new File(e))
|
case e @ _ => Some(new File(e))
|
||||||
}
|
})
|
||||||
} catch {
|
} catch {
|
||||||
// Occurs inside File constructor when property or environment variable does not exist
|
// Occurs inside File constructor when property or environment variable does not exist
|
||||||
case _: NullPointerException => None
|
case _: NullPointerException => None
|
||||||
|
// Occurs when File does not exist
|
||||||
|
case _: IOException => None
|
||||||
case e: SAXParseException => System.err.println(s"WARNING: Problem parsing ${f().getAbsolutePath}, ${e.getMessage}"); None
|
case e: SAXParseException => System.err.println(s"WARNING: Problem parsing ${f().getAbsolutePath}, ${e.getMessage}"); None
|
||||||
}
|
}
|
||||||
loadHomeFromSettings(() => new File(Path.userHome, ".m2/settings.xml")) orElse
|
loadHomeFromSettings(() => new File(Path.userHome, ".m2/settings.xml")) orElse
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue