mirror of https://github.com/sbt/sbt.git
Additional updates, should be clean now.
This commit is contained in:
parent
ad7d9ce42b
commit
31acddf856
|
|
@ -5,7 +5,7 @@ package sbt
|
|||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import scala.xml.{ XML, NodeSeq }
|
||||
import scala.xml.{ Text, NodeSeq, Elem, XML }
|
||||
import org.apache.ivy.plugins.resolver.DependencyResolver
|
||||
|
||||
sealed trait Resolver {
|
||||
|
|
@ -303,17 +303,19 @@ object Resolver {
|
|||
private[this] def mavenLocalDir: File = {
|
||||
def loadHomeFromSettings(f: () => File): Option[File] =
|
||||
try {
|
||||
XML.loadFile(f()) \ "settings" \ "localRepository" match {
|
||||
case scala.xml.Text(loc) => Some(new File(loc))
|
||||
case _ => None
|
||||
val file = XML.loadFile(f())
|
||||
(file \ "localRepository").text match {
|
||||
case "" => None
|
||||
case e @ _ => Some(new File(e))
|
||||
}
|
||||
} catch {
|
||||
case _: Throwable => None
|
||||
// Occurs inside File constructor when property or environment variable does not exist
|
||||
case _: NullPointerException => None
|
||||
}
|
||||
loadHomeFromSettings(() => new File(Path.userHome, ".m2/settings.xml")) orElse
|
||||
loadHomeFromSettings(() => new File(Path.fileProperty("M2_HOME"), "conf/settings.xml")) getOrElse
|
||||
loadHomeFromSettings(() => new File(new File(System.getenv("M2_HOME")), "conf/settings.xml")) getOrElse
|
||||
new File(Path.userHome, ".m2/repository")
|
||||
}
|
||||
}
|
||||
def publishMavenLocal = Resolver.file("publish-m2-local", mavenLocalDir)
|
||||
def mavenLocal = MavenRepository("Maven2 Local", mavenLocalDir.toURI.toString)
|
||||
def defaultLocal = defaultUserFileRepository("local")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
[1600]: https://github.com/sbt/sbt/pull/1600
|
||||
[@topping]: https://github.com/topping
|
||||
|
||||
### Improvements
|
||||
|
||||
* Maven local repository is now resolved from the first of the <localRepository/> element in ~/.m2/settings.xml, $M2_HOME/conf/settings.xml or the default of
|
||||
~/.m2/repository if neither of those configuration elements exist. If more Maven settings are required to be recovered, the proper thing to do is merge
|
||||
the two possible settings.xml files, then query against the element path of the merge. This code avoids the merge by checking sequentially.
|
||||
Loading…
Reference in New Issue