myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Myfaces Wiki] Update of "MyFaces Archetypes for Maven" by BrunoAranda
Date Mon, 12 Jun 2006 18:59:41 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by BrunoAranda:

New page:
= Archetypes =

There are two [
"Maven Archetypes"] in !MyFaces which aim is to help setting up a new JSF project in less
than one minute.

 * !MyFaces Archetype: this archetype creates the basic structure for a project that will
use !MyFaces. It includes all the dependencies needed so you don't have to find them out.
The best way to start a new web application.
 * JSF Components Archetype: aimed to those that want to setup a JSF component library project.
This archetype will create a maven multi-module project, that contains the artifact for the
JSF components and a webapp for the examples. Everything setup and prepared to be deployed
out-of-the-box! Includes a very simple demo component, that can be used in any JSF implementation.

Note that those two archetype are not released yet, but they will be very soon. In the meanwhile,
you will have to build the archetypes yourself before using them.

== The MyFaces Archetype ==

This archetype allows you to generate a template for a web application that uses !MyFaces,
based on the blank example application. So, creating the template of the application is as
easy as executing:

mvn archetype:create -DarchetypeGroupId=org.apache.myfaces.maven -DarchetypeArtifactId=myfaces-archetype
-DarchetypeVersion=1.0-SNAPSHOT -DgroupId=myAppId -DartifactId=testApp

In the near future, the archetype will be located in a public repository in internet, but
currently if you want to use it you have to build it from sources.

==== Getting and installing the plugin locally ====

To be able to use the archetype the first thing you should do is to checkout the myfaces archetype
source from the svn, using the command:

svn co myfaces-archetype

Now, let's install the plugin locally (this supposes that you have maven 2.x already installed).
Navigate to the plugin root folder and use the mvn install command:

cd myfaces-archetype
mvn install

At this point, you have the plugin installed in your local system. You don't have to install
it again unless you want to update it.

==== Creating a template for a web application ====

Now, using maven (anywhere in your file system) you can create a template for an application
that uses !MyFaces using the command:

mvn archetype:create -DarchetypeGroupId=org.apache.myfaces.maven -DarchetypeArtifactId=myfaces-archetype
-DarchetypeVersion=1.0-SNAPSHOT -DgroupId=myAppId -DartifactId=testApp

In this last command we are creating an application with groupId=myAppId and artifactId=testApp.
You can change that values to adapt your needs.

Finally, if we want to test the basic application created, just run the command:

cd testApp
mvn package

And you will have your war created at testApp/target folder!

This whole process can save a lot of time while setting up a new web application. And what
is better, you have already the structure to use maven :-)

==== Jetty plugin ====

The Jetty6 plugin has been added to the pom.xml of the archetype.

mvn -PjettyConfig clean jetty6:run

This will create a war, launch the Jetty container and it will server your project at http://localhost:8080/testApp

== The JSF Components Library Archetype ==

This archetype generates a maven multi-module project prepared for the development of custom
JSF components. To create your new project, the only thing you have to do (again, after installing
the archetype locally, but this will be not needed soon), is to execute this command;

mvn archetype:create -DarchetypeGroupId=org.apache.myfaces.maven -DarchetypeArtifactId=jsfcomponents-archetype
-DarchetypeVersion=1.0-SNAPSHOT -DgroupId=myAppId -DartifactId=myJsfComponents

But well, now you have to get it from the sources:

svn co

Then, install the archetype:

cd jsfcomponents-archetype
mvn install

Now, you can create the project in the folder of your choice! Just go to that folder and run
the archetype:create goal.

cd yourFolder
mvn archetype:create -DarchetypeGroupId=org.apache.myfaces.maven -DarchetypeArtifactId=jsfcomponents-archetype
-DarchetypeVersion=1.0-SNAPSHOT -DgroupId=myAppId -DartifactId=myJsfComponents

And there you have it, you can start coding without having to hazzle with the project configuration.
The archetype generates a multi-module project with this structure:

 -+ project base (parent pom)
  +--- core (component library)
  +--- examples (examples for the components)

The layout of the project is almost identical to the layout of the MyFaces sandbox. This also
ensures that your components could go to the sandbox without having too handle major conversions.

=== The component library (core project) ===

It will contain the sources of your components, as well as some tests (it should!). There
is one demo component that comes with the archetype, so you can see how it is implemented
and configured. This demo component works in every implementation (both !MyFaces and Sun's

=== The examples webapp ===

It is a webapp with the basic setup to start making demonstrations of your custom components
without having to do special setups. There is already an example for the demo component. The
home web page includes the version of the component library (the version of the pom file).
The webapp can be built with !Myfaces or with the JSF-RI and can be executed directly with
Jetty (the same way than the !MyFaces Archetype). That is very handy to test that your components
work in both implementations. For instance, if you want to execute your application directly
from Jetty and using MyFaces, execute this in the examples folder:

mvn -PjettyConfig,myfaces clean jetty6:run

And you can go to http://localhost:8080/testApp-examples to see the examples.

No other technologies are included (e.g. facelets), but it is easy to add whatever you need.
There is no need to reinvent the wheel and following a standard structure will boost the code
understanding between developers.

View raw message