7

想查看akka的源码,好像用的是0.7.x版本的sbt。
我将项目配置转换为 0.10.x 版本。当我在库依赖项中添加 sbteclipse 并运行 eclipse create-src 以生成 eclipse 项目时,它告诉 eclipse 不是命令。这是我的 Build.scala。当我使用库依赖项列出库时,实际上存在 sbteclipse_2.8.1.jar

我之前犯了一个愚蠢的错误。插件定义应该在 project/plugins/build.sbt 文件中声明,而不是在 yourproject/build.sbt 中作为库依赖项

import sbt._
import Keys._

object Settings {
  import Dependencies._
  import Resolvers._

  val buildScalaVersion = "2.9.0-1"

  val buildSettings = Defaults.defaultSettings ++ Seq(
    scalaVersion := buildScalaVersion,
    libraryDependencies := Depns,
    resolvers := Repos)
}
object Resolvers {
  /**
   * repos definition
   */
  lazy val Repos = Seq(
    AkkaRepo,
    CodehausRepo,
    GuiceyFruitRepo,
    JBossRepo,
    JavaNetRepo,
    SonatypeSnapshotRepo,
    GlassfishRepo,
    ScalaToolsRelRepo,
    ScalaToolsSnapshotRepo,
    TypeSafeRepo)
  lazy val AkkaRepo = "Akka Repository" at "http://akka.io/repository"
  lazy val CodehausRepo = "Codehaus Repo" at "http://repository.codehaus.org"
  lazy val GuiceyFruitRepo = "GuiceyFruit Repo" at "http://guiceyfruit.googlecode.com/svn/repo/releases/"
  lazy val JBossRepo = "JBoss Repo" at "http://repository.jboss.org/nexus/content/groups/public/"
  lazy val JavaNetRepo = "java.net Repo" at "http://download.java.net/maven/2"
  lazy val SonatypeSnapshotRepo = "Sonatype OSS Repo" at "http://oss.sonatype.org/content/repositories/releases"
  lazy val GlassfishRepo = "Glassfish Repo" at "http://download.java.net/maven/glassfish"
  lazy val ScalaToolsRelRepo = "Scala Tools Releases Repo" at "http://scala-tools.org/repo-releases"
  lazy val DatabinderRepo = "Databinder Repo" at "http://databinder.net/repo"
  lazy val ScalaToolsSnapshotRepo = "Scala-Tools Snapshot Repo" at "http://scala-tools.org/repo-snapshots"
  //type safe sbteclipse plugin repo
  lazy val typesafeRepoUrl = new java.net.URL("http://repo.typesafe.com/typesafe/releases")
  lazy val pattern = Patterns(false, "[organisation]/[module]/[sbtversion]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]")
  lazy val TypeSafeRepo = Resolver.url("Typesafe Repository", typesafeRepoUrl)(pattern)
}

object Dependencies {

  // -------------------------------------------------------------------------------------------------------------------
  // Versions
  // -------------------------------------------------------------------------------------------------------------------
  lazy val JACKSON_VERSION = "1.7.1"
  lazy val JERSEY_VERSION = "1.3"
  lazy val MULTIVERSE_VERSION = "0.6.2"
  lazy val SCALATEST_VERSION = "1.4.1"
  lazy val JETTY_VERSION = "7.4.0.v20110414"
  lazy val JAVAX_SERVLET_VERSION = "3.0"
  lazy val SLF4J_VERSION = "1.6.0"
  // Compile
  lazy val aopalliance = "aopalliance" % "aopalliance" % "1.0" % "compile" //Public domain
  lazy val aspectwerkz = "org.codehaus.aspectwerkz" % "aspectwerkz" % "2.2.3" % "compile" //ApacheV2
  lazy val commons_codec = "commons-codec" % "commons-codec" % "1.4" % "compile" //ApacheV2
  lazy val commons_io = "commons-io" % "commons-io" % "2.0.1" % "compile" //ApacheV2
  lazy val javax_servlet_30 = "org.glassfish" % "javax.servlet" % JAVAX_SERVLET_VERSION % "provided" //CDDL v1
  lazy val jetty = "org.eclipse.jetty" % "jetty-server" % JETTY_VERSION % "provided" //Eclipse license
  lazy val guicey = "org.guiceyfruit" % "guice-all" % "2.0" % "compile" //ApacheV2
  lazy val h2_lzf = "voldemort.store.compress" % "h2-lzf" % "1.0" % "compile" //ApacheV2
  lazy val jackson = "org.codehaus.jackson" % "jackson-mapper-asl" % JACKSON_VERSION % "compile" //ApacheV2
  lazy val jackson_core = "org.codehaus.jackson" % "jackson-core-asl" % JACKSON_VERSION % "compile" //ApacheV2
  lazy val jersey_server = "com.sun.jersey" % "jersey-server" % JERSEY_VERSION % "provided" //CDDL v1
  lazy val jsr250 = "javax.annotation" % "jsr250-api" % "1.0" % "compile" //CDDL v1
  lazy val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1" % "compile" //CDDL v1
  lazy val multiverse = "org.multiverse" % "multiverse-alpha" % MULTIVERSE_VERSION % "compile" //ApacheV2
  lazy val multiverse_test = "org.multiverse" % "multiverse-alpha" % MULTIVERSE_VERSION % "test" //ApacheV2
  lazy val netty = "org.jboss.netty" % "netty" % "3.2.4.Final" % "compile" //ApacheV2
  lazy val osgi_core = "org.osgi" % "org.osgi.core" % "4.2.0" //ApacheV2
  lazy val protobuf = "com.google.protobuf" % "protobuf-java" % "2.3.0" % "compile" //New BSD
  lazy val sjson = "net.debasishg" % "sjson_2.9.0" % "0.11" % "compile" //ApacheV2
  lazy val sjson_test = "net.debasishg" % "sjson_2.9.0" % "0.11" % "test" //ApacheV2
  lazy val slf4j = "org.slf4j" % "slf4j-api" % SLF4J_VERSION
  lazy val logback = "ch.qos.logback" % "logback-classic" % "0.9.28" % "runtime"
  // Test
  lazy val commons_coll = "commons-collections" % "commons-collections" % "3.2.1" % "test" //ApacheV2
  lazy val testJetty = "org.eclipse.jetty" % "jetty-server" % JETTY_VERSION % "test" //Eclipse license
  lazy val testJettyWebApp = "org.eclipse.jetty" % "jetty-webapp" % JETTY_VERSION % "test" //Eclipse license
  lazy val junit = "junit" % "junit" % "4.5" % "test" //Common Public License 1.0
  lazy val mockito = "org.mockito" % "mockito-all" % "1.8.1" % "test" //MIT
  lazy val scalatest = "org.scalatest" % "scalatest_2.9.0" % SCALATEST_VERSION % "test" //ApacheV2
  lazy val sbteclipse = "com.typesafe.sbteclipse" % "sbteclipse_2.8.1" % "1.1" extra ("sbtversion" -> "0.10.0")

  val Depns = Seq(
    aopalliance,
    aspectwerkz,
    commons_codec,
    commons_io,
    javax_servlet_30,
    jetty,
    guicey,
    h2_lzf,
    jackson,
    jackson_core,
    jersey_server,
    jsr250,
    jsr311,
    multiverse,
    multiverse_test,
    netty,
    osgi_core,
    protobuf,
    sjson,
    sjson_test,
    slf4j,
    logback,
    commons_coll,
    testJetty,
    testJettyWebApp,
    junit,
    mockito,
    scalatest,
    sbteclipse)
}
object AkkaBuild extends Build {
  import Settings._
  import Resolvers._

  lazy val akka = Project("akka", file("."), settings = buildSettings)
    .aggregate(
      akka_actor,
      akka_testkit,
      akka_actor_tests,
      akka_stm, akka_typed_actor,
      akka_remote, akka_http,
      akka_samples, akka_slf4j,
      akka_tutorials)

  lazy val akka_actor = Project("akka-actor", file("akka-actor"), settings = buildSettings)
  lazy val akka_testkit = Project("akka-testkit", file("akka-testkit"), settings = buildSettings) dependsOn (akka_actor)
  lazy val akka_actor_tests = Project("akka-actor-tests", file("akka-actor-tests"), settings = buildSettings) dependsOn (akka_testkit)
  lazy val akka_stm = Project("akka-stm", file("akka-stm"), settings = buildSettings) dependsOn (akka_actor)
  lazy val akka_typed_actor = Project("akka-typed-actor", file("akka-typed-actor"), settings = buildSettings) dependsOn (akka_stm, akka_actor_tests)
  lazy val akka_remote = Project("akka-remote", file("akka-remote"), settings = buildSettings) dependsOn (akka_typed_actor)
  lazy val akka_http = Project("akka-http", file("akka-http"), settings = buildSettings) dependsOn (akka_actor)
  lazy val akka_samples = Project("akka-samples", file("akka-samples"), settings = buildSettings)
  lazy val akka_slf4j = Project("akka-slf4j", file("akka-slf4j"), settings = buildSettings) dependsOn (akka_actor)
  lazy val akka_tutorials = Project("akka-tutorials", file("akka-tutorials"), settings = buildSettings) dependsOn (akka_actor)
}
4

1 回答 1

6

从您的问题中我不确定您使用的是 0.7.x 还是 0.10.x,但这是 0.10.x 的答案

将以下内容放入您的~/.sbt/plugins/build.sbt文件中

resolvers += {
  val typesafeRepoUrl = new java.net.URL("http://repo.typesafe.com/typesafe/releases")
  val pattern = Patterns(false, "[organisation]/[module]/[sbtversion]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]")
  Resolver.url("Typesafe Repository", typesafeRepoUrl)(pattern)
}

libraryDependencies <<= (libraryDependencies, sbtVersion) { (deps, version) => 
  deps :+ ("com.typesafe.sbteclipse" %% "sbteclipse" % "1.1" extra("sbtversion" -> version))
}
于 2011-07-04T04:59:40.483 回答