the plugin.sbt can not add more than one plugins. - plugins

I use sbt with playframework and activator to build a webapp.
my sbt version is 0.13.0
I change the plugin.sbt file to:
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")
and then the error is:
F:\mysource\play-slick>sbt
F:\mysource\play-slick\project\plugins.sbt:9: error: eof expected but ';' found.
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")
^
[error] Error parsing expression. Ensure that settings are separated by blank lines.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
I want to know how to add more than one SbtPlugin in plugins.sbt?

In .sbt files, you must have a blank line between settings (note the error message, Ensure that settings are separated by blank lines.). So, it should be:
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.1")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")
For more details on .sbt files, see http://www.scala-sbt.org/0.13.1/docs/Getting-Started/Basic-Def.html.

Related

Why does sbt assembly fail with "Not a valid command: assembly"?

I installed Spark to C:\Spark1_6\spark-1.6.0-bin-hadoop2.6. After navigating to this path I am entering sbt assembly command and I am getting the following error message:
[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Expected ':'
[error] Not a valid key: assembly
[error] assembly
[error] ^
Here is my sbt project structure.
-Project101
-project
-build.properties
-plugins.sbt
-src
-build.sbt
Here is my build.sbt:
name := "Project101"
version := "1.0"
scalaVersion := "2.10.2"
libraryDependencies ++= Seq(
"org.apache.spark" % "spark-core_2.10" % "1.6.0" exclude ("org.apache.hadoop","hadoop-yarn-server-web-proxy"),
"org.apache.spark" % "spark-sql_2.10" % "1.6.0" exclude ("org.apache.hadoop","hadoop-yarn-server-web-proxy"),
"org.apache.spark" %% "spark-hive" % "1.6.0",
"org.apache.spark" %% "spark-streaming" % "1.6.0",
"org.apache.spark" %% "spark-streaming-kafka" % "1.6.0"
)
resolvers in Global ++= Seq(
"Sbt plugins" at "https://dl.bintray.com/sbt/sbt-plugin-releases",
"Maven Central Server" at "http://repo1.maven.org/maven2",
"TypeSafe Repository Releases" at "http://repo.typesafe.com/typesafe/releases/",
"TypeSafe Repository Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/"
)
Here is the plugins.sbt:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
sbt package command is working and able to create the jar file. But I had to execute sbt assembly command too but is not working.
Not a valid command: assembly
Whenever you face the error message, please make sure you're in the top-level directory of the project with the sbt-assembly plugin installed.
If you have a project in Project101 directory, make sure that project/plugins.sbt has the line in:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
With that, you should again be in Project101 directory and execute sbt assembly. That should execute the plugin to create an uber-jar.
As correctly stated in another answer, the issue is caused by running sbt assembly not from the project directory.
If you getting that issue within Docker container, make sure that your mounts are set correctly.
For example:
docker run ... -v $$PWD/:/<your Scala project directory here> -w /<your Scala project directory here> <your build image> bash -c "sbt assembly"

Scala code build with sbt assembly , failing

I am using sbt 0.13.7 and Scala 2.11.4 on a Windows machine to compile my code into a fat jar, that I eventually want to run on a Linux machine.
Below is my build.sbt file:
import AssemblyKeys._
name := "Simple Project"
version := "1.0"
organization := "com.myorg"
scalaVersion := "2.11.4"
libraryDependencies ++= Seq(
// Spark dependency
"org.apache.spark" % "spark-core_2.10" % "1.2.0" % "provided",
// Third party libraries
"net.sf.jopt-simple" % "jopt-simple" % "4.3",
"joda-time" % "joda-time" % "2.0"
)
libraryDependencies += Defaults.sbtPluginExtra("com.eed3si9n" % "sbt-assembly" % "0.7.2", "0.11.2", "2.9.1")
// This statement includes the assembly plugin capabilities
assemblySettings
// Configure jar named used with the assembly plug-in
jarName in assembly := "my-project-assembly.jar"
// A special option to exclude Scala itself form our assembly jar, since Spark
// already bundles Scala.
assemblyOption in assembly := (assemblyOption in assembly).value.copy(includeScala = false)
The error I am facing is:
build.sbt:16: error: type mismatch;
found : Seq[sbt.Project.Setting[_]]
required: sbt.internals.DslEntry
assemblySettings
^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
Are you using sbt-assembly 0.12.0? If so, you don't need assemblySettings any more since it's an auto plugin.
Edit:
You have to include
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
in project/*.sbt like project/assembly.sbt, not build.sbt.

Can't compile 2.2 to 2.3 Migration

I have been fighting with this for the past few hours and I haven't made any headway at all. It seems no matter what I do, I keep getting the same error.
java.lang.NoClassDefFoundError: play/Project$
My build.sbt
name := "appname"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
filters,
"org.postgresql" % "postgresql" % "9.3-1100-jdbc4",
"org.mindrot" % "jbcrypt" % "0.3m",
"org.webjars" %% "webjars-play" % "2.3.0-2",
"org.webjars" % "foundation" % "5.3.0",
"org.scalaj" %% "scalaj-http" % "0.3.16"
)
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.10.4"
I have also tried this build.sbt
object ApplicationBuild extends Build {
val appName = "appname"
val appVersion = "1.0-SNAPSHOT"
val appDependencies ++= Seq(
jdbc,
anorm,
cache,
filters,
"org.postgresql" % "postgresql" % "9.3-1100-jdbc4",
"org.mindrot" % "jbcrypt" % "0.3m",
"org.webjars" %% "webjars-play" % "2.3.0-2",
"org.webjars" % "foundation" % "5.3.0",
"org.scalaj" %% "scalaj-http" % "0.3.16"
)
val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings(
scalaVersion := "2.10.4",
version := appVersion,
libraryDependencies ++= appDependencies
)
}
As well as different tweaks and modifications. Always the same error. The build.properties is set to sbt.version=0.13.5
plugins.sbt
logLevel := Level.Debug
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.4")
After running Patrick Mahoney's suggestion and making sure I removed the import.
Errors:
[error] java.lang.NoClassDefFoundError: play/Project$
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? q
me#me-desktop:~/Projects/appname$ sbt --version
sbt launcher version 0.13.6
me#me-desktop:~/Projects/appname$ find . | grep -r "play.Project"
me#me-desktop:~/Projects/appname$ find . | grep -r "play/Project"
Try cleaning your build project compiled outputs:
rm -rf project/target
or
$> sbt "reload plugins" clean
(in addition to applying James' answer)
Thanks to James and Patrick, but I found the problem. The problem was in the activator-sbt-echo-play-shim.sbt file in the /project directory.
It contained the following:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "0.1.1.3")
I created a second blank 2.3.4 app using Activator and it's activator-sbt-echo-play-shim.sbt listed:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5")
So I updated the one in my project to 1.5 and deleted the idea and eclipse .sbts for good measure and the app was finally able to compile. It auotmatically updated the above to:
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.2")
Now I have other, more expected, issues I need to work out (like anorm). But I'm now able to compile it and get those errors to start working them out. I did not think these files were part of the activator/sbt compile, but I guess they were. I thought they were for debugging. But they made the difference and the changes above worked.
Thanks again to everyone for their help.
Make sure you've updated project/build.properties to have sbt version 0.13.5. Then, remove import play.Project._, it's not needed. That should work.

Run Play project from sbt

I am about to publish a Play project to github, but I would like that Scala developers don't need to install play separately if they already have sbt installed.
Would it be possible to compile and run a Play project with sbt if we add the correct dependencies ?
My working build.sbt for Play is here, but it doesn't work with sbt.
import play.Project._
name := "my_project_name"
version := "1.0"
libraryDependencies ++= Seq(
"com.netflix.rxjava" % "rxjava-scala" % "0.17.4",
"oauth.signpost" % "signpost-core" % "1.2.1.2",
"oauth.signpost" % "signpost-commonshttp4" % "1.2.1.2",
"org.apache.httpcomponents" % "httpclient" % "4.3.3",
"commons-io" % "commons-io" % "2.3"
)
playScalaSettings
Thanks!
You just should add the following line to project/plugins.sbt file:
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.3") // or your play version
play new does this by default.
You may check if the project is executable by sbt by executing sbt run from the terminal.

Play: error: not found: value playScalaSettings

I'm trying to create a new play application, myFirstApp, in Scala using sbt 0.12. I've build.sbt, in myFirstApp/ folder. I've also added plugins.sbt to myFirstApp/project/ folder.
Build.sbt
import play.Project._
name := "My first application"
version := "1.0"
playScalaSettings
plugins.sbt
// Typesafe snapshots
resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/"
resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0-M1")
build.properties
sbt.version=0.12.3
On executing sbt from myFirstApp folder, I get this error:
error: not found: value playScalaSettings
How do I get rid of it?
Just change
build.properties
sbt.version=0.13.0
and
plugins.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.3")
As of May 9th, 2014, last stable version for the plugin is 2.2.3. You can check Typesafe repo for current releases.
There is currently no SBT 0.12.x plugin for Play 2.2: http://repo.typesafe.com/typesafe/releases/com.typesafe.play/sbt-plugin/scala_2.10/
and I M1 is also not in the repo http://repo.typesafe.com/typesafe/releases/com.typesafe.play/sbt-plugin/scala_2.10/sbt_0.13/