How to add RichFaces 4.x to maven based project

Version 10

    This article will walk you through the steps needed to use RichFaces in a Maven build environment.


    The first step is to take a look at this article to configure Maven for using JBoss repository.


    Base dependencies (4.0.0 ALPHA2 and later)

         First you should add richfaces-components-bom to your dependency-management section of your pom.xml. That should be done in order to have all the runtime dependencies with versions for the specified release.

    A note on release naming
    The shorthand name for current milestone release is 4.0.0.M1; this is what you'll see in many locations primarily meant to be read by humans (e.g. the download pages.) However, the official name for the release is, a name which follows the JBoss project versioning conventions for projects that issue milestone releases. The inclusion of the date of the release in the release qualifier helps ensure proper release ordering as specified by the OSGi specification. The official name appears in distributions zips, jar manifests, Maven pom files, and in Maven repository URLs. So it should be included like shown at snippet below:



            <!-- for Alhpa versions it was just 'ALPHA2' -->  
    Whats a BOM

    To understand the "Bill of Materials" (BOM) concept more check out:


    In short bom's are maven pom.xml files that all runtime dependencies with versions listed for a concrete module.  So by importing this, you are importing the required versions, and dependencies to use RichFaces.


    RichFaces Dependencies


    Next you will need to add richfaces-components-ui dependency to your project dependencies sections.





    Logger Dependency

    sl4j-api added transitivelly but implementation should be added also by end-developer. For example sl4j-log4j12:



    Or any other impl.


    CDK annotations dependency



    This dependency is compile time and only needed if you creating/accessing some RF components instances in your application actions/listeners in order to define CDK annotations.



    That's all for ALPHA 2 and later versions - all the other dependencies will be fetched transitivelly.


    Note as you could see from the last two snippets - you do not need to specify the version for the dependency. It's defined in BOM file from above. All the other runtime dependencies like JSF artifacts, EL, Servlet and other(you could check in bom file after fetching) also has version specified there That's the version which we are defining for the release. So you could remove the versions in your existent POM for those artifacts to use ones under which we officially released - but it's not a requirement. Your application could re-define them with any other supported version.