如何将sbteclipse插件添加到SBT 0.10.x.

时间:2011-07-04 00:51:44

标签: eclipse scala sbt akka

我想查看akka的源代码,似乎使用0.7.x版本的sbt。
我将项目配置转换为0.10.x版本。当我在libraray-dependencies中添加sbteclipse并运行eclipse create-src来生成eclipse项目时,它告诉eclipse不是命令。这是我的Build.scala。当我使用库依赖项列出库

时,sbteclipse_2.8.1.jar实际上是存在的

我之前犯了一个愚蠢的错误。插件定义应在project / plugins / build.sbt文件中声明,而不是作为projectproject / 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)
}

1 个答案:

答案 0 :(得分: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))
}