1 | # Setting up your preferred IDE |
---|
2 | |
---|
3 | Working with Play is easy. You donât even need a sophisticated IDE, because Play compiles and refreshes the modifications you make to your source files automatically, so you can easily work using a simple text editor. |
---|
4 | |
---|
5 | However, using a modern Java or Scala IDE provides cool productivity features like auto-completion, on-the-fly compilation, assisted refactoring and debugging. |
---|
6 | |
---|
7 | ## Eclipse |
---|
8 | |
---|
9 | ### Generate configuration |
---|
10 | |
---|
11 | Play provides a command to simplify Eclipse configuration. To transform a Play application into a working Eclipse project, use the `eclipsify` command: |
---|
12 | |
---|
13 | without the source jars: |
---|
14 | |
---|
15 | ``` |
---|
16 | [My first application] $ eclipsify |
---|
17 | ``` |
---|
18 | |
---|
19 | if you want to grab the available source jars (this will take longer and it's possible a few sources might be missing): |
---|
20 | |
---|
21 | ``` |
---|
22 | [My first application] $ eclipsify with-source=true |
---|
23 | ``` |
---|
24 | |
---|
25 | |
---|
26 | |
---|
27 | You then need to import the application into your Workspace with the **File/Import/General/Existing projectâŠ** menu (compile your project first). |
---|
28 | |
---|
29 | [[images/eclipse.png]] |
---|
30 | |
---|
31 | You can also start your application with `play debug run` and then you can use the Connect JPDA launcher using **Debug As** to start a debugging session at any time. Stopping the debugging session will not stop the server. |
---|
32 | |
---|
33 | |
---|
34 | > **Tip**: You can run your application using `~run` to enable direct compilation on file change. This way scala templates files are auto discovered when you create new template in `view` and auto compiled when file change. If you use normal `run` then you have to hit `Refresh` on you browser each time. |
---|
35 | |
---|
36 | If you make any important changes to your application, such as changing the classpath, use `eclipse` again to regenerate the configuration files. |
---|
37 | |
---|
38 | > **Tip**: Do not commit Eclipse configuration files when you work in a team! |
---|
39 | |
---|
40 | The generated configuration files contain absolute references to your framework installation. These are specific to your own installation. When you work in a team, each developer must keep his Eclipse configuration files private. |
---|
41 | |
---|
42 | ## IntelliJ |
---|
43 | |
---|
44 | ### Generate configuration |
---|
45 | |
---|
46 | Play provides a command to simplify Intellij IDEA configuration. To transform a Play application into a working IDEA module, use the idea command: |
---|
47 | |
---|
48 | without the source jars: |
---|
49 | |
---|
50 | ``` |
---|
51 | [My first application] $ idea |
---|
52 | ``` |
---|
53 | |
---|
54 | if you want to grab the available source jars (this will take longer and it's possible a few sources might be missing): |
---|
55 | |
---|
56 | ``` |
---|
57 | [My first application] $ idea with-sources |
---|
58 | ``` |
---|
59 | |
---|
60 | You then need to import the application into your project (File->New Module->Import existing Module) |
---|
61 | |
---|
62 | [[images/idea.png]] |
---|
63 | |
---|
64 | > Tip: There is an [Intellij IDEA issue](http://devnet.jetbrains.net/thread/433870) regarding building Java based Play2 apps while having the Scala plugin installed. Until it's fixed, the recommended workaround is to disable the Scala plugin. |
---|
65 | |
---|
66 | To debug, first add a debug configuration |
---|
67 | |
---|
68 | - Open Run/Debug Configurations dialog, then click Run -> Edit Configurations |
---|
69 | - Add a Remote configuration, then select `Remote` |
---|
70 | - Configure it: |
---|
71 | - Set a name |
---|
72 | - Transport: Socket |
---|
73 | - Debugger mode: Attach |
---|
74 | - Host: localhost |
---|
75 | - Port: 9999 |
---|
76 | - Select module you imported |
---|
77 | - Close dialog - click Apply |
---|
78 | |
---|
79 | Start play in debug mode: |
---|
80 | |
---|
81 | ``` |
---|
82 | $ play debug |
---|
83 | ``` |
---|
84 | |
---|
85 | which should print: |
---|
86 | |
---|
87 | ``` |
---|
88 | Listening for transport dt_socket at address: 9999 |
---|
89 | ``` |
---|
90 | |
---|
91 | Set some breakpoints. Run the web app by executing the task `play` (again I had to do this in same terminal I ran `play debug`). Finally, browse `http://localhost:9000`. IntelliJ should stop at your breakpoint. |
---|
92 | |
---|
93 | If you make any important changes to your application, such as changing the classpath, use `idea` again to regenerate the configuration files. |
---|
94 | |
---|
95 | |
---|
96 | ## Netbeans |
---|
97 | |
---|
98 | ### Generate Configuration |
---|
99 | |
---|
100 | Play does not have native Netbeans project generation support at this time. For now you can generate a Netbeans Scala project with the [Netbeans SBT plugin](https://github.com/remeniuk/sbt-netbeans-plugin). |
---|
101 | |
---|
102 | First edit the plugins.sbt file |
---|
103 | |
---|
104 | ``` |
---|
105 | resolvers += { |
---|
106 | "remeniuk repo" at "http://remeniuk.github.com/maven" |
---|
107 | } |
---|
108 | |
---|
109 | libraryDependencies += { |
---|
110 | "org.netbeans" %% "sbt-netbeans-plugin" % "0.1.4" |
---|
111 | } |
---|
112 | ``` |
---|
113 | |
---|
114 | Now run |
---|
115 | |
---|
116 | ``` |
---|
117 | $ play netbeans |
---|
118 | ``` |
---|
119 | |
---|
120 | > **Next:** |
---|
121 | > |
---|
122 | > â [[Play 2.0 for Scala developers|ScalaHome]] |
---|
123 | > â [[Play 2.0 for Java developers|JavaHome]] |
---|