Skip to end of metadata
Go to start of metadata

Developing a Trails app with IDEs


Icon

When executing from within the IDE Trails does not automatically generate the hibernate.cfg.xml file. So you either have to edit it your self (my recommended option) or you have to execute "mvn compile" every time you create a new Hibernate entity.

Using Eclipse

You want to use Eclipse WTP, the latest WTP 1.5.3 is known to work fine. With Maven (and you *don't* have to use it, but it's easier and the documented way of doing things), you can maintain the dependencies in only one place (in your project pom.xml) and let Maven generate the Eclipse project files for you and never check them into your own source control system.

  • If you've never used Maven's eclipse plugin before, add the M2_REPO variable to your workspace:mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
    for example:

  • Create the eclipse configuration files (-Dwtpversion for creating WTP's dynamic web project, but is not required otherwise):

  • If you are using WTP's container support, configure your libraries.
    WTP doesn't pickup the libraries from maven repository. As a workaround you can recreate your war structure in src/main/webapp there is a maven goal wich do that for you:

Then, import the existing project into your eclipse workspace. 

For an integrated in-place development, you have several options: jetty (with Eclipse Jetty launcher plugin), Tomcat (with Sysdeo's Tomcat plugin or with Merve Tomcat Launcher), or using WTP's native servlet container support. WTP's native container support tends to be somewhat cumbersome as the concept is generalized to work for multiple servlet containers and doesn't offer as high level of integration for a particular container. One of the issues is that WTP's support works so it scans source folders and copies them to target directories, for which there isn't a real need for. Sysdeo's Tomcat plugin offers the highest level of Tomcat integration (reload web app context from a context-specific menu, separate buttons for starting and stopping), but has its own issues for loading the dependent libraries (need to manually install devloader, need to semi-manually keep the libraries in sync when you add them, pukes out if multiple servlet-apis are found on load path). Merve is a good choice if you want to get up and running quickly with Tomcat, without having to install it first and and allows you to set the port etc. for the container straight from Eclipse. Merve adds itself as  Eclipse/Run As.. configuration and you don't need to manually update library paths or anything else.

Jetty is another servlet container and has a no-frills Eclipse plugin very similar to Merve. Some claim Jetty is a little faster to start-up than Tomcat which is an advantage in development, but equally configured, it's difficult to notice any real difference in performance.

Whatever your configuration of choice is, you'll hit the two most common gripes when developing a Tapestry 4.1 application in an IDE: 1) Changes in Tapestry's html templates aren't refreshed and 2) code hot-swapping fails. In both cases, you need to either reload the context or restart the container. For the templates, turn off Tapestry caching with a system property org.apache.tapestry.disable-caching=false as explained. However, as Trails heavily relies on rendering abstract blocks and a lot of the magic happens in the property descriptors, often times you are forced to reload the context because the code hot-swapping frequently fails - (typically anytime the class is already loaded). Do everything can to shorten the start-up time of your application for best results.

Using M2Eclipse: Maven Integration for Eclipse

Version 0.0.11 of the Maven Integration for Eclipse project includes a notable new feature, a Maven Project Import wizard.

Unable to render {include} The included page could not be found.


It works beautifully with the jettylauncher.

Using IntelliJ IDEA

Similar to Eclipse Maven plugin there maven-idea-plugin that generates configuration files for you:

Using IntelliJ IDEA 7.0

Since version 7.0 (actually latest version IDEA 7.0 Milestone 2 is only a pre-release build of version 7.0 of IntelliJ IDEA, which is coming out by the end of this year) IntelliJ IDEA lets you create projects directly from Maven descriptor files, enabling you to quickly switch to your selected development environment.
Importing Maven projects to IntelliJ IDEA with automatic artifacts downloading is pretty easy.
Start a new project selecting "Import project from external model"

Then select Maven.

Finally select the root directory of your Trails project.

Idea 7.0 also lets you execute and manage Maven goals from within the IDE and has a beautiful Hibernate & Spring support.

Icon

Help needed here, haven't used... For developing Tapestry 4.x applications there's a HandyTapestry plugin that people say is pretty useful.



  • No labels