Apache Struts 2 Documentation > Dependencies
Added by Patrick Lightbody, last edited by Ted Husted on Feb 12, 2007  (view change) show comment

General Information on Dependencies

SAF 2 is in the process of the migrating from the Incubator. The library distribution and dependency report may not yet be available.

As with most modern and robust frameworks, Struts Action Framework 2 has a number of external dependencies. For your convenience, all of the JARs used by the framework are available in a library distribution. You can download the distribution and add the JARs to your SAF-based application.

Depending on which of the framework's features your application uses, some of the JARs may be optional. However, if a JAR is not used, its code is not loaded into main memory, and no additional resources are consumed.

Dependency Management

We use Apache Maven to track and maintain the framework's dependencies. Another popular product is Ivy. You may want to consider using Maven or Ivy to manage your own application's dependencies.

Using Ivy to resolve dependencies

The much easier way for dependency resolving is to integrate Ivy into your project. See Building the Framework from Source for a introduction to Ivy and installation instructions.

Here is a sample ivy.xml for a SAF-based project, requiring the latest release of SAF 2 with FreeMarker, SiteMesh and JasperReports functionality:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" xhref="http://www.jayasoft.fr/org/ivyrep/ivy-doc.xsl"?>
<ivy-module version="1.0">
    <info organisation="my.organisation.net" module="myproject"
          revision="1.0-alpha-1"
          status="integration"
          publication="20051022053520">
        <license name="Apache" url="http://www.apache.org/licenses/LICENSE-2.0.txt"/>
        <ivyauthor name="Me" url="http://my.organisation.net/"/>
        <description homepage="http://my.organisation.net/myproject">
            My first Webwork2 based project.
            <br/>
        </description>
    </info>
    <configurations>
        <conf name="build" visibility="private"/>
        <conf name="default"/>
    </configurations>
    <publications>
        <artifact name="myproject" type="jar" conf="default"/>
    </publications>
    <dependencies>
        <!-- build only dependencies -->
        <dependency org="junit" name="junit" rev="3.8.1" conf="build->*"/>
        <dependency org="servletapi" name="servletapi" rev="2.4" conf="build->*"/>

        <!-- runtime (and build) dependencies -->
        <dependency org="log4j" name="log4j" rev="1.2.9" conf="default->default"/>
        <dependency org="apache-struts" name="action" rev="2.0+"
           conf="default->default,freemarker,sitemesh,jasperreports"/>
    </dependencies>
</ivy-module>

The following is a sample repository resolver configuration ivyconf.xml

<ivyconf>
    <properties file="ivyconf.properties"/>
    <conf defaultResolver="default" checkUpToDate="true"/>
    <resolvers>
        <ivyrep name="libraries"/>
        <chain name="default">
            <url name="apache-struts" checkmodified="true">
                <ivy pattern="http://struts.apache.org/[organisation]/[module]/ivy-[revision].xml"/>
                <artifact
pattern="http://struts.apache.org/[organisation]/[module]/[artifact]-[revision].[type]"/>
            </url>
            <url name="contegix">
               <ivy
pattern="http://repository.contegix.com/ivyrep/[organisation]/[module]/ivy-[revision].xml"/>
                <artifact
pattern="http://repository.contegix.com/ivyrep/[organisation]/[module]/[artifact]-[revision].[type]"/>
            </url>
            <ivyrep name="ivyrep"/>
            <ibiblio name="contegix-maven" root="http://repository.contegix.com/maven"/>
            <url name="maven">
                <artifact
pattern="http://www.ibiblio.org/maven/[organisation]/jars/[module]-[revision].[type]"/>
            </url>
        </chain>
    </resolvers>
</ivyconf>

After integrating an appropriate Ivy init task into your project build file, Ivy will resolve all dependencies required by your project and download the needed JARs. See Ivy documentation for more information on how to integrate Ivy in your own project, or just have a quick look at our build process.

Next: Big Picture