Scala / Lift: Set up hotdeploy through Eclipse? - eclipse

How do I set up hotdeploy for Scala/Lift projects in Eclipse?
Basically, I would like to be able to
Set up a new project, from say lift-archetype-basic
Launch jetty:run, either from some run-configuration or through terminal
Be able to edit Scala files in Eclipse, Save/Auto compile
Refresh the web-page in the browser and see the updates.
The tutorial at http://wiki.liftweb.net/index.php/Using_eclipse_hotdeploy is out-dated and I really can't figure out how to set this up.
I currently have
Eclipse 3.5
Maven IAM plugin version 0.11
Scala plugin 2.8.0.RC6
Should I use any other versions or plugins?

With SBT it's possible to continuously recompile and reload the web application when using Jetty:
jetty-run
~ prepare-webapp
jetty-run starts Jetty and the ~ prepare-webapp recompiles and recreates the web application whenever sources files change.
SBT is compatIble with Maven and Ivy, so you may generate the project file layout with Maven archetypes, and switch to SBT later - it will recognize repositories and dependencies specified in the POM.
This tutorial video shows, how to get stated with SBT and Eclipse.

Related

How do I run SBT from within Eclipse?

So far I've been running IntelliJ IDEA Community Edition for my Scala projects, but as my projects are expanding in complexity, I stumble upon more and more roadblocks with the IDE.
Like for example the simple fact that IDEA doesn't allow for web-development or Java EE development what so ever, which means using the Play Framework or TomEE in Community Edition leads to nothing but dead ends and frustration.
The only reason I switched to IDEA in the first place, is because of its excellent plugin system, allowing me to run SBT seamlessly as the primary scala compiler and library downloading tool with ease.
Searching around on Google, however I can only seem to find mentions about the eclipse plugin for sbt, that makes an sbt project Eclipse friendly, which is the exact opposite of what I'm really looking for.
I'm not willing to spend €89 per year for a student licence after all the pain it's put me through so far...
So my question is; is there a plugin for Eclipse that allows me to use SBT the same way as in IDEA? Or am I forced to go through the console?
There may be some movement in this direction in the future, but for now there is no such plugin.
Currently there is no Sbt plugin for Eclipse. Depending on your use-case, you could:
use the Eclipse builder
Pros: proper integration (error markers in Problems and editors, cancelation, progress reporting)
Cons: may get out-of-sync with the Sbt build file (when adding a dependency, for example), doesn't handle anything other than Java and Scala (like Play templates or route files)
use Sbt on the command line (make sure to disable auto-building in Eclipse)
Pros: can handle complex builds, classpath is always up to date
Cons: no integration (see above)
use Activator
Same Pros and Cons as Sbt, but with a pretty UI
We are working on an sbt-server plugin for Eclipse, which will delegate the build to an external Sbt process without giving up the convenience of integration. We hope to have something out towards the end of this year.
I think the main problem you are trying to solve for is too have sbt jar dependencies show up and get used natively by your eclipse project. You can do that with the IvyIDE plugin (which is found in the eclipse marketplace).
If you have that installed (and the eclipse plugin for sbt) then this closes the gap between systems.
To enable:
type the {sbt deliver-local} command from your terminal. This adds an ivy xml in your project's target directory
right click on your project. Choose the Ivy -> enable Ivy dependency management option
go into your projects properties. Highlight the Ivy property. Click the new button and navigate to the ivy xml file in your projects target directory.
Now your eclipse compiles off of your sbt managed dependencies and now you are doing everything you want except actually running sbt from within eclipse (which you only have to do now when you are changing dependencies)

Can NetBeans 8.0 with Scala and sbt plugins installed create sbt project?

I had previously used Scala-IDE, and I thought I'd give NetBeans IDE 8.0 a try.
I created Java/Maven projects successfully, but I don't seem to be able to create an sbt project. I have all the Scala plugins loaded as far as I can see, including the sbt plugin. Platform is Win 8.1 and Java 8.
Creating an NetBeans native project for Scala works, but there seems to be no option to create an sbt project. Is that expected?
Iff the plugin you use is nbscala-1.6.3.1 it appears from the documentation that the supported features are:
Recognize sbt project and open in NetBeans
Open sbt console in NetBeans (Right click on sbt project, choose "Open Sbt")
Jump to/Open compile error lines
I conclude that there's no support for creating a new sbt project using the plugin.
You'd have to create a sbt project using Typesafe Activator and only then use NetBeans with the plugin to open it and start hacking right in the environment.

GWT+Eclipse without GWT_CONTAINER

The situation
I'm using GWT with Eclipse and Google Plugin for Eclipse (GPE).
Gradle is the build tool and the Eclipse classpath is generated by Gradle. As I have no "com.google.gwt.eclipse.core.GWT_CONTAINER" on my classpath, GPE always shows the error "The project 'Test' does not have any GWT SDKs on its build path" and the Console sometimes prints "GWT SDK not installed.".
Annother effect is that Eclipse doesn't let me GWT-compile the project (but running dev mode works fine). But that one is ok for me, as I compile using Gradle.
Things I'm aware of
I know that I can exclude all GWT depedencies from the Eclipse classpath and add the container through Gradle (I did that for other projects). But as I can't enforce the GWT version provided by Eclipse (I can only specify the SDK's name in the classpath by adding the suffix "/" to the conatiner), I think thats an ugly solution. Another point is that the GPE update site only lists the latest GWT version available. There's no way to automatically install an older version (yes you can provide one externally).
When using GPE together with Maven and m2e it simply works: GPE links no real SDK for Maven projects but there's a link to the "com.google.gwt" group in the local Maven repository. But that's magic I can't use because:
Gradle's local repository format is different to Maven's
This logic is implemented in the plugin "com.google.gdt.eclipse.maven" and I can't use that without adding a pom.xml to the project
The questions
Is there a possibility to deactivate this nasty error without loosing other GPE features?
Is it possible to do something similar to what GPE+m2e does without
creating my own Eclipse plugin?
Am I right that excluding the jars and adding the container is the only viable solution by now?
You can adapt this library to launch with custom classpath and other settings: https://github.com/eclecticlogic/gwt-launcher

Eclipse running lift project (project configuration issues)

Trying to get a lift project to run on windows, I've installed maven on my computer, then tried to use
mvn archetype:generate from cmd, then chose the lift basic one , but it always failed on the jetty:run part. Before that, I had to change a lot of the pom.xml file to even get a successful build (since the tutorial I was using was obsolete and it couldn't find the dependencies).
So I've decided to try with the eclipse plugin, thinking it should be easier.
I've installed the maven plugin for eclipse and created a project with the lift archetype.
The project was succesfully created, but I have all kinds of errors in the editor for missing ; and so on (I have scala ide installed on eclipse also and creating a normal scala project works and compiles/runs fine). I have also tried to include the scala-library.jar in the buildpath, with no change.
The odd part is that I can run the cmd and go to the project folder, then run mvn jetty:run and it will actually work (?!) Trying to run in eclipse with jetty:run as goal will give me ClassNotFoundException on the HelloWorld snippet.
So what might be wrong with my settings?
UPDATE: no luck whatsoever, after trying 3 different eclipse versions, installing the maven for scala plugin and following every tutorial I could find. It just simply feels all is outdated on the instructions:
this is how it looks after I include the scala libraries for eclipse on every project (after I create it from an archetype):
is this "mvn archetype:generate" up to date? I don't know if anybody guarantees it will work at all..
Anyway, the default way to at least try Lift and see it working is the following: https://github.com/lift/lift_25_sbt
It uses "Simple Build Tool" instead of maven, but maven should work, too. Also, you can easily read "build.sbt" to get all the dependencies.
Plugins for creating eclipse/intellij project definitions are included. (See the README of the demo project.)
The target to create eclipse project is "eclipse" or "eclipse with-sources=true".
The target to launch the app is "container:start".

Working with a Scalatra application in an Eclipse workspace? (i.e. build path)

I am experimenting with a small Scalatra web application, which I have imported as a project into Eclipse.
I have used Eclipse to manage a few Lift applications before. With a Lift project, SBT copies all the dependency JAR's to a /lib_managed directory. I can therefore add those JAR's to Eclipse's build path, and it co-exists with SBT just fine without complaining about missing classes.
With Scalatra, however, the dependency JAR's don't seem to get copied anywhere helpful during the development cycle. If you build a WAR file, then the dependencies get bundled up into that... but there doesn't seem to be anything like Lift's /lib-managed directory.
Assuming that anyone else uses Eclipse in developing Scalatra projects, how might I easily set up Eclipse's build path? I suppose that I could manually create entries that point my local Ivy repository one-by-one, although that seems a bit ugly. Perhaps there's an easy way through SBT to setup something similar to Lift's /lib-managed subdirectory inside the project directory.
It looks like the best approach for this is using the SBT plugin for Eclipse.
This is not an "Eclipse plugin" for managing SBT. Rather, it's an "SBT plugin", for generating the .project and .classpath files used by Eclipse. The Maven world used to deal with Eclipse in a similar manner, before the m2eclipse Eclipse plugin reached maturity over the past couple years.
With this plugin installed (I installed it globally so I wouldn't have to change my project's files), you just type sbt eclipse after any changes to your dependencies. SBT will then update your Eclipse project files to match.
You could also use my Maven prototype, then simply import the maven project into Eclipse. Quite nice and you're not forced to use SBT.
https://github.com/fancellu/scalatra-maven-prototype