【发布时间】:2015-12-19 18:41:54
【问题描述】:
我正在尝试将我的 play 2.3.9 应用程序部署到 heroku。更新和下载库后,sbt 因一个奇怪的导入错误而失败,并显示以下错误消息:
remote: [info] Compiling 1 Scala source to /tmp/scala_buildpack_build_dir/project/target/scala-2.10/sbt-0.13/classes...
remote: /tmp/scala_buildpack_build_dir/modules/admin/build.sbt:0: error: not found: object $34400878e902ee641868
remote: import $34400878e902ee641868._
remote: ^
remote: [error] Type error in expression
remote: Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
remote: ! ERROR: Failed to run sbt!
该应用程序正在使用 3 个子模块,分别称为 admin、common 和 web,并且显然在 admin 模块的 build.sbt 文件上失败了。
管理模块的 build.sbt 文件部分由位于根模块的“项目”文件夹中的名为 Common.scala 的通用 scala 对象生成。 admin、common 和 web 子模块使用这个公共对象来共享公共构建属性。
管理员的 build.sbt:
Common.moduleSettings("admin")
lazy val common = (project in file("../common")).enablePlugins(PlayJava)
lazy val root = (project in file(".")).enablePlugins(PlayJava).enablePlugins(SbtWeb).dependsOn(common).aggregate(common)
Keys.fork in (Test) := false
libraryDependencies ++= Common.commonDependencies
Common.scala 文件:
import sbt._
import sbt.Keys._
import play.PlayImport._
import com.typesafe.sbt.web.SbtWeb.autoImport.{Assets, pipelineStages}
import com.typesafe.sbt.less.Import.LessKeys
import com.typesafe.sbt.rjs.Import.{rjs, RjsKeys}
import com.typesafe.sbt.digest.Import.digest
object Common {
def appName = "lcdp-1"
// Common settings for every project
def settings (theName: String) = Seq(
name := theName,
organization := "com.lcdp",
version := "1.0-SNAPSHOT",
scalaVersion := "2.11.6",
doc in Compile <<= target.map(_ / "none"),
scalacOptions ++= Seq("-feature", "-deprecation", "-unchecked", "-language:reflectiveCalls"),
resolvers += "sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/",
resolvers += "release repository" at "http://hakandilek.github.com/maven-repo/releases/",
resolvers += "snapshot repository" at "http://hakandilek.github.com/maven-repo/snapshots/"
)
// Settings for the app, i.e. the root project
val appSettings = settings(appName) ++: Seq(
javaOptions += s"-Dconfig.resource=root.conf"
)
// Settings for every module, i.e. for every subproject
def moduleSettings (module: String) = settings(module) ++: Seq(
javaOptions += s"-Dconfig.resource=$module.conf"
)
// Settings for every service, i.e. for admin and web subprojects
def serviceSettings (module: String) = moduleSettings(module) ++: Seq(
includeFilter in (Assets, LessKeys.less) := "*.less",
excludeFilter in (Assets, LessKeys.less) := "_*.less",
pipelineStages := Seq(rjs, digest),
RjsKeys.mainModule := s"main-$module"
)
val commonDependencies = Seq(
javaJdbc,
cache,
javaWs,
javaEbean,
"com.newrelic.agent.java" % "newrelic-agent" % "3.7.0",
"be.objectify" %% "deadbolt-java" % "2.3.3",
"com.typesafe.play" %% "play-mailer" % "2.4.1",
...
)
Scala 版本是 2.11.6,sbt 版本是 0.13.5
这个应用程序在我的本地主机上运行良好。所以我无法弄清楚这个 sbt 导入错误发生了什么......
【问题讨论】:
-
尝试使用工头在本地运行它?
-
你在
project/build.properties中配置了什么版本的 sbt。此外,可能需要检查您的modules/admin/build.sbt是否有杂散字符。但看起来 sbt 正在做一些奇怪的事情。 -
我刚刚添加了一些关于如何生成 build.sbt 文件的说明。 sbt 版本是 0.13.5
-
我建议升级 sbt。
标签: java scala heroku playframework sbt