Playframework 2.3.9 sbt on on heroku导入失败

时间:2015-09-22 17:05:04

标签: java scala heroku playframework sbt

我正在尝试将我的游戏2.3.9应用程序部署到heroku。在更新和下载libs之后,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文件中失败。

admin模块的build.sbt文件部分由托管在根模块的“project”文件夹中的名为Common.scala的公共scala对象生成。 admin,common和web子模块使用此公共对象来共享公共构建属性。

Admin的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 verison是2.11.6,sbt版本是0.13.5

此应用在我的localhost上运行良好。所以我无法弄清楚这个sbt导入错误发生了什么......

1 个答案:

答案 0 :(得分:1)

事实上我的应用程序需要在编译之前进行清理。执行heroku config:set SBT_CLEAN=true将强制sbt在编译之前清除heroku上的工件。这解决了这个问题。