SBT doesn't find file in local maven repository although it's there

前端 未结 4 1816
不思量自难忘°
不思量自难忘° 2020-12-07 17:19

I\'m having problems with a maven dependency which is in my local respository.

SBT can\'t find it. Already set log level to debug, but not getting anything new.

相关标签:
4条回答
  • 2020-12-07 17:53

    You need three slashes after the file: specifier. This is because between the second and third slash, you have an optional hostname. Wikipedia has a good explanation of file: URL's

    You're having a problem because the typical pattern of "file://"+Path.userHome+"/.m2/repository" assumes a Unix filesystem, where the path begins with a /, contains no :, and usually contains no spaces.

    To have a non-hardcoded path that works on both Windows and Linux/Unix, use:

    "Local Maven" at Path.userHome.asFile.toURI.toURL + ".m2/repository"
    
    0 讨论(0)
  • 2020-12-07 17:56

    Watch out when you have a project defined, you'll need to include the resolver in the settings. Global resolver will not be identified.

    Example:

    lazy val core = (project in file("core")).
      settings(commonSettings: _*).
      settings(
        resolvers += Resolver.mavenLocal,
        name := "Core",
        libraryDependencies := coreDependencies
      )
    
    0 讨论(0)
  • 2020-12-07 18:12

    To get this to work for newer versions of sbt, add the following to build.sbt:

    resolvers += "Local Maven Repository" at "file:///"+Path.userHome+"/.m2/repository"
    
    0 讨论(0)
  • 2020-12-07 18:13

    Just add this line in the build.scala or build.sbt file

    resolvers += Resolver.mavenLocal
    
    0 讨论(0)
提交回复
热议问题