score:59
Update: In newer versions if IntelliJ IDEA, it is no longer necessary to create the module from play/activator. IntelliJ IDEA has now a really good support for SBT projects. If exists, delete all the idea related directories inside your project. Then in IntelliJ IDEA click File -> Open and choose your build.sbt file. That's all.
IntelliJ IDEA has a good integration for the Play Framework 2. Sometimes it jams, but most of the time it runs. I use it to run(single, all) tests, start or debug the play application and edit my code (o; And this all from within the IDE and without the sbt console.
Here is a short tutorial with the most important steps. Currently I use IntelliJ IDEA 12.1 with the newest Play Framework 2 and Scala plugins.
1. Create a new application
play new myapp
2. Create the IDE module
Start the play console:
cd newapp
play
Create the module:
idea with-sources=yes
exit
3. Configure the IDE
- Open the newly created project
- Open the module settings(select project and press F4)
- Add the Scala library to your project
- Select Modules->myapp->Dependencies
- Press the plus Icon and select Library(2)
- Add the Scala 2.10.0 Project Library
- Select the Compiler Library in the Scala Facet
- Select Facets->Scala(myapp)
- Set the Compiler library to Scala 2.10.0
- Fix the errors
- Select Modules->myapp-build->Dependencies->scala-2.9.2 and press the minus icon
- Select Libraries->Scala 2.9.2 and press the minus icon
- Fix the output Path for the myapp-build module
- Select Modules->myapp-build->Paths
- Append classes to the Output path(X:\projects\myapp\project\target\scala_2.9.2\classes)
- Append test-classes to the Test output path(X:\projects\myapp\project\target\scala_2.9.2\test-classes)
4. Run a test
Select the ApplicationSpec under the test directory and click Run 'ApplicationSpec' from the context menu. You should get an error that the compiled template could not be found. This is because the IDE doesn't compile the templates, but this can be done by run the application once. Also follow point 5 and then run the test again.
5. Run the application
Select a controller and click Run Play 2 App from context menu. This should start the application on address: http://localhost:9000/
.
6. Update dependencies
If you update your application dependencies then you must tell the IDE about this changes. Also after running the play update command you must close the IDE and remove some files from project directory. If you execute the play idea
command before removing the files, you get double dependencies in your play project.
Execute the following steps to update your dependencies:
- Run the
update
task from your play console - Remove the
.idea_modules
and.idea/libraries
directories - Run the
idea with-sources=yes
command in the play console - Run step 3 again
score:0
I usually used IntellijIDEA (version 12.0.4) only for Play Framework code editor because of:
- Auto saving feature by default
- Rather fast IntelliSense feature
- Dracula UI, it is an eye-pleasure for me
And I usually run and debug the apps with Play SBT console. It's reasonable fast. But, sometimes when executing play
command on console, I found that the loading-project-info task take too long time (nearly 10 minutes). I don't know why this sometimes happen, but overall the use of Play SBT console is my choice.
I'm doing that because there is usually should-not-be-the-problem-things intepreted as error like following :
The first time when I start learning Play Framework, I was facing such problem. So, at the end, I choose to use Play SBT console to run and debugging app then.
And sorry I cannot answer for the question number 2. Until now I only tried running and debugging play application. For testing purpose I've never tried before for Play 2.x.
score:3
Play console includes a fork of a sbt plugin named sbt-idea. The play's fork got a little lagged behind the original plugin, and has some problems in IntelliJ when you run play idea
. You can use the original plugin, which doesn't have any issues. In order to use this plugin in your play project, you need to..
1.Add the following lines to project/plugins.sbt
file: (the blank line in the middle is required)
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.1")
2.Run gen-idea
from the play console.
Source: stackoverflow.com
Related Query
- How to use IntelliJ with Play Framework and Scala
- How do I get Intellij IDEA 12.0 to work with Play Framework 2.1.0 app and Scala 2.10.0?
- How to use cdn url with play framework and scala for image display?
- How to use play-plugins-mailer with Play 2.3 and Scala 2.11?
- How to create an instance of a model with the ebean framework and scala in Play 2.2
- How to send email with attached file in scala and play framework (2.3.9) using activator?
- How to use Memcached with the Scala Play Framework 2.2?
- How can I use scala sources from a different location in a sbt project and also make it work with IntelliJ IDEA?
- How to log user credentials when authentication fails with Scala Play Framework and Silhouette
- How to log user credentials when authentication fails with Scala Play Framework and Silhouette
- How to use fcm(firebase cloud messaging) with scala play framework to send notification?
- How do you read the HTML content of an Atom feed with Scala and Play framework 2.0?
- One Play 2 Framework App - use both java and scala
- Which is best data access options available for Play framework with Scala and PostgreSQL?
- Dynamic SQL Parameters with Anorm and Scala Play Framework
- How to get Scala imports working in IntelliJ IDEA with the Play framework?
- How to know if a Scala file modified with IntelliJ Idea is saved and if it is checked into CVS?
- How to use my classes from Scala worksheet in IntelliJ CE with Scala plugin?
- How to show images using Play framework and Scala in the view page
- Debug not working with play framework activator, scala and eclipse
- How to set up play framework ApplicationLoader and Macwire to work with custom routes?
- How do you use play framework as a library, in a scala project
- Scala unused import statement with play framework in IntelliJ
- How to use the Play Framework with Google App Engine with locally installed Java 7?
- How to generate Scala setters and getters with IntelliJ IDEA
- How programmatically limit download speed on server with Scala and Play
- How do I create horizontal or vertical struts and glue for use with scala BoxPanel?
- Value and column operations in scala spark, how to use a value left of an operator with spark column?
- With Scala + sbt, how do you simultaneously allow IntelliJ builds and command line builds?
- How to use SORM framework with Play Framework?
More Query from same tag
- Integrate BigQuery with Spark
- How to proxy an HTTP method with play framework 2.5?
- lift-json, proguard and android
- Spark custom estimator access to Param[T]
- Apache httpclient not honouring proxy setting using setProxy
- What would be the good name for this operation?
- Using ClassTag to see if what I have is the same as the template type
- Using scala cats to check combination of non-empty fields
- A simple way to iterate over paginated reponse Http4s
- How to match case the undeprecated apply-method of scala.xml.Elem
- What is the use of this case of scalaz.Ordering?
- How does a play.api.mvc.Action actual return a Result?
- Scala difference between "+:" and "::"
- How to disable the method return type hint in IntellijIdea scala plugin
- Split a list into sublist based on element types in scala
- Why type inference works when applying currying in Scala?
- Scala: How to define the default value for a constructor parameter within the companion object?
- Scala mongodb transaction: How to rollback?
- How to access case class field annotation values
- Scala: Performing comparision on query output
- Transform 2 Scala Spark Dataframes and a Long value into a single JSON string
- Passing parameters with Map to Neo4j query Scala
- Why does Callable of ExecutorSrvice blocks the inner task? (from FP in Scala)
- why it raise a error when rdd use sortby with ordering
- how can i create Spark DataFrame From .Thrift file's struct Object
- Creating a Random Feature Array in Spark DataFrames
- spark parquet conversion issue with malformed lines in file
- Upgrade to Play Framework 2.2 Securesocial problems. There is no cache plugin registered
- Invariant default type for enums in Scala 3
- List files scala emr hdfs (csv file missing)