4

I am new to play framework(Scala),I created a new project using activator new sample play-scala command, sample is my project name.Then I successfully ran a project using activator run command .When I ran a activator eclipse command it showed

[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse
[error] Expected ':'
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse

So from some internet suggestions I added
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")

this line into my sample project's plugins.sbt file.This fixed the not a valid command error but When I imported a project into eclipse it showed a object index is not a member of package views.html error please help me to fix the error

plugins.sbt

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.0")

// web plugins

addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")

addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")

addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")

enter image description here

Jamal
  • 976
  • 2
  • 14
  • 39

6 Answers6

1

create a new file plugins.sbt inside the project folder.

Sample directory path

C:\Workspace\PlayFramework\activator-1.3.6-minimal\play-java-intro\project\

Add the below content to the file

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

Then run the eclipse command

activator eclipse

This worked for me without any issues.

Shamnad P S
  • 1,095
  • 2
  • 15
  • 43
0

under your project folder does \project\build.sbt or \project\plugins.sbt existed? if not exist, you need to manualy create one.

similar issue Installing sbteclipse

Community
  • 1
  • 1
wherby
  • 704
  • 1
  • 5
  • 16
  • I have `\project\plugins.sbt` in my project. I edited this question with `plugins.sbt` file please have a check on. – Jamal Jun 01 '15 at 06:09
  • If you have plugin.sbt then you needn't add anything for that. If you run "activator eclipse" has some error, then clean the folders(.ivy2) and rerun the command. first you need to make sure the "activator eclipse" has no error. – wherby Jun 01 '15 at 11:59
  • how to clean a project folder? what is meant by .ivy2? – Jamal Jun 01 '15 at 13:48
  • .ivy2 is the hidden folder in your home folder, if you using linux like system, you need to use "ls -a" to display it. The folder is used to cache java and scala packages. If you run "activator eclipse" has error message for package download error, you remove the folder and redo the action may resolve the issue. First of all, make sure "activator eclipse" has no error. Then import the project using eclipse. – wherby Jun 01 '15 at 13:51
  • I am using Windows machine, If I use `addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")` It shows `[error] (*:update) sbt.ResolveException: unresolved dependency: com.typesafe.sbt eclipse#sbteclipse-plugin;4.0.0: not found` exception – Jamal Jun 01 '15 at 14:28
  • When I used `addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "3.0.0") ` It ran activator eclipse command successfully but showed a `object index is not a member of package views.html` error – Jamal Jun 01 '15 at 14:33
  • That's a known issue for sbt . You should add "EclipseKeys.createSrc := EclipseCreateSrc.All" to your plugin.sbt, and rerun "activator eclipse" after that reopen the eclipse, may fix the issue. – wherby Jun 01 '15 at 15:14
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/79335/discussion-between-jamal-and-wherby). – Jamal Jun 01 '15 at 15:18
  • 1
    Your project I opened with latest Scala IDE 4.1 then the error occur, and I open with Scala IDE 3.0.4, every thing goes fine. Though there has error, you also could run the project using "activator run" to start your project. It's not a code level issue, it is only IDE bug. If you can't download old Scala version, I suggest you using Intellij as IDE. – wherby Jun 02 '15 at 07:21
0

I had the same problem a long time ago. The solution was to create following two directories (at least one did not exist yet):

target/scala-2.11/src_managed/main
target/scala-2.11/twirl/main

I can't remember where I found the solution (or what the explanation of the error message was) but I hope this helps.

BTW, what's your ScalaIDE version? I currently use 4.1.0 and I don't see this issue anymore.

Update:

I created a new play project and suddenly encountered the same issue myself. There is an older thread dealing with this problem but unfortunately without any generally accepted solution.

The solution that worked or me was to update the project's Java Build Path and add these two source folders:

target/scala-2.11/routes/main
target/scala-2.11/twirl/main
Community
  • 1
  • 1
goerlitz
  • 505
  • 4
  • 15
  • I have both directories in my `target/scala-2.11/src_managed/main` `target/scala-2.11/twirl/main` project target folder. but target/scala-2.11/src_managed/main folder is empty it doesnt contains anything.target/scala-2.11/twirl/main folder conatins folder with the name `views` `views/html/` conatins both files namely `index.template.scala` and `maintemplate.scala` Scala IDE version:4.3.0 – Jamal Jun 01 '15 at 05:24
  • Folders should be okay then. (I just realized that my initial play project does not have the src_managed folder). – goerlitz Jun 01 '15 at 18:44
  • Concerning the IDE version: 4.3.0 is your eclipse version and I was actually referring to the stand-alone ScalaIDE version (4.1.0 final is just a week old). You may want to give ScalaIDE a try. But if you want to stick with eclipse + Scala plugin I would suggest to update both eclipse and the scala plugin. – goerlitz Jun 01 '15 at 18:50
0

Try $ activator clean compile and then refresh project in Eclipse Package Explorer. After this action Eclipse will be in sync with project files.

Alex Karasev
  • 1,108
  • 2
  • 13
  • 24
0

I found adding the plugin to the project directory didn't work for me.. dont know why.. (I'm using activator 0.13).

What I did...

create a directory called /.sbt/0.13/plugins create a file called /.sbt/0.13/plugins/plugins.sbt

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")

that worked.. the 2.5 version is super old.. so probably 4.0.0 or something would be better.

Duane
  • 4,572
  • 6
  • 32
  • 33
0

i had the same issue upgrading from play 2.3 to play 2.5, just added addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0") to plugins.sbt but still having error Not a valid command: eclipse

So i realized that i had another sbt file under /project 'activator-sbt-eclipse-shim.sbt', i don't know why it was there but it was using and old version addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.3.0")

i just changed that file to the right version and it worked

LuizAsFight
  • 222
  • 1
  • 7