Struts Action Framework and Maven 2
Download and install Maven 2 from http://maven.apache.org/.
Maven 2 does not use .properties files. Per-developer and per-system configuration is done in ~/.m2/settings.xml. (Where '~' represents the user's home directory.) For more information, refer to the settings model and the Suggested Settings section below.
Acquiring the Source Code
Checkout Source from Subversion
The Struts Subversion repository is organized into sub-projects. You can check out Struts Action 1 alone using this URL:
svn co https://svn.apache.org/repos/asf/struts/struts1/trunk struts1
Or you can check out all of the sub-projects, including the sandbox, with this:
svn co https://svn.apache.org/repos/asf/struts/current current
Snapshot or Distribution
The following instructions should work equally well from the 'src' directory of a Struts snapshot or distribution. If they don't, let us know!
Building with Maven
To build and install the framework artifacts (pom and jar files) in your local Maven repository:
~/svn/struts/current/struts1 $ mvn
(The default goal, configured in struts1/pom.xml is install.)
To clean up, which will delete all of the 'target' directories:
$ mvn clean
To build the example apps:
$ mvn -P apps or $ cd apps $ mvn
Binary and Source Assembly
To build the assemblies, enable the 'pre-assembly' profile (which produces the javadoc and source artifacts) as well as 'itest' and 'apps', and execute both 'install' and 'site':
~/svn/struts/current/struts1 $ mvn install site -P apps,itest,pre-assembly
And then create the assembly:
~/svn/struts/current/struts1/assembly $ mvn assembly:assembly
The output will be in 'assembly/target/assembly/out'.
NOTE: The 'assembly:assembly' goal must be run from struts1/assembly.
In this post, John Casey explains why 'mvn assembly:assembly' is a separate command with Maven 2.0.
Integration tests for Struts 1 are located under the integration module. Integration tests will only be run if the itest profile is enabled.
The integration/apps-it module contains tests to confirm that each example app starts and displays its default page:
~/svn/struts/current/action/integration/apps-it mvn -P itest
In addition, each module inherits Cargo plugin configuration (from apps/pom.xml) which will start Tomcat 5.x and deploy the app:
~/svn/struts/current/action/apps/[module] mvn package cargo:start
Then visit http://localhost:8080/webappname in your browser. This requires that the cargo.tomcat5x.home system property is set, usually either on the command line (-Dcargo.tomcat5x.home=...) or in ~/.m2/settings.xml. See the Suggested Settings section, below.
The Cactus tests for Struts Taglib are not working and have been moved to the sandbox/apps-test/taglib-it module.
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> ... <!-- Uncomment this when the 'central' repo on ibiblio is down See: http://maven.apache.org/guides/mini/guide-mirror-settings.html --> <!-- mirrors> <mirror> <id>ggi-project.org</id> <url>http://ftp.ggi-project.org/pub/packages/maven2</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors --> <servers> ... <!-- ** CYGWIN USERS ** SEE NOTE BELOW --> <server> <id>apache.snapshots</id> <username>yourid</username> <privateKey>/path/to/private/key</privateKey> </server> <server> <id>struts-staging</id> <username>yourid</username> <privateKey>/path/to/private/key</privateKey> </server> <server> <id>apache-site</id> <username>yourid</username> <privateKey>/path/to/private/key</privateKey> </server> </servers> <profiles> ... <profile> <id>cargo-config</id> <properties> <cargo.tomcat5x.home>c:/java/apache-tomcat-5.5.17</cargo.tomcat5x.home> <cargo.tomcat4x.home>c:/java/jakarta-tomcat-4.1.31</cargo.tomcat4x.home> </properties> </profile> <profile> <id>struts-staging</id> <repositories> <repository> <id>struts-staging</id> <url>http://people.apache.org/builds/struts/m2-staging-repository</url> <snapshots><enabled>false</enabled></snapshots> <releases><enabled>true</enabled></releases> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>cargo-config</activeProfile> </activeProfiles> </settings>
Note for Cygwin Users
Even though you execute mvn within the cygwin shell, Maven's deployer plugin looks under %HOMEPATH% for the known_hosts file. If it's not found, you'll be prompted to continue.
...blah blah ...blah bhah Using private key: C:\cygwin\home\myname\.ssh\id_dsa The authenticity of host 'people.apache.org' can't be established. DSA key fingerprint is 79:7c:cb:6a:44:47:b2:ef:5c:66:28:d7:40:0d:b1:f9. Are you sure you want to continue connecting? (yes/no): yes
So, unless you don't mind being interrupted at each project and module secure copy, just to type 'yes', you'll have to use this work-around.
- Create a directory ('.ssh' no quotes), which, by the way, Windows won't let you do from Windows Explorer -- how helpful (rolling eyes), so do it from cygwin:
$mkdir /cygdrive/c/Docu<hit tab to complete>/username/.ssh
- Copy your current known_hosts file over to where Maven can find it (you must have at least tried to ssh into people.apace.org, and said 'yes' to adding the host for this to work)
$cp /home/username/.ssh/known_hosts /cygdrive/c/Docu<hit tab to complete>/username/.ssh/
To deploy snapshots of all framework artifacts (pom and jar, including -sources and -javadoc):
mvn deploy -P pre-assembly
Maven will choose the appropriate repository from <distributionManagement> based on the version number. (The <snapshotRepository>, if the version number ends in -SNAPSHOT, the <repository>, otherwise.)
To avoid repeated password prompts, configure the apache.snapshots <server> in ~/.m2/settings.xml.
Better Builds With Maven - free book from Mergere (requires registration)
This article provides a good introduction to Maven 2 and lists some other useful goals.
- Consolidate the Examples application into the new Cookbook to reduce the size of the distribution
- Create a custom deployment plugin to handle promoting our test builds from cvs.apache.org/maven-snapshot-repository to www.apache.org/dist/maven-repository.
- Figure out how to run the Cactus tests in 'sandbox/apps-test/el-it' against the strutsel-exercise-taglib webapp which is in the 'apps' module.
- Fix the Cactus tests for Struts Taglib
Revisit the war plugin configuration for including the source code in the example webapps under WEB-INF/src. This is currently being done with an execution of the antrun plugin in apps/pom.xml. Martin mentions that a <webResources> element is present in the war plugin source, but it does not appear to be available in the latest released version.
Use <dependencyManagement> in action/trunk/pom.xml to control version numbers. Modules then declare only <groupId>/<artifactId> for dependencies. (A brief look says there isn't as much duplication as I thought; this might not be necessary.)