Tapestry Training -- From The Source

Let me help you get your team up to speed in Tapestry ... fast. Visit howardlewisship.com for details on training, mentoring and support!

Thursday, January 25, 2007

Tapestry 5 Maven Archetype

I've just put together a rather decent Maven Archetype for Tapestry 5. It's called "tapestry-simple" and its documented here.

The archetype allows you to create a Tapestry 5 application in, literally, seconds. It generates the pom.xml (for Maven), .classpath/.project (for Eclipse), as well as web.xml, log4j.properties, the complete directory structure, even a sample Start.html and Start.java.

It also configures the Jetty plugin so that you can immediately run the application using "mvn jetty:run".

This took only a little doing. The Maven documentation was awful as usual (yes, kettle, stove, etc.), but peeking at a couple of the sample archetypes, and trying some experiments, allowed me to put together something relatively complete and polished in a couple of hours. And those hours will save thousands of developers an hour or two each.

To make this work, you need to edit your settings.xml to add in the Apache snapshot repository at http://people.apache.org/repo/m2-snapshot-repository/ ... but perhaps better (and almost as easy) is to check out the latest Tapestry 5 source from SVN and build locally. You'll want the tapestry-project, tapestry-ioc, tapestry-core and tapestry-simple projects. Do a "mvn clean install" and all the latest and greatest will be in your local Maven repository!

14 comments:

Anonymous said...

Very cool! Is there one for Tapestry 4?

Unknown said...

Greg Wilkins & friends put together a bunch of archetypes, including Tapestry 4: Check out http://www.webtide.com/resources.jsp

Unknown said...

I really like what I saw and what I heard about what you said in PJUG tonight, when can I start using 5? If I use Tapestry 4 now, any design consideration for moving to 5? Thanks for the great framework.

Anonymous said...

I'm having trouble downloading the 5.0.0-SNAPSHOT ("Unable to download the artifact from repository"). Is there some specific repository in which I should be looking?

Unknown said...

In my case, I had just built it, so it's coming out of my local repository.

To find it, and all the other Tapestry 5 snapshots, you need to add the following repository to your ~.m2/settings.xml file:

http://people.apache.org/repo/m2-snapshot-repository

Renat Zubairov said...

Great idea! Thanks allot. It will definitely lower the burden to start Tap5 development. I'll try it today!
Renat

高爽 said...

Get it running by doing this
1. Adding a repository in settings.xml didn't work for me. (A bug in maven 2.0.4??). I had to specify -DremoteRepositories in command line to donwload the project
mvn archetype:create -DarchetypeGroupId=org.apache.tapestry -DarchetypeArtifactId=tapestry-simple -DarchetypeVersion=5.0.0-SNAPSHOT -DgroupId=com.gaoshuang -DartifactId=tapestry5-simple -DpackageName=com.gaoshuang.tapestry5 -Dversion=1.0.0-SNAPSHOT -DremoteRepositories=http://people.apache.org/repo/m2-snapshot-repository/

2. Downloaded javassist.jar (version 3.1) and installed locally
mvn install:install-file -DgroupId=javassist -DartifactId=javassist -Dversion=3.1 -Dpackaging=jar -Dfile=javassist.jar

3. mvn jetty:run

Anonymous said...

Thanks @shuang! I couldn't get Maven to use my profile settings either, but got a "Build Successful" message with the extra remote repository on the command line.

Bill Holloway said...

Wow. I used shuang's mvn command line to create the project, and created a new Java project in Eclipse using the existing source, and it correctly enabled all the Maven features in the IDE. Granted, this was after I had run "mvn jetty:run" already on my command line in the source (prior to the eclipse work).

mvn:jetty run seemed to import some Eclipse IDE resources. Either way, no complaints! The stub app fired up right away! Yowsa!

Anonymous said...

Thanks Howard! I really like Tapestry 5 than Tapestry 4. It is really cool.

Unknown said...

I was able to get this to work by adding to the settings.xml in ${maven.home}/conf, something like:

<profile>
<id>tapestry5</id>
<repositories>
<repository>
<id>tapestry5</id>
<name>Repository for Tapestry 5</name>
<url>http://people.apache.org/repo/m2-snapshot-repository/</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
</profiles>

Then use the command line in the blog entry AND -P tapestry5 to enable the profile.

mbjarland said...

I have to say that even after using it actively for three projects I still manage to hate maven!

When it doesn't work, it REALLY doesn't work.

I'm a long time ant user and there are few things I can not make happen with ant, but every project I've run maven in, I've always run into a scenario where the maven standard structure starts feeling too constraining and doing 'custom' stuff in mvn is just a pain or at least not as sleek as with ant (or I just suck at mvn).

I'd like to cook up something similar to appfuse with a sample T5 app, hibernate, and an ACEGI security setup with a couple of users. I believe a zip file and ant targets leaves the structure more open to customization than a mvn target in this scenario.

Howard, are you planning on making mvn the distribution mechanism of choice for T5 or was this just an easy way to get the QuickStart up and running?

Opinions anybody?

PS Apologiez for the acidic tone...sitting there with your "plugin does not exist" message, broken local repository, etc, etc, does that to you after a while. DS

Unknown said...

Hi I tried to create the very first example in Tapestry site,but instead of creating a project template for Tapestry,maven creates AppFuse application.Following is the maven log,see its asking for wicket sample number.What cud be the wrong?
thanks


ct using marmalade)
12: internal -> maven-archetype-mojo (A Maven Java plugin development project)
13: internal -> maven-archetype-portlet (A simple portlet application)
14: internal -> maven-archetype-profiles ()
15: internal -> maven-archetype-quickstart ()
16: internal -> maven-archetype-site-simple (A simple site generation project)
17: internal -> maven-archetype-site (A more complex site project)
18: internal -> maven-archetype-webapp (A simple Java web application)
19: internal -> struts2-archetype-starter (A starter Struts 2 application with Sitemesh, DWR, and Spring)
20: internal -> struts2-archetype-blank (A minimal Struts 2 application)
21: internal -> struts2-archetype-portlet (A minimal Struts 2 application that can be deployed as a portlet)
22: internal -> struts2-archetype-dbportlet (A starter Struts 2 portlet that demonstrates a simple CRUD interface with db backing)
23: internal -> struts2-archetype-plugin (A Struts 2 plugin)
24: internal -> shale-archetype-blank (A blank Shale web application with JSF)
25: internal -> maven-adf-archetype (Archetype to ease the burden of creating a new application based with ADF)
26: internal -> data-app (A new Databinder application with sources and resources.)
27: internal -> jini-service-archetype (Archetype for Jini service project creation)
28: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype)
29: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype)
30: internal -> softeu-archetype-jsf (JSF+Facelets Archetype)
31: internal -> jpa-maven-archetype (JPA application)
32: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype)
33: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype)
34: internal -> maven-archetype-har (Hibernate Archive)
35: internal -> maven-archetype-sar (JBoss Service Archive)
36: internal -> wicket-archetype-quickstart (A simple Apache Wicket project)
Choose a number: (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36):


Unknown said...

The problem is that the Maven developers released a badly broken vesion of the Maven archetype plugin that broke every archetype in the world except the couple they have built in. I believe they are working on a fix.