Creator of the Apache Tapestry web application framework and the Apache HiveMind dependency injection container. Howard has been an active member of the Java community since 1997. He specializes in all things Tapestry, including on-site Tapestry training and mentoring, but has lately been spreading out into fun new areas including functional programming (with Clojure), and NodeJS. Howard is a DZone MVB and is not an employee of DZone and has posted 79 posts at DZone. You can read more from them at their website. View Full User Profile

Using Maven to Create a New Tapestry 5.1 Project

  • submit to reddit

I've been digging deep into the (revised) Maven archetype plugin: the tool used to generate new projects from a template. The existing quickstart archetype had some glaring omissions, partially related to limitations of the old plugin. The new plugin makes many more things possible.

In the past, you needed to specify the new project's groupId, artifactId and other data on the command line. This process was so tedious and error prone that I advised wrapping it up in a Ruby script.

Now it's a bit easier, as Maven will ask you for any necessary properties:

$ mvn archetype:generate -DarchetypeCatalog=
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO]    task-segment: [archetype:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.
[INFO] Setting property: velocimacro.messages.on => 'false'.
[INFO] Setting property: resource.loader => 'classpath'.
[INFO] Setting property: resource.manager.logwhenfound => 'false'.
[INFO] [archetype:generate]
[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: -> quickstart (Tapestry Quickstart Project)
Choose a number:  (1): 1
[INFO] snapshot org.apache.tapestry:quickstart: checking for updates from quickstart-repo
Define value for groupId: : com.formos
Define value for artifactId: : demo1
Define value for version:  1.0-SNAPSHOT: :
Define value for package:  com.formos: : com.formos.demo1.web
Confirm properties configuration:
groupId: com.formos
artifactId: demo1
version: 1.0-SNAPSHOT
package: com.formos.demo1.web
Y: :
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 24 seconds
[INFO] Finished at: Sat Jan 31 13:12:31 PST 2009
[INFO] Final Memory: 8M/14M
[INFO] ------------------------------------------------------------------------

The key part is the -DarchetypeCatalog=, which points Maven at Tapestry's own nightly snapshot repository. It picks up a catalog file from there which points to the quickstart archetype stored inside the snapshot repository. No muss, no fuss.

Of course, the first time you run this, Maven has to download about 34MB of modules!

In any case, it works nicely. I put some extra effort in so that the archetype description clearly identifies the exact version of Tapestry.

The new quickstart archetype is much improved; it now includes a Layout component that wraps the page content using a free CSS layout, "concrete" (which has a Creative Commons license). In other words, your application will look good from day 1, though (of course) I'd expect you to throw away the layout subsequently. Anyway, this will answer some questions such as: "how do I use a Layout component?" and "how do I access a message catalog?"

I can see replacing the "concrete" layout with something more general, less blog-oriented (but that's beyond my CSS/HTML design skills!).

All of this is all usable right now. Have fun!


Published at DZone with permission of Howard Lewis Ship, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


David Canning replied on Sat, 2009/03/28 - 12:58pm

It does not work with snapshot  I cleaned out my .m2 repository just in case and get the following error.

[INFO] Generating project in Interactive mode
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-arc
Choose archetype:
1: -> quickstart (Tapestry Qui
ckstart Project)
Choose a number:  (1): 1
[INFO] snapshot org.apache.tapestry:quickstart: checking for updates from quickstar
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] The defined artifact is not an archetype
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7 seconds
[INFO] Finished at: Sat Mar 28 10:58:12 MST 2009
[INFO] Final Memory: 8M/15M
[INFO] ------------------------------------------------------------------------

 Any help?


David Canning replied on Sat, 2009/03/28 - 1:01pm

Sorry for the post.  I just read your blog.  David

hookfi john replied on Sun, 2009/05/31 - 8:02am

Tiffany shop is the best online US tiffany jewelry stores where you can buy the cheapest Tiffany & Co silver jewelry. Our huge selection of Tiffany Tiffany Bracelets Tiffany Rings

Howard Haines replied on Mon, 2010/10/25 - 2:10am

For those of you who are purchasing Titanium Jewelry or Titanium Necklaces, we realize that this is one of the most important purchasing decisions you will make. You have made the best choice in choosing one of our Cross Titanium Necklaces, Titanium Pendants or Titanium Rings, as they are constructed of the highest grade materials to ensure that your new Titanium Jewelry lasts forever. The designers we feature are chosen for their unique modern styling and lasting quality. You can be confident in your purchase as each item comes with a no hassle 30 day return privilege.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.