Print
Developing with IDEs

Developing a Trails app with IDEs



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:

    mvn eclipse:add-maven-repo -Declipse.workspace=C:\j\workspace


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

    mvn eclipse:eclipse -Dwtpversion=1.5


  • 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:

    mvn war:inplace


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.

Import local Maven projects

Local Maven project can be imported using Elipse import wizard. Select "File / Import..." and then choose "Maven Projects" from the list.

Then on the next wizard page specify root folder to scan for projects, then hit "Refresh" button. Then you can check projects for importing into the Eclipse workspace. Note that project modules are shown as nested elements.

By default modules will be imported as separate projects and workspace artifact resolution will be enabled, but you can adjust these options from the Advanced section.

  • The major advantage of single project is that it less verbose and it may work little better with some Team VSC plugins. For example, Sublipse is little shaky when working with overlapping nested projects.
  • From the dependency resolution point of view, multi-project setup allow to be much closer to the Maven dependency resolution and provides more accurate dependencies for each module.

Checkout Maven projects from SCM

Maven projects can be checked out from Source Control Management system (SCM) using Eclipse import wizard from "File / Import... / Other / Checkout Maven projects from SCM...". Then you can select SCM type from the list of supported SCMs, specify URL, required revision or tag and select location where code should be checked out.

You can paste a Maven SCM URL like "scm:git:http://repo.or.cz/r/egit.git" directly into the "SCM URL" field

Materialize Maven projects

Full projects for Maven artifacts that have correct SCM information specified in their POM can be checkout into Eclipse Workspace using import wizard from "File / Import... / Other / Materialize Maven Projects...". Then you can use "Add..." button and use Quick Search to add Maven artifacts for import. Then if selected artifacts have correct SCM info specified they will be imported in Eclipse workspace.

The same import wizard can be also invoked from the Maven Indexes view and also from "Maven / Import Project" popup menu on any jars in Eclipse Workspace. If selected jars are not in "Maven Dependencies" classpath container, then plugin will try to identify Maven artifacts using SHA1 of selected jars.



It works beautifully with the jettylauncher.

Using IntelliJ IDEA

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

mvn idea:idea

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.



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





Powered by Atlassian Confluence