How to use scala-time?

2020-06-16 08:06发布

问题:

somebody know scala-time? (https://github.com/jorgeortiz85/scala-time) Have no idea how to use it. I can download it (on linux) and run sbt but theres always the same errormessage:

git clone git://github.com/jorgeortiz85/scala-time
cd scala-time
sbt
Getting org.scala-tools.sbt sbt_2.9.1 0.7.4 ...

:: problems summary ::
:::: WARNINGS
        module not found: org.scala-tools.sbt#sbt_2.9.1;0.7.4

    ==== local: tried

      /home/ll/.ivy2/local/org.scala-tools.sbt/sbt_2.9.1/0.7.4/ivys/ivy.xml

      -- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:

      /home/ll/.ivy2/local/org.scala-tools.sbt/sbt_2.9.1/0.7.4/jars/sbt_2.9.1.jar

    ==== Maven2 Local: tried

      file:///home/ll/.m2/repository/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.pom

      -- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:

      file:///home/ll/.m2/repository/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.jar

    ==== typesafe-ivy-releases: tried

      http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.9.1/0.7.4/ivys/ivy.xml

      -- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:

      http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.9.1/0.7.4/jars/sbt_2.9.1.jar

    ==== Maven Central: tried

      http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.pom

      -- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:

      http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.jar

    ==== Scala-Tools Maven2 Repository: tried

      http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.pom

      -- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:

      http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.jar

    ==== Scala-Tools Maven2 Snapshots Repository: tried

      http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.pom

      -- artifact org.scala-tools.sbt#sbt_2.9.1;0.7.4!sbt_2.9.1.jar:

      http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.9.1/0.7.4/sbt_2.9.1-0.7.4.jar

        ::::::::::::::::::::::::::::::::::::::::::::::

        ::          UNRESOLVED DEPENDENCIES         ::

        ::::::::::::::::::::::::::::::::::::::::::::::

        :: org.scala-tools.sbt#sbt_2.9.1;0.7.4: not found

        ::::::::::::::::::::::::::::::::::::::::::::::

huh? Any other options?

回答1:

To actually use it (as compared to building scala-time yourself), just add

libraryDependencies += "org.scala-tools.time" % "time_2.9.1" % "0.5"

to the build.sbt of the project you want to use it in.

Addition:

Current versions may want to use

libraryDependencies += "org.scalaj" %% "scalaj-time" % "0.6"


回答2:

This is an sbt version problem, and you might be able to work around it by using a different sbt-launch or by changing the build a bit. I get a similar error if I use sbt-launch-0.10.1.jar for this code, but it works fine if I use sbt-launch-0.7.7.jar.

I'd suspect you're using sbt-launch-0.11.0, and this is causing sbt to look for a compiled version of sbt that doesn't in fact exist.

Possible fixes are:

  1. Just use sbt-launch-0.7.7 for this code.
  2. Edit the build.properties file to use a different version of sbt.
  3. Get source for sbt-0.7.4, compile with scala 2.9.1 and stash the result in your local ivy repository with the name and location that's being searched.

Options 1 and 2 worked for me.

I haven't done #3 for this, but have done similar things for other code. It can be a bit painful...

You can have multiple versions of sbt-launch and flip between them depending on the needs of a particular codebase.

Perhaps someone who knows sbt better than I will post a real solution, but I'm hoping this is at least a little helpful.



回答3:

Update or remove the sbt version(0.7.4) line from build.properties



回答4:

That means there's no public version of SBT 0.7.4 compiled against Scala 2.9.1 by the looks of it.



标签: scala sbt