Differences between revisions 42 and 43
Revision 42 as of 2007-02-26 00:19:10
Size: 9169
Editor: WendySmoak
Comment:
Revision 43 as of 2009-09-20 23:12:37
Size: 9183
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
[[TableOfContents]] <<TableOfContents>>
Line 9: Line 9:
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 [http://maven.apache.org/maven-settings/settings.html settings model] and the Suggested Settings section below. 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 [[http://maven.apache.org/maven-settings/settings.html|settings model]] and the Suggested Settings section below.
Line 69: Line 69:
In [http://www.nabble.com/Re%3A-building-assemblies-from-the-top-level-project-directory-p4735063.html this post], John Casey explains why 'mvn assembly:assembly' is a separate command with Maven 2.0. In [[http://www.nabble.com/Re%3A-building-assemblies-from-the-top-level-project-directory-p4735063.html|this post]], John Casey explains why 'mvn assembly:assembly' is a separate command with Maven 2.0.
Line 73: Line 73:
The Maven 2 [http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html build lifecycle] includes a phase for integration testing. See [http://jira.codehaus.org/browse/MNG-1381 MNG-1381] and the [http://docs.codehaus.org/display/MAVEN/Testing+Strategies Testing Strategies] wiki page for more information. The Maven 2 [[http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html|build lifecycle]] includes a phase for integration testing. See [[http://jira.codehaus.org/browse/MNG-1381|MNG-1381]] and the [[http://docs.codehaus.org/display/MAVEN/Testing+Strategies|Testing Strategies]] wiki page for more information.
Line 210: Line 210:
 * [http://www.mergere.com/m2book_download.jsp Better Builds With Maven] - free book from Mergere (requires registration)
 * [http://www.developer.com/open/article.php/10930_3552026_2 This article] provides a good introduction to Maven 2 and lists some other useful goals.
 * [[http://www.mergere.com/m2book_download.jsp|Better Builds With Maven]] - free book from Mergere (requires registration)
 * [[http://www.developer.com/open/article.php/10930_3552026_2|This article]] provides a good introduction to Maven 2 and lists some other useful goals.

Struts Action Framework and Maven 2

Maven Setup

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

Local Install

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 Testing

The Maven 2 build lifecycle includes a phase for integration testing. See MNG-1381 and the Testing Strategies wiki page for more information.

Integration tests for Struts 1 are located under the integration module. Integration tests will only be run if the itest profile is enabled.

Apps

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.

Cactus Tests

The Cactus tests for Struts Taglib are not working and have been moved to the sandbox/apps-test/taglib-it module.

Suggested Settings

~/.m2/settings.xml

<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/

Snapshots

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.

Releases

References

TODO

StrutsMaintenanceMaven (last edited 2009-09-20 23:12:37 by localhost)