Interaction with a lift application from a console

5 views
Skip to first unread message

Oscar Picasso

unread,
Dec 9, 2007, 1:06:02 PM12/9/07
to lif...@googlegroups.com
Hi,

In Ruby on Rails you can interact directly with an application by launching a console.

Has lift such a feature?

Thank

Steve Jenson

unread,
Dec 9, 2007, 3:05:04 PM12/9/07
to lif...@googlegroups.com
Yes, we do.

All projects generated with new_proj come with a script/console under
your project's directory. If you used the archetypes to create your
project, you won't have this. DavidB is making something slicker using
Maven that the archetypes will use.

If you don't have these files, but have lift checked out of SVN, make
a script directory and copy liftweb/script/console and
liftweb/script/liftrepl.scala. Here are pointers to them in googlecode
in case you don't have lift checked out of SVN:
http://liftweb.googlecode.com/svn/trunk/liftweb/script/

Then in your project's base directory, run script/console

One warning: if you are using Derby, only one process can have Derby
running at a time. So either mvn jetty:run or script/console can be
running at one time. It won't harm your database if try to use both at
the same time, it'll simply fail.

Let me know if you have any issues with it.

Best,
Steve

Oscar Picasso

unread,
Dec 9, 2007, 4:31:15 PM12/9/07
to lif...@googlegroups.com
I remember now.

I used it when I generated a new project with new_proj. I got confused as I now generate new projects with the Maven archetype.

It didn't work out of the box, so to speak, when run from the project base directory.

I had to change the console script last line from:
... scala liftrepl.scala
to
... scala script/liftrepl.scala

Steve Jenson

unread,
Dec 9, 2007, 4:42:03 PM12/9/07
to lif...@googlegroups.com
Fixed. Thanks!

David Bernard

unread,
Dec 10, 2007, 3:21:35 AM12/10/07
to lif...@googlegroups.com
I espect to add this feature to maven-scala-plugin and release before the end of the week (so any scala project could use it). I already have a working version, but I would like to integrate arrow
support (navigating into history and edit line) through jline.

WARNING: the maven-scala-plugin will have some difference with the current scrip (Steve points)
* it only add into classpath jar (and its dependencies) declared into the pom, not the wall local maven repository (include all version of the same artifact - unstable)
* it won't need to install scala (required jar download automaticaly by maven)

Regards

/davidB

David Bernard

unread,
Dec 10, 2007, 3:30:01 AM12/10/07
to lif...@googlegroups.com
I forgot, IMHO in some/lot of cases, it's better to write test case or main classes (under src/test/scala) than using "console" mode:
* you could keep your dry (but not include them into the running test group, by creating main class, set a member of a package "sandbox" and exclude it when you search/run "official test", only for
manual run from IDE,...), it's a memory of your work without polute the main code
* it's easier to edit the code under ide, click "run" and re-edit/fix than using console.

Currently console is usefull to explore/try syntax because they is no incremental compilation into IDE/editor.

my 2cents

/davidB

David Pollak

unread,
Dec 10, 2007, 8:03:50 AM12/10/07
to lif...@googlegroups.com
On Dec 10, 2007 12:30 AM, David Bernard <dwa...@free.fr> wrote:

I forgot, IMHO in some/lot of cases, it's better to write test case or main classes (under src/test/scala) than using "console" mode:
* you could keep your dry (but not include them into the running test group, by creating main class, set a member of a package "sandbox" and exclude it when you search/run "official test", only for
manual run from IDE,...), it's a memory of your work without polute the main code
* it's easier to edit the code under ide, click "run" and re-edit/fix than using console.

Currently console is usefull to explore/try syntax because they is no incremental compilation into IDE/editor.

It's be interesting to optionally integrate the console with JavaRebel so that changes to the projects source would be immediately picked up.
 


my 2cents

/davidB
Collaborative Task Management http://much4.us

David Bernard

unread,
Dec 10, 2007, 8:03:49 AM12/10/07
to lif...@googlegroups.com
David Pollak wrote:
>
>
> On Dec 10, 2007 12:30 AM, David Bernard <dwa...@free.fr
> <mailto:dwa...@free.fr>> wrote:
>
>
> I forgot, IMHO in some/lot of cases, it's better to write test case
> or main classes (under src/test/scala) than using "console" mode:
> * you could keep your dry (but not include them into the running
> test group, by creating main class, set a member of a package
> "sandbox" and exclude it when you search/run "official test", only for
> manual run from IDE,...), it's a memory of your work without polute
> the main code
> * it's easier to edit the code under ide, click "run" and
> re-edit/fix than using console.
>
> Currently console is usefull to explore/try syntax because they is
> no incremental compilation into IDE/editor.
>
>
> It's be interesting to optionally integrate the console with JavaRebel
> so that changes to the projects source would be immediately picked up.

Nice idea, but it'll be not part of the next release (too many things I want to do this week ;) )
But for after 2.2 (may be) I'll add it to my todo list. (add an issue into code.google (liftweb project) to avoid memory failure)

/davidB

David Pollak

unread,
Dec 10, 2007, 9:10:36 AM12/10/07
to lif...@googlegroups.com
On Dec 10, 2007 5:03 AM, David Bernard <dwa...@free.fr> wrote:

David Pollak wrote:
>
>
> On Dec 10, 2007 12:30 AM, David Bernard <dwa...@free.fr
> <mailto: dwa...@free.fr>> wrote:
>
>
>     I forgot, IMHO in some/lot of cases, it's better to write test case
>     or main classes (under src/test/scala) than using "console" mode:
>     * you could keep your dry (but not include them into the running
>     test group, by creating main class, set a member of a package
>     "sandbox" and exclude it when you search/run "official test", only for
>     manual run from IDE,...), it's a memory of your work without polute
>     the main code
>     * it's easier to edit the code under ide, click "run" and
>     re-edit/fix than using console.
>
>     Currently console is usefull to explore/try syntax because they is
>     no incremental compilation into IDE/editor.
>
>
> It's be interesting to optionally integrate the console with JavaRebel
> so that changes to the projects source would be immediately picked up.

Nice idea, but it'll be not part of the next release (too many things I want to do this week ;) )
But for after 2.2 (may be) I'll add it to my todo list. (add an issue into code.google (liftweb project) to avoid memory failure)

Definitely.  This is a wish-list for me.  Even if it doesn't make 0.4, it's fine. 

David Bernard

unread,
Dec 10, 2007, 8:22:01 AM12/10/07
to lif...@googlegroups.com
David,

If using javaRebel is only to modify jvmargs, it should be possible with maven-scala-plugin-2.2 through configuration.
(Somethings that accelerate things: could you send me a sample call to java/scala + javarebel)

I didn't installed JavaRebel, and I wan't to learn/explore other things before.

/davidB

David Pollak wrote:
>
>
> On Dec 10, 2007 5:03 AM, David Bernard <dwa...@free.fr

> <mailto:dwa...@free.fr>> wrote:
>
>
> David Pollak wrote:
> >
> >
> > On Dec 10, 2007 12:30 AM, David Bernard <dwa...@free.fr
> <mailto:dwa...@free.fr>

> > <mailto:oscarp...@gmail.com

David Bernard

unread,
Dec 10, 2007, 4:28:59 PM12/10/07
to lif...@googlegroups.com
David, Steve,

Before releasing the maven-scala-plugin with the new "console" goal. could you check if it matches your need ?
mini-guide :

* force the version of the plugin to 2.2-SNAPSHOT into the pom.xml
* from the commande line :
# every thing should be compiled
mvn test
# run the console (it doesn't require compile)
mvn scala:console
...
scala> new bootstrap.liftweb.Boot().boot
... [play/enjoy] ...

Notes :
* I added support for history and line edition and navigation. (I don't understand why scala developper require rlwrap and similar)
* The history is saved across session (file is ~/.m2/scala-console.histo)
* I've got an issue with :quit, if it doesn't work then use Ctrl-C
* If you want to try with javarebel add the option -Djavarebel.jar.path=<path_of_javarebel.jar> (and tell me if it works, not tested)
* If you don't want to wrote the line new bootstrap.liftweb.Boot().boot at the begin of the session, you could
* add into the pom.xml
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
<scope>test</scope>
</dependency>
* add the file src/test/scala/LiftConsole.scala (based on liftrepl)
import bootstrap.liftweb.Boot
import scala.tools.nsc.MainGenericRunner

object LiftConsole {
def main(args : Array[String]) {
// Instantiate your project's Boot file
val b = new Boot();
// Boot your project
b.boot;
// Now run the MainGenericRunner to get your repl
MainGenericRunner.main(args)
// After the repl exits, then exit the scala script
exit(0)
}
}

Send me your feedbacks (I'll release after).

Thanks.

David Bernard

unread,
Dec 10, 2007, 4:38:10 PM12/10/07
to lif...@googlegroups.com
Oups, I forgot
After created LiftConsole
mvn test
mvn scala:console -DmainClass=LiftConsole (or add the <mainClass>LiftConsole</mainClass> as configuration of the plugin)

That's all.

Reply all
Reply to author
Forward
0 new messages