Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Most developers will never need to build the framework from source. The distribution package contains everything a developer needs to get started and become productive with the framework. For more on how to go to work with the distributed binaries right away, see Getting Started Ready, Set, Go!. However, there are situations when someone will want to build the framework from scratch. You may want to try out new tweaks and patches, or you might want to try writing your own tweak or patch.

Info

If you just want to use the latest development build, perhaps because a patch you need has been applied, you can also download a nightly build.

Getting the Sources

The source code for the framework is available as a distribution you can download directly or and from the source code repository.

...

The distributions of the framework contain all sources, as well as all needed libraries for building JARs and running. Distributions can be downloaded from the Apache Struts project.

...

Repository (SVN)

Use Subversion to checkout the source code.

Code Block
> cd C:\projects\Apache\
> svngit coclone https://svngit-wip-us.apache.org/repos/asf/struts2/trunk/struts.git

Building with Maven

The default build environment is Maven. To get started with Maven

  • Download Maven 23
  • Extract Maven 2 3 to a directory of your choice
    • (e.g. \opt\Apache\Maven\maven-23.03.43)
  • Add the bin folder under that directory to your system path
    • (e.g. PATH=%PATH%;C:\opt\Apache\Maven\maven-23.03.43)

Change to your framework home directory (e.g. C:\projects\Apache\struts-current\2.x) and run

Code Block
> cd C:\projects\Apache\struts\
> mvn clean install -Pall

That will take care of the basic maven build. There is a bunch more that you can do. Checkout out Building with Maven for more information.

Building with Ant

As and for an alternative, you can also build the framework using Ant and Ivy.

What is Ant

Ant is the defacto standard build tool for Java project. If you don't have Ant installed, it's each to download and setup. As with Maven, you can extract the Ant distribution to the folder of your choice, and then add the bin folder to your system path.

What is Ivy?

If you checked out the sources from the repository, you might have noticed that the lib directory is empty. Unfortunately this does not mean that the framework has no external dependecies. As a full featured MVC framework, it has lots and lots of dependencies. Of course, this means that there has to be some kind of dependency management.

Ivy is a free Java based dependency manager, with powerful features such as transitive dependencies, Maven repository compatibility, continuous integration, HTML reports and many more. Ivy is fully integrated with Ant, which many developers already use.

Note
titleSkipping dependency resolution

The build now knows the property "skip.ivy". This may be specified from build.properties file or from a command line ant execution with -Dskip.ivy=true. If set, dependency resolution via Ivy is omitted and build is done with current jars found in lib directory. This behaviour is turned on by default for builds from the distribution package.

JUnit and Clover

The full Ant build process will require JUnit and Clover.

  • Place a copy of junit.jar (>= 3.8.1) and clover.jar (>= 1.3.9) into your $ANT_HOME/lib directory (if not already exists).
    • If you don't have these jars at hand, look in the lib/build directory of your Struts module after you called ant init in the step before...
  • Our Clover license is found in the common directory of the struts module. Place the clover-license.jar into your $ANT_HOME/lib directory as well.

Now you are ready to ...

Build It

From the root of your project folder

Code Block

> ant

NOTE: The above assumes that the Struts build depends on a version of XWork which is available from a Maven repository. If this is not the case (e.g. when Struts depends on an unreleased XWork snapshot), you will need to build XWork yourself, and install it into your local Maven repository, before attempting to build Struts itself. See Building with Maven for instructions on building XWork.

JDK/JRE Compatibility

  • The framework requires JDK 1.4.2+ 7 to build. JDK 5.0 is not required for building.
  • Action2-based applications require JRE 1.4.2+ to run. JRE 5.0 is not required to run unless your application uses the optional xwork-tiger module, which adds some Java 5.0 specific features to the framework.
    Info

    Java 5 with Java 1.4 backward compatibility is being considered for Struts 2

Next: Documentation Style GuideNext: Building with Maven