我想在我的java应用程序中连接JavaScript文件,这是基于play framework 2.5。
在plugins.sbt
中,我添加了以下代码:
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.8")
我还补充说:
resolvers += Resolver.url("SBT Plugins", url("https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
resolvers += Resolver.url("bintray-sbt-plugins", url("https://dl.bintray.com/sbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)
在Build.scala
我已添加:
pipelineStages := Seq(rjs)
当我运行>activator clean dist
时,我得到:
"rjs is undefined"
我尝试添加:
import com.typesafe.sbt.rjs.Import._
但rjs
中没有com.typesafe.sbt
个包。
Build.scala
import play.PlayScala
import sbt._
import Keys._
import play.Play.autoImport._
import com.typesafe.sbt._
import com.typesafe.sbt.web.SbtWeb
import de.johoop.jacoco4sbt.JacocoPlugin._
import com.typesafe.sbt.web.Import.pipelineStages
object ApplicationBuild extends Build {
def fromEnv(name: String) = System.getenv(name) match {
case null => None
case value => Some(value)
}
val appName = fromEnv("artifactId").getOrElse("BMT")
val appVersion = fromEnv("version").getOrElse("1.2-SNAPSHOT")
pipelineStages := Seq(rjs)
val appDependencies = Seq(
javaJdbc,
javaCore,
javaJpa,
javaWs,
cache,
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.5.Final",
"org.mockito" % "mockito-all" % "1.9.5" % "test",
"org.apache.poi" % "poi" % "3.9",
"org.apache.poi" % "poi-ooxml" % "3.9",
"org.json" % "json" % "20090211",
"commons-codec" % "commons-codec" % "1.9",
"org.apache.directory.api" % "api-all" % "1.0.0-M33" exclude("org.apache.directory.api", "api-ldap-schema-data"),
"org.apache.directory.server" % "apacheds-server-annotations" % "2.0.0-M15" % "test" exclude("org.apache.directory.api", "api-ldap-schema-data"),
"org.apache.directory.server" % "apacheds-test-framework" % "2.0.0-M15" % "test" exclude("org.apache.directory.api", "api-ldap-schema-data"),
"com.microsoft.windowsazure" % "microsoft-windowsazure-api" % "0.4.6"
)
val main = Project(appName, file(".")).enablePlugins(play.PlayJava,SbtWeb).settings(
version := appVersion,
libraryDependencies ++= appDependencies
)
}
我所知道的是如何在应用程序中安装sbt-rjs插件。
答案 0 :(得分:1)
您的Build.scala
项目存在多个问题:
您有不存在的导入,例如:
import play.PlayScala
// the correct import is play.sbt.PlayScala
import play.Play.autoImport._
// the correct import is play.sbt.Play.autoImport._
而且,这个,我想这会产生你的报告问题:
import com.typesafe.sbt._
问题在于rjs
是com.typesafe.sbt
的子包,然后在rjs
内使用Build.scala
实际引用包而不是您想要的配置。将上面的导入替换为:
import com.typesafe.sbt.rjs.SbtRjs.autoImport._
然后它将正确引用rjs
管道阶段。
你有:
enablePlugins(play.PlayJava,SbtWeb)
但play.PlayJava
不存在。正确的行是:
enablePlugins(play.sbt.PlayJava, SbtWeb)
为什么不使用build.sbt
代替。您的构建没有什么特别之处,build.sbt
会更简单:
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
javaJdbc,
javaCore,
javaJpa,
javaWs,
cache,
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.5.Final",
"org.mockito" % "mockito-all" % "1.9.5" % "test",
"org.apache.poi" % "poi" % "3.9",
"org.apache.poi" % "poi-ooxml" % "3.9",
"org.json" % "json" % "20090211",
"commons-codec" % "commons-codec" % "1.9",
"org.apache.directory.api" % "api-all" % "1.0.0-M33" exclude("org.apache.directory.api", "api-ldap-schema-data"),
"org.apache.directory.server" % "apacheds-server-annotations" % "2.0.0-M15" % "test" exclude("org.apache.directory.api", "api-ldap-schema-data"),
"org.apache.directory.server" % "apacheds-test-framework" % "2.0.0-M15" % "test" exclude("org.apache.directory.api", "api-ldap-schema-data"),
"com.microsoft.windowsazure" % "microsoft-windowsazure-api" % "0.4.6"
)
pipelineStages := Seq(rjs)
def fromEnv(name: String) = System.getenv(name) match {
case null => None
case value => Some(value)
}
name := fromEnv("artifactId").getOrElse("BMT")
version := fromEnv("artifactId").getOrElse("BMT")