Archetypes

From LiftWiki

Jump to: navigation, search


Archetypes are templates for new project. So you could create a new lift app without need to checkout lift from svn, build lift,... Read the following section and choose your preferred way.


Contents

Archetypes list

lift-archetype-blank
To create a blank/empty liftweb project (nothing to remove)
lift-archetype-basic
To create a liftweb project with ORM,...
scala-archetype-simple
To create a simple scala project (not a webapp or lift project, the template is created with 2 tests, one pass and one fail to allow you check if "test run" works)

Result

Result of lift-archetype-blank

your-proj-id/
|-- pom.xml
`-- src
    |-- main
    |   |-- resources
    |   |-- scala
    |   |   |-- bootstrap
    |   |   |   `-- liftweb
    |   |   |       `-- Boot.scala
    |   |   `-- your
    |   |       `-- proj
    |   |           `-- gid
    |   |               |-- controller
    |   |               |-- model
    |   |               |-- snippet
    |   |               |   `-- HelloWorld.scala
    |   |               `-- view
    |   `-- webapp
    |       |-- WEB-INF
    |       |   `-- web.xml
    |       |-- index.html
    |       |-- scripts
    |       |   `-- jquery-1.2.1.js
    |       `-- templates-hidden
    |           `-- default.html
    `-- test
        |-- resources
        `-- scala
            |-- LiftConsole.scala
            |-- RunWebApp.scala
            `-- your
                `-- proj
                    `-- gid
                        `-- AppTest.scala

Using archetypes

from Shell (with maven)

To create a new project from an archetype :

  1. prerequis :
    • install maven (>= 2.0.7)
  2. cd the parent directory where to create your project
  3. copy/paste one of following command (see the list at the end of this page for description)
  4. set in last line your groupId and artifactId (-DgroupId=your.proj.gid -DartifactId=your-proj-id)
  5. [return] to execute
  6. now you have a project to start working/playing

For a new lift project with nothing extra:

mvn archetype:generate -U                                     \
 -DarchetypeGroupId=net.liftweb                             \
 -DarchetypeArtifactId=lift-archetype-blank                 \
 -DarchetypeVersion=1.0.2                            \
 -DremoteRepositories=http://scala-tools.org/repo-releases  \
 -DgroupId=your.proj.gid -DartifactId=your-proj-id

For a new lift project with extras such as a default derby database, User model, basic stylings:

mvn archetype:create -U  \
 -DarchetypeGroupId=net.liftweb                             \
 -DarchetypeArtifactId=lift-archetype-basic                 \
 -DarchetypeVersion=1.0.2                            \
 -DremoteRepositories=http://scala-tools.org/repo-releases  \
 -DgroupId=your.proj.gid -DartifactId=your-proj-id
mvn archetype:create                                         \
  -DarchetypeGroupId=org.scala-tools.archetypes              \
  -DarchetypeArtifactId=scala-archetype-simple               \
  -DarchetypeVersion=1.2                                     \
  -DremoteRepositories=http://scala-tools.org/repo-releases  \
  -DgroupId=your.proj.gid -DartifactId=your-proj-id         

from Shell (with archy)

Archy is a simple, command-line frontend to Maven 2's Archetypes. It walks you through the process of creating a new project using these project templates.

  1. prerequis
    • install archy
  2. run archy
 java -jar archy.jar
  1. select or write the name of the archetype (version outdated, wait for the next lift release)

Archetypes are registered into the default List

from Q4E

Q4E is a maven plugin for eclipse (the following list allow to create eclipse project from archetype).

  1. prerequis :
    1. install Eclipse
    2. install Q4E
  2. Eclipse File > New > Project...
  3. Select Maven 2 Project>Maven 2 Project Creation Wizard
  4. Set the name and the location
  5. Select your archetype
  6. ... follow wizard

Archetypes are registered into the default List

see Q4E:How to create a new archetype list for more information.

Personal tools
search|search