将Scala项目发布到本地存储库?

时间:2014-05-15 20:21:05

标签: sbt

我试图用sbt。

将项目发布到我的本地存储库中

这是我的 build.sbt 文件

name := "myProject"

organization := "co.myorganization"

version := "2.0"

scalaVersion := "2.11.0"

sbtPlugin := true

这是我的publishLocal命令输出:

[info] :: delivering :: co.myorganization#myProject;2.0 :: 2.0 :: release :: Thu May 15 14:57:24 COT 2014

所有似乎都运行正常,但在我的其他项目中,当我尝试将其用作依赖项时,我收到此错误:

"co.myorganization" % "my-project"  % "2.0"

错误输出:

::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: co.myorganization#my-project;2.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[trace] Stack trace suppressed: run last *:update for the full output.
[error] (*:update) sbt.ResolveException: unresolved dependency: co.s4n#s4n-autenticacion;2.0: not found
[error] Missing task key: scalaInstance
java.lang.IllegalArgumentException
    at org.sbtidea.Settings.logErrorAndFail(Settings.scala:11)
    at org.sbtidea.Settings$$anonfun$task$1.apply(Settings.scala:24)
    at org.sbtidea.Settings$$anonfun$task$1.apply(Settings.scala:24)
    at scala.Option.getOrElse(Option.scala:120)
    at org.sbtidea.Settings.task(Settings.scala:24)
    at org.sbtidea.SbtIdeaPlugin$.projectData(SbtIdeaPlugin.scala:163)
    at org.sbtidea.SbtIdeaPlugin$$anonfun$2.applyOrElse(SbtIdeaPlugin.scala:88)
    at org.sbtidea.SbtIdeaPlugin$$anonfun$2.applyOrElse(SbtIdeaPlugin.scala:87)
    at scala.runtime.AbstractPartialFunction.apply(AbstractPartialFunction.scala:33)
    at scala.collection.TraversableLike$$anonfun$collect$1.apply(TraversableLike.scala:278)
    at scala.collection.immutable.RedBlackTree$.foreach(RedBlackTree.scala:79)
    at scala.collection.immutable.TreeMap.foreach(TreeMap.scala:202)
    at scala.collection.TraversableLike$class.collect(TraversableLike.scala:278)
    at scala.collection.immutable.TreeMap.collect(TreeMap.scala:48)
    at org.sbtidea.SbtIdeaPlugin$.doCommand(SbtIdeaPlugin.scala:87)
    at org.sbtidea.SbtIdeaPlugin$$anonfun$org$sbtidea$SbtIdeaPlugin$$ideaCommand$2.apply(SbtIdeaPlugin.scala:45)
    at org.sbtidea.SbtIdeaPlugin$$anonfun$org$sbtidea$SbtIdeaPlugin$$ideaCommand$2.apply(SbtIdeaPlugin.scala:45)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$1$$anonfun$apply$2.apply(Command.scala:60)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62)
    at sbt.Command$.process(Command.scala:95)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
    at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:100)
    at sbt.State$$anon$1.process(State.scala:179)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
    at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:100)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.MainLoop$.next(MainLoop.scala:100)
    at sbt.MainLoop$.run(MainLoop.scala:93)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:71)
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:66)
    at sbt.Using.apply(Using.scala:25)
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:66)
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:49)
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:33)
    at sbt.MainLoop$.runLogged(MainLoop.scala:25)
    at sbt.StandardMain$.runManaged(Main.scala:57)
    at sbt.xMain.run(Main.scala:29)
    at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:57)
    at xsbt.boot.Launch$.withContextLoader(Launch.scala:77)
    at xsbt.boot.Launch$.run(Launch.scala:57)
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
    at xsbt.boot.Launch$.launch(Launch.scala:65)
    at xsbt.boot.Launch$.apply(Launch.scala:16)
    at xsbt.boot.Boot$.runImpl(Boot.scala:32)
    at xsbt.boot.Boot$.main(Boot.scala:21)
    at xsbt.boot.Boot.main(Boot.scala)
[error] java.lang.IllegalArgumentException

请告知。

2 个答案:

答案 0 :(得分:1)

如果您将项目构建为插件sbtPlugin := true,它将添加有关sbt版本的额外信息。

您必须使用addSbtPlugin添加这些文字,此外还因为您已经为插件重写了默认的Scala版本,您必须将其添加到addSbtPlugin方法:

addSbtPlugin("co.myorganization" % "myproject" % "2.0", "0.13", "2.11")

假设您要将插件添加到Sbt版本0.13和Scala 2.11。

在插件时更好地坚持使用默认版本的Scala。

如果您没有插件,请从sbtPlugin := true删除build.sbt

答案 1 :(得分:0)

也许您需要将本地存储库添加到解析器列表中?

resolvers += "Local Maven Repository" at file(
    Path.userHome.absolutePath+"/.m2/repository").toURL.toString