source: Dev/branches/play-2.0.1/documentation/manual/gettingStarted/NewApplication.md @ 322

Last change on this file since 322 was 322, checked in by hendrikvanantwerpen, 13 years ago

Added Play! framework and application with Jena dependency. Working on
the basic things now (login/register), after that start implementing
our data model.

File size: 2.3 KB
Line 
1# Creating a new application
2
3## Create a new application with the play command
4
5The easiest way to create a new application is to use the `play new` command.
6
7```bash
8$ play new myFirstApp
9```
10
11This will ask for some information.
12
13- The application name (just for display, this name will be used later in several messages).
14- The template to use for this application. You can choose either a default Scala application, a default Java application, or an empty application.
15
16[[images/playNew.png]]
17
18> Note that choosing a template at this point does not imply that you can’t change language later. For example, you can create a new application using the default Java application template and start adding Scala code whenever you like.
19
20Once the application has been created you can use the `play` command again to enter the [[Play 2.0 console | PlayConsole]].
21
22```bash
23$ cd myFirstApp
24$ play
25```
26
27## Create a new application without having Play installed
28
29You can also create a new Play application without installing Play, by using sbt.
30
31> First install [[sbt 0.11.2 | https://github.com/harrah/xsbt/wiki/Getting-Started-Setup]] if needed.
32
33Just create a new directory for your new application and configure your sbt build script with two additions.
34
35In `project/plugins.sbt`, add:
36
37```scala
38// The Typesafe repository
39resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
40
41// Use the Play sbt plugin for Play projects
42addSbtPlugin("play" % "sbt-plugin" % "2.0")
43```
44
45Be sure to replace `2.0` here by the exact version you want to use. If you want to use a snapshot version, you will have to specify this additional resolver:
46
47```
48// Typesafe snapshots
49resolvers += "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/"
50```
51
52In `project/Build.scala`:
53
54```scala
55import sbt._
56import Keys._
57import PlayProject._
58 
59object ApplicationBuild extends Build {
60 
61  val appName         = "My first application"
62  val appVersion      = "1.0"
63 
64  val appDependencies = Nil
65 
66  val main = PlayProject(
67    appName, appVersion, appDependencies, mainLang = SCALA
68  )
69 
70}
71```
72
73You can then launch the sbt console in this directory:
74
75```bash
76$ cd myFirstApp
77$ sbt
78```
79
80sbt will load your project and fetch the dependencies.
81
82> **Next:** [[Anatomy of a Play 2.0 application | Anatomy]]
Note: See TracBrowser for help on using the repository browser.