Как добавить плагин sbteclipse в SBT 0.10.x - PullRequest
7 голосов
/ 04 июля 2011

Я хочу посмотреть исходный код akka, и, похоже, он использует версию sbt 0.7.x.
Я преобразую конфигурацию проекта в версию 0.10.x. Когда я добавил sbteclipse в libraray-dependencies и запустил eclipse create-src для генерации проекта eclipse, он сказал, что eclipse - это не команда. Вот мой Build.scala. Sbteclipse_2.8.1.jar фактически существует, когда я использую библиотечные зависимости для вывода списка библиотек

Я делал глупую ошибку раньше. Определение плагина должно быть объявлено в файле project / plugins / build.sbt, а не как зависимость библиотеки в вашем проекте / 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 Ответ

6 голосов
/ 04 июля 2011

Я не был уверен из ваших вопросов, используете ли вы 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))
}
...