Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Liftweb setup in 10 minutes - IDE and project configuration

DZone's Guide to

Liftweb setup in 10 minutes - IDE and project configuration

· Java Zone
Free Resource

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

Scala is one of the coolest programming languages out there and Lift is a revolutionary web framework that really leverages many scala features.

But it can be daunting at the beginning, even just getting your workspace setup. In this article I will go through the basic setup of your IDE, it really takes a few minutes!

Even though I've always been an Eclipse person I'm using IDEA IntelliJ with Scala cause I think is way superior. Ok let's begin. You will need IntelliJ 10.5.1, Maven or SBT.

Create the project with maven

First step is to create the project and for that we will use lift maven archetype. For the persistence layer we will use the default lift mapper. Run this command

mvn archetype:generate   -DarchetypeGroupId=net.liftweb   
-DarchetypeArtifactId=lift-archetype-basic_2.8.1
-DarchetypeVersion=2.3
-DarchetypeRepository=http:/scala-tools.org/repo-snapshots
-DremoteRepositories=http://scala-tools.org/repo-snapshots
-DgroupId=com.playamatch -DartifactId=web

You can also create a JPA based project running the same command with

archetypeArtifactId=lift-archetype-jpa-basic_2.8.1

You already have a full liftweb project! You can even run it with maven itself using the command

mvn jetty-run

Download and configure IntelliJ

Next open IntelliJ and install the scala plugin. You need to go to File -> Setting. This is where you can access all the configuration options. The equivalent of Window -> Preferences in eclipse.

Now go to the plugins, pick scala right click "Download and Install" and once done restart the IDE.

You should be able to see your code with syntax highlights and navigate through the classes already. If you want you can also download the SBT plugin for IDEA. In this tutorial I will use the command line.

Another configuration change you might want to do if you are coming from eclipse if the shortcuts. IDEA comes with an eclipse profile that will allow you to keep using all the handy shortcuts you've learned so far.



Configure SBT

I would recommend using SBT for your projects with the scala compiler is very fast ( well as fast as it gets really ;) ) Here I am using SBT 0.10.1

You need to create a build.sbt in the project root folder. This is what mine looks like, it is pretty much the standard dependencies.

/build.sbt

name := "liftplay"

scalaVersion := "2.8.1"

seq(webSettings: _*)



// If using JRebel uncomment next line
//jettyScanDirs := Nil


resolvers += "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"


libraryDependencies ++= {

val liftVersion = "2.3" // Put the current/latest lift version here

Seq(

"net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",

"net.liftweb" %% "lift-mapper" % liftVersion % "compile->default",

"net.liftweb" %% "lift-wizard" % liftVersion % "compile->default")

}



// Customize any further dependencies as desired

libraryDependencies ++= Seq(

"org.eclipse.jetty" % "jetty-webapp" % "7.3.0.v20110203" % "jetty", // For Jetty 7

//"org.mortbay.jetty" % "jetty" % "6.1.22" % "jetty,test", // For Jetty 6, add scope test to make jetty avl. for tests

"org.scala-tools.testing" % "specs_2.9.0" % "1.6.8" % "test", // For specs.org tests

"junit" % "junit" % "4.8" % "test->default", // For JUnit 4 testing

"javax.servlet" % "servlet-api" % "2.5" % "provided->default",

"com.h2database" % "h2" % "1.2.138", // In-process database, useful for development systems

"ch.qos.logback" % "logback-classic" % "0.9.26" % "compile->default" // Logging

)


 

Then create another file under project/plugins (create these folders in your root project directory if you don't have them) called again build.sbt


/project/plugins/build.sbt
resolvers ++= Seq(

"Web plugin repo" at "http://siasia.github.com/maven2",

Resolver.url("Typesafe repository", new java.net.URL("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns)

)



//Following means libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % "0.1.0-""

libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % ("0.1.0-"+v))

last file is the build.properties under the project folder

/project/build.properties
project.organization=com.playamatch
project.name=liftplay
project.version=1.0-SNAPSHOT
sbt.version=0.10.1
def.scala.version=2.8.1
build.scala.versions=2.8.1
project.initialize=false

That's it. All you need to do now is an update to download all the dependencies

Get dependencies and run application

sbt update

and then you can run your new application

sbt ~jetty-run

Enable Debug for your application

If you want to debug your application just add the following to your sbt script

Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005

and then create a remote application debug configuration from Run -> Edit configurations. First check your defaults are like this then click on the plus sign


and name your run configuration!

Happy coding!!!

From http://www.devinprogress.info/2011/08/liftweb-setup-in-10-minutes-ide-and.html

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}