[英]Unable to get sbt-rjs plugin imported in play application
I wanted to concatenate JavaScript files in my java application which is built on play framework 2.5. 我想在基于play框架2.5构建的Java应用程序中串联JavaScript文件。
In plugins.sbt
, I have added the below code: 在
plugins.sbt
,我添加了以下代码:
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.8")
I also added: 我还补充说:
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)
In Build.scala
I have added: 在
Build.scala
我添加了:
pipelineStages := Seq(rjs)
When I run >activator clean dist
I get: 当我运行
>activator clean dist
我得到:
"rjs is undefined"
I tried adding: 我尝试添加:
import com.typesafe.sbt.rjs.Import._
But there is no rjs
package in com.typesafe.sbt
. 但没有
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
)
}
What I know is how to get the sbt-rjs plugin installed in the application. 我所知道的是如何在应用程序中安装sbt-rjs插件。
There is more than one problem with your Build.scala
project: Build.scala
项目存在多个问题:
You have imports that do not exists, like: 您有不存在的导入,例如:
import play.PlayScala
// the correct import is play.sbt.PlayScala
import play.Play.autoImport._
// the correct import is play.sbt.Play.autoImport._
And also, this one, which I suppose is generating the problem your report: 而且,我想这会导致您的报告产生问题:
import com.typesafe.sbt._
Problem here is that rjs
is a subpackage of com.typesafe.sbt
and then using rjs
inside your Build.scala
actually references the package instead of the configuration you want. 这里的问题是,
rjs
是一个子包com.typesafe.sbt
,然后使用rjs
您的内部Build.scala
实际引用的包,而不是你想要的配置。 Replace the import above with: 将上面的导入替换为:
import com.typesafe.sbt.rjs.SbtRjs.autoImport._
And then it will properly reference the rjs
pipeline stage. 然后它将正确引用
rjs
管道阶段。
You have: 你有:
enablePlugins(play.PlayJava,SbtWeb)
But play.PlayJava
does not exists. 但是
play.PlayJava
不存在。 The correct line would be: 正确的行是:
enablePlugins(play.sbt.PlayJava, SbtWeb)
Why not to use build.sbt
instead. 为什么不使用
build.sbt
代替呢。 There is nothing special in your build and build.sbt
would be simpler: 您的build和
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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.