The Weld team has recently collaborated with members of the community, most notably Steven Boscarine, to provide you with a set of Maven archetypes that get you developing with CDI and JSF 2 in a jiffy. Today we are announcing that the 1.0.0-BETA1 version of the archetypes are available in the Maven Central Repository. Consider it a holiday present from us ;)

Now you can create a brand new project with a single command and get started writing your application with CDI without having to waste time messing around with mundane setup tasks!

Follow this guide to get started.

Tell me more

Maven archetypes are templates that you use to create a new Maven project that is customized to your organization domain name (groupId) and project name (artifactId). The Weld archetypes focus on creating Java EE 6 projects that can be run on any Java EE 6-compliant application server (e.g., Glassfish V3 or JBoss AS 6.0), as well as JSF 2.0 and CDI projects that run on Servlet Containers (e.g., Tomcat 6 or Jetty 6). At the moment, the only view layer that is offered is JSF 2, though we plan to have archetypes that setup Wicket and other technologies that integrate with CDI in the future.

There are currently three archetypes available:

  • weld-jsf-servlet-miminal: An archetype for creating an application using JSF 2.0 and CDI 1.0 for Servlet Containers (Tomcat 6 / Jetty 6)
  • weld-jsf-jee-minimal: An archetype for creating a minimal Java EE 6 application using JSF 2.0, CDI 1.0 and EJB 3.1 (persistence unit not included)
  • weld-jsf-jee: An archetype for creating a Java EE 6 application using JSF 2.0, CDI 1.0, EJB 3.1 and JPA 2.0 (persistence unit included)

The resulting project imports the weld-extensions-bom to provide compatible version numbers for the Java EE APIs and supporting libraries. Only servlet projects depend on Weld at runtime, in order to bring the CDI services in a servlet environment. The jee projects depend exclusively on the Java EE 6 platform.

Show me

After loading the archetype catalog, you can choose to generate the project from the commandline or an IDE like Eclipse, NetBeans, or IntelliJ IDEA. Here's a screenshot showing us creating a new Maven project from one of the Weld archetypes in Eclipse (using the m2eclipse plugin):

Create Maven project

The generated project includes a readme file with instructions on how to deploy the application (readme.txt), a Maven POM (pom.xml), boilerplate configuration, a demonstration of the JSF 2 and Bean Validation integration, and a start page that you can visit to confirm your application deployed correctly, shown below. The start page uses layout template and stylesheet. The graphics on the page are taken from prototypes that the JBoss.org design team has created for the Weld project branding.

There is no faster way to get started with CDI and JSF 2 than using these archetypes!

Still, there is room for improvement. We are looking for your feedback. Do you find them easy? Do they provide too little? Too much? What other features do you want?

Credits

I'd like to thank Steven Boscarine for his dedication to this initiative and for helping us keep the end goal in perspective, Sonatype for making it so streamlined for OSS projects to publish artifacts to the Maven Central repository with Nexus, and the JBoss.org design team for the graphics that give the start page a slick look!


Back to top