Learning Lift - HelloLift Lesson 1

In this document we outline how to create a new lift project and deploy it on Jetty. The approach shown here is a temporary approach recommended for Windows developers. The preferred approach of using lifty is currently not working in the Windows environment.

Learning Something

Learning Something tutorials like this one are prepared while I am learning something new. Because I am a newbie at whatever I am learning, these tutorials tend to be very basic. They are step-by-step instructions prepared by a newbie. Consequently, they may not show the best way to do something. They just show how I understood things at the time. Still, I hope you will benefit from my sharing of these tutorials and I hope you will add comments where you know a better way so we can all learn from each other.

I hope you enjoy and benefit from the Learning Something tutorials. Enjoy!

Pre-requisites

You need to download and install Lift, Scala, SBTand Git Gui in order to follow this lesson.

Part 1: Create New Lift Project

Step 1.1: Create Working Directory

Create a working directory in which you want to store your Lift project. My working directory is c:\$work\lift projects.

Step 1.2: Clone Git Prototype Project from Git

Launch Git Gui and click the Clone Existing Repository link on the home screen (second link from top in the image below).

Git Gui will launch the Clone Existing Repository screen shown below.

Enter the following details in the available fields:

Source Location git://github.com/lift/lift_sbt_prototype.git

Target Directory: Enter the name of the directory you want Git Gui to create for your project. In our case, we want to call our project HelloLift, so let’s set our target directory name to c:\$work\lift projects\hellolift. Be sure that the subdirectory hellolift does not exist yet; Git Gui will create the directory for us.

Once you have entered the source and target information, the Git Gui screen should be similar to the image below.

Click the Clone button to clone the Lift prototype project to your working directory.

Git Gui displays a dialog box while it cloning the requested prototype project, as shown below.

Once the project is cloned Git Gui will display its main working window as shown below:

The Git Gui window title indicates that we are in the project directory of the hellolift project. Below the menu bar we can see that master is the current branch. Below the branch name, Git Gui shows any Unstaged Changes in this branch. Below that again, Git Gui shows any Staged Changes. Since we have not made any changes to the application both lists are empty at the moment.

Step 1.3: Explore our Application Files

Click Repository in the Git Gui menu bar and select Explore Working Copy. Git Gui will launch the project directory in an Explorer window as shown below.

As shown above, Git Gui has created our project directory hellolift in our target directory c:\$work\lift projects.

If you are curious feel free to navigate through the folders in the hellolift project directory to see the files Git has cloned for us.

Part 2: Deploy New Lift Project

Step 2.1: Open Command Prompt

Open a new command prompt as shown below.

Use the cd command to navigate to the project directory. In my case, the cd command is as follows:

    cd  c:\$work\lift projects\hellolift

You will need to adjust the cd command to use your project directory name.

Once you enter the above cd command and click enter, the command prompt should show that you are in the project directory as shown below:

Step 2.2: Launch SBT

We will use SBT (Simple Build Tool) to deploy the project. Type sbt and click enter at the command prompt as shown below.

Click the enter key and SBT will run as shown below.

Notice that SBT has retrieved 17 artifacts for us, recompiled and built our project all from one command. Also notice that the SBT command prompt is displayed (after the last info line). This lets us know that SBT is running and waiting for our next instruction.

Step 2.3: Run Update in SBT

At the SBT prompt type update and click enter. SBT will update your project to include the necessary files. Once update is complete you will see the command prompt as shown below. This will take some time (in my case 25 seconds) so be patient.

Step 2.4: Deploy the Application to Jetty

At the SBT prompt type jetty-run and click enter. SBT will deploy your application to the Jetty server. The command prompt should appear as shown below.

Our application is now running on the Jetty server. We will view the application in our browser in the next step.

As we can see from the information in the Command Prompt, jetty-run has been successful. A few lines above the success message, you can see that the users table has been created. All of this was done for us by Lift and SBT.

Step 2.5: Browse to our Application

Now that our application is running, let’s go take a look at it. Launch your favourite browser and point it to http://localhost:8080/ to view your application as shown in the image below.

Congratulations, you have successfully cloned the prototype project and got it running on the Jetty server at your local host.

Part 3: Where to from Here

As a next step, click around the menu in your new Web Application and see what’s available. Also, look around in the project directory and become familiar with the various parts that make up the application.

Enjoy!

 

Once your done, check out the appendix below and then go to HelloLift Lesson 2 when you are ready.

Appendix: Shutting Down

In case you are wondering, you can stop the Jetty server by entering jetty-stop in the Command Prompt window as shown below.

Once you have entered jetty-stop as shown above, click the enter key to stop server as shown below.

We are now back at the SBT prompt.

In case you are wondering, we can exit from the SBT prompt by typing exit at the SBT prompt as shown below.

Now click enter to submit the exit command as shown below.

As we can see in the image above our SBT session has completed and we are back at the Windows Command Prompt in our project directory. Typing exit and hitting enter from here will close the Windows Command Prompt.

 

 

 

 

 

 

 

Copyright 2010-2011, Hani Massoud. All rights reserved. Article copyright and all rights retained by the author.

Views: 260

Tags: Lift, Scala, Tutorial

Comments are closed for this blog post

Members

Featured Members

Ads

Get your business online and get more customers through the door!

© 2013   Created by Hani Massoud.

Badges  |  Report an Issue  |  Privacy Policy  |  Terms of Service