<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mariano Guerra's Log (Publicaciones sobre scala)</title><link>http://marianoguerra.org/</link><description></description><atom:link href="http://marianoguerra.org/es/categories/scala.xml" rel="self" type="application/rss+xml"></atom:link><language>es</language><lastBuildDate>Mon, 18 Nov 2024 17:56:41 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>lift 2.4-M4, scala 2.9.1, sbt 0.11.0-RC0, jetty 7.3 and xsbt-web-plugin 0.1.1</title><link>http://marianoguerra.org/es/posts/201109lift-24-m4-scala-291-sbt-0110-rc0-jetty/</link><dc:creator>Mariano Guerra</dc:creator><description>&lt;div class="document"&gt;&lt;div class="section" id="lift-2-4-m4-scala-2-9-1-sbt-0-11-0-rc0-jetty-7-3-and-xsbt-web-plugin-0-1-1"&gt;&lt;h1&gt;installing sbt 0.11.0-RC0&lt;/h1&gt;&lt;/div&gt;&lt;div class="section" id="installing-sbt-0-11-0-rc0"&gt;run the following commands:&lt;br&gt;&lt;pre class="literal-block"&gt;# go to your home directory&lt;br&gt;cd&lt;br&gt;&lt;br&gt;# create a bin folder there (if you don't have it yet)&lt;br&gt;mkdir bin&lt;br&gt;&lt;br&gt;# download the latest sbt&lt;br&gt;wget http://repo.typesafe.com/typesafe/ivy-snapshots/org.scala-tools.sbt/sbt-launch/0.11.0-RC1/sbt-launch.jar&lt;br&gt;&lt;/pre&gt;now we need to create a launcher for sbt, create a file called sbt in the bin directory you just created and put the following inside:&lt;br&gt;&lt;pre class="literal-block"&gt;java -Xmx512M -jar `dirname $0`/sbt-launch.jar "$@"&lt;br&gt;&lt;/pre&gt;now run the following commands:&lt;br&gt;&lt;pre class="literal-block"&gt;# give execution permissions to the file&lt;br&gt;chmod u+x sbt&lt;br&gt;&lt;/pre&gt;if you don't have $HOME/bin in your path variable you should add it, for this do the following:&lt;br&gt;&lt;pre class="literal-block"&gt;# open $HOME/.bashrc in your favorite text editor&lt;br&gt;vim $HOME/.bashrc&lt;br&gt;&lt;/pre&gt;and add the following line at the end of it:&lt;br&gt;&lt;pre class="literal-block"&gt;export PATH=$PATH:$HOME/bin&lt;br&gt;&lt;/pre&gt;save and close and run the shell again so it loads the new definitions:&lt;br&gt;&lt;pre class="literal-block"&gt;bash&lt;br&gt;&lt;/pre&gt;you can check that the path was updated by running:&lt;br&gt;&lt;pre class="literal-block"&gt;echo $PATH&lt;br&gt;&lt;/pre&gt;you should see something similar to this:&lt;br&gt;&lt;pre class="literal-block"&gt;/sbin:/bin:/usr/sbin:/usr/bin:/home/test/bin&lt;br&gt;&lt;/pre&gt;see that the last one is $HOME/bin (with $HOME expanded to my current home location)&lt;/div&gt;&lt;div class="section" id="installing-scala-2-9-1"&gt;&lt;h1&gt;installing scala 2.9.1&lt;/h1&gt;if your operating system has this in the package manager then install it from there but since the release is new and some distributions are a little behing we will install it from the download section of the scala site.&lt;br&gt;run the following commands:&lt;br&gt;&lt;pre class="literal-block"&gt;# download the latest version of scala&lt;br&gt;wget http://www.scala-lang.org/downloads/distrib/files/scala-2.9.1.final.tgz&lt;br&gt;&lt;br&gt;# unpack it&lt;br&gt;tar -xzf scala-2.9.1.final.tgz&lt;br&gt;&lt;br&gt;# move the folder to the standard place&lt;br&gt;sudo mv scala-2.9.1.final /usr/share/scala&lt;br&gt;&lt;br&gt;# create links so the commands are visible&lt;br&gt;sudo ln -s /usr/share/scala/bin/scala /usr/bin/scala&lt;br&gt;sudo ln -s /usr/share/scala/bin/scalac /usr/bin/scalac&lt;br&gt;sudo ln -s /usr/share/scala/bin/fsc /usr/bin/fsc&lt;br&gt;sudo ln -s /usr/share/scala/bin/sbaz /usr/bin/sbaz&lt;br&gt;sudo ln -s /usr/share/scala/bin/sbaz-setup /usr/bin/sbaz-setup&lt;br&gt;sudo ln -s /usr/share/scala/bin/scaladoc /usr/bin/scaladoc&lt;br&gt;sudo ln -s /usr/share/scala/bin/scalap /usr/bin/scalap&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="section" id="installing-the-rest"&gt;&lt;h1&gt;installing the rest&lt;/h1&gt;first create the project folder and setup the structure:&lt;br&gt;&lt;pre class="literal-block"&gt;# define the name of the project&lt;br&gt;PROJNAME=demo&lt;br&gt;&lt;br&gt;# create the direcotry where our project will be&lt;br&gt;mkdir $PROJNAME&lt;br&gt;&lt;br&gt;# get the latest lift with sbt support&lt;br&gt;wget https://nodeload.github.com/lift/lift_24_sbt/tarball/master&lt;br&gt;&lt;br&gt;# extract lift&lt;br&gt;tar -xzf master&lt;br&gt;&lt;br&gt;# remove the downloaded file&lt;br&gt;rm master&lt;br&gt;&lt;br&gt;# copy the basic example to our project directory&lt;br&gt;cp -r lift-lift_24_sbt-*/scala_29/lift_basic/* $PROJNAME&lt;br&gt;&lt;br&gt;# move to our project folder&lt;br&gt;cd $PROJNAME&lt;br&gt;&lt;br&gt;# remove older sbt versions&lt;br&gt;rm sbt sbt.bat sbt-launcher.jar&lt;br&gt;&lt;br&gt;# remove the project structure&lt;br&gt;rm -r project/&lt;br&gt;&lt;br&gt;# create the new project structure&lt;br&gt;mkdir -p project/project&lt;br&gt;&lt;/pre&gt;the change in the project directory structure is because it changed in sbt 0.11, see more about this here:&lt;br&gt;&lt;a class="reference external" href="https://groups.google.com/forum/#%21searchin/simple-build-tool/plugins/simple-build-tool/ep_63fA_Gzk/32xiPzGkCqAJ"&gt;https://groups.google.com/forum/#!searchin/simple-build-tool/plugins/simple-build-tool/ep_63fA_Gzk/32xiPzGkCqAJ&lt;/a&gt;&lt;br&gt;create a file at $PROJNAME/build.sbt:&lt;br&gt;&lt;pre class="literal-block"&gt;vim build.sbt&lt;br&gt;&lt;/pre&gt;with the following content:&lt;br&gt;&lt;pre class="literal-block"&gt;seq(webSettings :_*)&lt;br&gt;&lt;br&gt;scalaVersion := "2.9.1"&lt;br&gt;&lt;br&gt;libraryDependencies ++= Seq(&lt;br&gt;        "net.liftweb" %% "lift-webkit" % "2.4-M4" % "compile",&lt;br&gt;        "net.liftweb" %% "lift-mapper" % "2.4-M4" % "compile",&lt;br&gt;        "org.eclipse.jetty" % "jetty-webapp" % "7.5.1.v20110908" % "jetty",&lt;br&gt;        "junit" % "junit" % "4.8" % "test",&lt;br&gt;        "ch.qos.logback" % "logback-classic" % "0.9.26",&lt;br&gt;        "org.scala-tools.testing" %% "specs" % "1.6.9" % "test",&lt;br&gt;        "com.h2database" % "h2" % "1.3.160"&lt;br&gt;)&lt;br&gt;&lt;/pre&gt;create a file at $PROJNAME/project/plugins.sbt:&lt;br&gt;&lt;pre class="literal-block"&gt;vim project/plugins.sbt&lt;br&gt;&lt;/pre&gt;with the following content:&lt;br&gt;&lt;pre class="literal-block"&gt;resolvers ++= Seq(&lt;br&gt;        "Web plugin repo" at "http://siasia.github.com/maven2",&lt;br&gt;        Resolver.url("Typesafe repository", new java.net.URL("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns)&lt;br&gt;)&lt;br&gt;&lt;br&gt;addSbtPlugin("com.github.siasia" % "xsbt-web-plugin" % "0.1.1")&lt;br&gt;&lt;/pre&gt;now run:&lt;br&gt;&lt;pre class="literal-block"&gt;sbt&lt;br&gt;&lt;/pre&gt;when you get to the console write:&lt;br&gt;&lt;pre class="literal-block"&gt;jetty-run&lt;br&gt;&lt;/pre&gt;note that the first time it will take a while, that's because it's downloading lot of stuff and compiling some other things, after the first run everything becomes faster.&lt;br&gt;after a moment some information will appear, after that navigate to:&lt;br&gt;&lt;pre class="literal-block"&gt;http://localhost:8080&lt;br&gt;&lt;/pre&gt;and play with the app.&lt;/div&gt;&lt;div class="section" id="generating-a-war-file-to-deploy-in-web-containers"&gt;&lt;h1&gt;generating a war file to deploy in web containers&lt;/h1&gt;just run:&lt;br&gt;&lt;pre class="literal-block"&gt;sbt package-war&lt;br&gt;&lt;/pre&gt;to test you can run:&lt;br&gt;&lt;pre class="literal-block"&gt;sbt test&lt;br&gt;&lt;/pre&gt;note that the new version of jetty changed namespace from org.mortbay.* to org.eclipse.* so some code may be broken.&lt;/div&gt;&lt;div class="section" id="some-extra-packages"&gt;&lt;h1&gt;some extra packages&lt;/h1&gt;here are some other packages you may want to have, copy the lines your are interested in and add them to $PROJNAME/build.sbt:&lt;br&gt;&lt;pre class="literal-block"&gt;libraryDependencies ++= Seq(&lt;br&gt;    "com.novocode" % "junit-interface" % "0.6" % "test-&amp;gt;default",&lt;br&gt;    "org.scalatest" % "scalatest_2.9.0" % "1.6.1",&lt;br&gt;    "com.sun.jersey" % "jersey-server" % "1.9",&lt;br&gt;    "com.sun.jersey" % "jersey-client" % "1.9",&lt;br&gt;    "com.sun.jersey" % "jersey-core" % "1.9",&lt;br&gt;    "com.sun.jersey" % "jersey-json" % "1.9",&lt;br&gt;    "javax.ws.rs" % "jsr311-api" % "1.1.1",&lt;br&gt;    "javax.xml.bind" % "jaxb-api" % "2.2"&lt;br&gt;)&lt;br&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</description><guid>http://marianoguerra.org/es/posts/201109lift-24-m4-scala-291-sbt-0110-rc0-jetty/</guid><pubDate>Fri, 23 Sep 2011 09:50:00 GMT</pubDate></item></channel></rss>