myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Myfaces Wiki] Update of "MyFaces_Archetypes_for_Maven" by LeonardoUribe
Date Thu, 04 Aug 2011 02:32:27 GMT
Dear Wiki user,

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

The "MyFaces_Archetypes_for_Maven" page has been changed by LeonardoUribe:
http://wiki.apache.org/myfaces/MyFaces_Archetypes_for_Maven?action=diff&rev1=20&rev2=21

- = Archetypes =
+ See the updated page on:
  
- There are four [[http://maven.apache.org/guides/introduction/introduction-to-archetypes.html|"Maven
Archetypes"]] in !MyFaces which aim is to help setting up a new JSF project in less than one
minute.
+ https://cwiki.apache.org/confluence/display/MYFACES/MyFaces+Archetypes+for+Maven
  
-  * '''!MyFaces Hello World 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.
-  * '''!MyFaces Hello World with Facelets Archetype''': this archetype creates the basic
structure for a project that will use !MyFaces and Facelets. It includes all the dependencies
needed so you don't have to find them out. 
-  * '''!MyFaces Hello World with Trinidad''': this archetype creates the basic structure
for a project that will use !MyFaces and Trinidad. It includes all the dependencies needed
so you don't have to find them out. 
-  * '''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. Complete tutorial available [[http://brunoaranda.googlepages.com/jsfcomponentsarchetype2|here]].
- 
- This archetypes are available on maven repo under the group org.apache.myfaces.buildtools
- 
- == The MyFaces Hello World Archetypes ==
- 
- This archetypes 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:generate -DarchetypeCatalog=http://myfaces.apache.org
- 
- Select option 1, set properties and that's all!
- 
- }}}
- 
- That's all. The goal archetype:create downloads the proper artifacts from the main maven
repo and create the test project. Now you can start to work immediately.
- 
- ==== Getting and installing the plugin locally ====
- 
- If you want to use the latest code of the archetype, the first thing you should do is to
checkout the myfaces archetype source from the svn, using the command:
- 
- {{{
- svn co http://svn.apache.org/repos/asf/myfaces/myfaces-build-tools/trunk/maven2-archetypes
- }}}
- 
- 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. For example:
- 
- {{{
- cd myfaces-archetype-helloworld
- 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:generate -DarchetypeCatalog=http://myfaces.apache.org
- 
- Select option 1, set properties and that's all!
- 
- }}}
- 
- or if you want to use MyFaces + Facelets
- 
- {{{
- mvn archetype:generate -DarchetypeCatalog=http://myfaces.apache.org
- 
- Select option 2, set properties and that's all!
- 
- }}}
- 
- or if you want to use Myfaces + Trinidad 
- 
- {{{
- mvn archetype:generate -DarchetypeCatalog=http://myfaces.apache.org
- 
- Select option 5, set properties and that's all!
- 
- }}}
- 
- 
- 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 :-)
- 
- ==== How to switch versions (e.g. to 1.1.x) ====
- 
- At the moment this Archetype creates a MyFaces 1.2.x project (see pom.xml).
- 
- To setup a MyFaces 1.1.x project you have change the MyFaces version numbers within the
generated pom.xml
- 
- Example for version 1.1.5:
- {{{
-     <dependency>
-         <groupId>org.apache.myfaces.core</groupId>
-         <artifactId>myfaces-api</artifactId>
-         <version>1.1.5</version>
-         <scope>compile</scope>
-     </dependency>
- 
-     <dependency>
-         <groupId>org.apache.myfaces.core</groupId>
-         <artifactId>myfaces-impl</artifactId>
-         <version>1.1.5</version>
-         <scope>compile</scope>
-     </dependency>
- }}}
- 
- ==== Jetty plugin ====
- 
- The Jetty6 plugin has been added to the pom.xml of the archetype.
- 
- {{{
- mvn -PjettyConfig clean jetty: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:generate -DarchetypeCatalog=http://myfaces.apache.org
- 
- Select option 4, set properties and that's all!
- 
- }}}
- 
- But well, now you have to get it from the sources:
- 
- {{{
- svn co http://svn.apache.org/repos/asf/myfaces/myfaces-build-tools/trunk/maven2-archetypes/myfaces-archetype-jsfcomponents
- }}}
- 
- Then, install the archetype:
- 
- {{{
- cd myfaces-archetype-jsfcomponents
- 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.buildtools      \
-                      -DarchetypeArtifactId=myfaces-archetype-jsfcomponents \
-                      -DarchetypeVersion=1.0.1                              \
-                      -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 base project ===
- 
- It contains the parent pom which lists the 'core' and 'examples' modules.
- 
- === 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
RI)
- 
- === 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 clean package jetty:run
- }}}
- 
- Alternately, to build your example app using the JSF Reference Implementation, execute this
in the examples folder:
- 
- {{{
- mvn -PjettyConfig -Djsf=ri clean package jetty:run
- }}}
- 
- And you can go to http://localhost:8080/myJsfComponents-examples to see the examples.
- 
- Always be sure to 'clean' when you switch JSF implementations, or your example app may contain
jars from ''both'' !MyFaces and the RI.
- 
- 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.
- 
- For more information on this archetype and how you can use it you can refer to [[http://brunoaranda.googlepages.com/jsfcomponentsarchetype2|this
tutorial]].
- 

Mime
View raw message