Versions Compared

Key

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

...

Code Block
titleInitial Build Successful
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] ------------------------------------------------------------------------Reactor Summary:
[INFO]
[INFO] Struts 2 .......................................... SUCCESS [6.016s]
[INFO] XWork: Core ....................................... SUCCESS [1:08.086s]
[INFO] Struts 2 Core .............................................. SUCCESS [02:42.870s604s]
[INFO] Struts 2 - CorePlugins ....................................... SUCCESS [1:170.272s944s]
[INFO] Struts 2 Spring API Plugin ............................ SUCCESS [13.523s]
[INFO] Struts 2 Convention Plugin ........................ SUCCESS [316.252s473s]
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 22 seconds
[INFO] Finished at: Wed Jul 19 10:46:01 PDT 2006
[INFO] Final Memory: 10M/42M
[INFO] ------------------------------------------------------------------------

Other phases

There are other phases that can be useful when working with Maven. The package phase will just JAR (or WAR) the modules. The test phase will only execute unit-tests. The compile phase will only build the source-code (but not the test sources). And the clean phase will remove all artifacts, typically the entire target directory.

Building IDE project files

Maven has a great feature that will allow you to build up your IDEA or Eclipse project files based on the project build structure. Using the Maven project files helps keep developers in-sync and efficient. The IDEA project files are pre-configured to define in the Run/Debug menu many common tasks, such as "execute all tests", "launch the showcase sample app", and so fort.

IDEA by JetBrains

The Maven IDEA plugin creates IDEA project and modules files, based on the Maven build configuraton (pom.xml).

First, be sure you have the latest IDEA plugin for Maven.

Code Block
titleGet the latest plugin!

mvn -DconnectionUrl=scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-idea-plugin \
    -Dgoals=install \
    scm:bootstrap

Most often, we use Maven to build projects, but it can also run plugins directly. To build an IDEA project file for Struts 2, including all the modules, run

Code Block
titleGenerate the project files

> mvn idea:idea -Papps,extras,thirdparty,xwork

Maven will generate struts-parent.ipr, struts-parent.iws, and an iml file for each module listed Open up struts-parent.ipr in IDEA, and you should be good to go.

If you ever need to rebuild your projects, running the idea:idea command again will update your files without overriding any information that doesn't conflict. If you do want to overwrite the project files, specify the overwrite parameter as true.

Code Block
titleStarting over

> mvn idea:idea -Doverwrite=true -Papps,extras,thirdparty,plugins,xwork

If you only need to rebuild some of the modules, adjust the list of "profiles".
Tip
titleClearing the cache

If you find the xwork module causing you problems, such as displaying as "XWork" when it should be named "xwork", the problem is likely to be within IDEA. Try clearing out your IDEA system cache and then run it again

Eclipse

For Eclipse, try

Code Block
titleGenerating Eclipse

> mvn -Pthirdparty,plugins,xwork eclipse:eclipse
Info
titleFeedback Wanted

Many Struts 2 developers use IDEA, and the Eclipse project files are not as well-tested or featureful as the IDEA versions. But as far as we know, they work!

IMPORTANT: Running the Sample Applications from Eclipse or non-IDEA IDEs

Currently the sample applications can be deployed using the Maven 2 Jetty plugin. For example, you can run the showcase example application from the command line:

Code Block
titleRunnning Showcase in Linux

cd apps/showcase
mvn jetty:run

You could also use one of the Maven IDE plugins to run the plugin or simply execute the mvn or mvn.bat file as an external application within your IDE.
A good tutorial on how to use the Maven 2 jetty plugin along with your IDE, including JPDA debugging support, can be found at the Apache Wicket documentation.

Maven Tips

A few helpful tips for using Maven are provided:

Skip exporting pages from Confluence

The whole Struts2 documentation resists on Confluence and during normal build process is exported with SiteExporter tool locally to html files. To perform that, you must have an account on Confluence. In most cases you don't need to export the whole Confluence, so you can skip this, just type command:

Code Block

mvn clean install -DskipWiki

Skip creating assemblies

During normal development cycle you don't need to create assembly packages which consist of all the libraries, example apps and docs - you can skip them as well:

Code Block

mvn clean install -DskipAssembly

Offline mode

If you are disconnected from the Internet or simply wish to make your build faster, pass in the -o argument and Maven won't check for new modules to download.

Code Block
titleOffline Mode

mvn -o -Pextras,plugins,xwork

OutOfMemoryError

If you get an OutOfMemoryError while running the tests:

Code Block
titleMemory Settings

// Bash
export MAVEN_OPTS=-Xmx512m

// Windows
set MAVEN_OPTS=-Xmx512m

Skipping test execution

Although this shouldn't ever happen, sometimes tests do fail and you need to build the framework anyway. If there's a problem, you can pass in the skip tests parameter.

Code Block
titleSkip Tests

mvn -Dmaven.test.skip=true -Pextras,plugins,xwork

Of course, if you find tests are failing, please submit a patch to fix them!

Debugging build failures

Struts 2 depends on the current snapshot artifact of XWork 2. Unfortunately, if XWork 2 is modified in a significant way, the Struts build doesn't check for and retrieve a new version of the XWork snapshot jar, resulting in compilation or unit test failures.

The solution is to clear out any stale XWork 2 jars in your local Maven repository, usually by removing the directory ~/.m2/repository/opensymphony. This will force the Struts Maven build to pull down a fresh copy of XWork and hopefully resolve your problem.

Creating a release

Maven terms a release build an "assembly". An assembly aggregates the builds of all the modules installed locally on your machine into one or more release files. The default profile for building Struts 2 includes an assembly that attempts to download a mirror of the wiki. This can be time-consuming, to disable the assembly module just add -DskipAssembly to your maven command line.

To create a release, you must first build and install locally every artifact. From the root struts2 directory, run:

Code Block
titleBuilding all modules

mvn -Pextras,apps,plugins install

Next, you need to run the assembly build to create the release files. From the struts2/assembly directory, run:

Code Block
titleBuilding the assembly

mvn assembly:assembly
 Struts 2 JUnit Plugin ............................. SUCCESS [13.325s]
[INFO] Webapps ........................................... SUCCESS [1.027s]
[INFO] Blank Webapp ...................................... SUCCESS [9.572s]
[INFO] JBoss Blank Webapp ................................ SUCCESS [7.814s]
[INFO] Mail Reader Webapp ................................ SUCCESS [7.028s]
[INFO] Struts 2 Portlet Plugin ........................... SUCCESS [20.995s]
[INFO] Struts 2 DWR Plugin ............................... SUCCESS [4.432s]
[INFO] Struts 2 Tiles Plugin ............................. SUCCESS [4.451s]
[INFO] Struts 2 Portlet Tiles Plugin ..................... SUCCESS [3.741s]
[INFO] Portlet Webapp .................................... SUCCESS [28.480s]
[INFO] Struts 2 Struts 1 Plugin .......................... SUCCESS [8.353s]
[INFO] Struts 2 Dojo Plugin .............................. SUCCESS [30.181s]
[INFO] Struts 2 JSF Plugin ............................... SUCCESS [6.000s]
[INFO] Struts 2 Configuration Browser Plugin ............. SUCCESS [7.531s]
[INFO] Struts 2 Sitemesh Plugin .......................... SUCCESS [6.159s]
[INFO] Struts 2 JSON Plugin .............................. SUCCESS [16.944s]
[INFO] Showcase Webapp ................................... SUCCESS [20.303s]
[INFO] Struts 2 REST Plugin .............................. SUCCESS [10.015s]
[INFO] Struts 2 Rest Showcase Example .................... SUCCESS [6.928s]
[INFO] Struts 2 Codebehind Plugin ........................ SUCCESS [10.394s]
[INFO] Struts 2 Java Templates Plugin .................... SUCCESS [9.633s]
[INFO] Struts 2 Jasper Reports Plugin .................... SUCCESS [5.920s]
[INFO] Struts 2 JFreeChart Plugin ........................ SUCCESS [18.296s]
[INFO] Struts 2 Pell Multipart Plugin .................... SUCCESS [3.891s]
[INFO] Struts 2 Plexus Plugin ............................ SUCCESS [4.715s]
[INFO] Struts 2 Sitegraph Plugin ......................... SUCCESS [8.009s]
[INFO] Struts 2 TestNG Plugin ............................ SUCCESS [6.012s]
[INFO] Struts 2 OVal Plugin .............................. SUCCESS [9.629s]
[INFO] Struts 2 OSGi Plugin .............................. SUCCESS [8.118s]
[INFO] Struts 2 Embedded JSP Plugin ...................... SUCCESS [30.524s]
[INFO] Struts 2 GXP Plugin ............................... SUCCESS [4.878s]
[INFO] Struts 2 CDI Plugin ............................... SUCCESS [7.620s]
[INFO] Struts 2 Tiles 3 Plugin ........................... SUCCESS [5.132s]
[INFO] Struts OSGi Bundles ............................... SUCCESS [0.254s]
[INFO] Struts 2 OSGi Admin Bundle ........................ SUCCESS [5.204s]
[INFO] Struts 2 OSGi Demo Bundle ......................... SUCCESS [4.582s]
[INFO] Struts 2 Maven Archetypes ......................... SUCCESS [0.198s]
[INFO] Struts 2 Archetypes - Angular JS .................. SUCCESS [10.509s]
[INFO] Struts 2 Archetypes - Blank ....................... SUCCESS [1.440s]
[INFO] Struts 2 Archetypes - Blank Convention ............ SUCCESS [1.324s]
[INFO] Struts 2 Archetypes - Database Portlet ............ SUCCESS [0.990s]
[INFO] Struts 2 Archetypes - Plugin ...................... SUCCESS [0.923s]
[INFO] Struts 2 Archetypes - Portlet ..................... SUCCESS [0.888s]
[INFO] Struts 2 Archetypes - Starter ..................... SUCCESS [1.992s]
[INFO] Struts 2 Assembly ................................. SUCCESS [1:37.556s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12:23.728s
[INFO] Finished at: Wed Oct 30 17:26:27 CET 2013
[INFO] Final Memory: 57M/945M
[INFO] ------------------------------------------------------------------------

Other phases

There are other phases that can be useful when working with Maven. The package phase will just JAR (or WAR) the modules. The test phase will only execute unit-tests. The compile phase will only build the source-code (but not the test sources). And the clean phase will remove all artifacts, typically the entire target directory.

Building IDE project files

Maven has a great feature that will allow you to build up your IDEA or Eclipse project files based on the project build structure. Using the Maven project files helps keep developers in-sync and efficient. The IDEA project files are pre-configured to define in the Run/Debug menu many common tasks, such as "execute all tests", "launch the showcase sample app", and so fort.

IDEA by JetBrains

The Maven IDEA plugin creates IDEA project and modules files, based on the Maven build configuraton (pom.xml).

First, be sure you have the latest IDEA plugin for Maven.

Code Block
titleGet the latest plugin!

mvn -DconnectionUrl=scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-idea-plugin \
    -Dgoals=install \
    scm:bootstrap

Most often, we use Maven to build projects, but it can also run plugins directly. To build an IDEA project file for Struts 2, including all the modules, run

Code Block
titleGenerate the project files

> mvn idea:idea -Papps,extras,thirdparty,xwork

Maven will generate struts-parent.ipr, struts-parent.iws, and an iml file for each module listed Open up struts-parent.ipr in IDEA, and you should be good to go.

If you ever need to rebuild your projects, running the idea:idea command again will update your files without overriding any information that doesn't conflict. If you do want to overwrite the project files, specify the overwrite parameter as true.

Code Block
titleStarting over

> mvn idea:idea -Doverwrite=true -Papps,extras,thirdparty,plugins,xwork

If you only need to rebuild some of the modules, adjust the list of "profiles".
Tip
titleClearing the cache

If you find the xwork module causing you problems, such as displaying as "XWork" when it should be named "xwork", the problem is likely to be within IDEA. Try clearing out your IDEA system cache and then run it again

Eclipse

For Eclipse, try

Code Block
titleGenerating Eclipse

> mvn -Pthirdparty,plugins,xwork eclipse:eclipse
Info
titleFeedback Wanted

Many Struts 2 developers use IDEA, and the Eclipse project files are not as well-tested or featureful as the IDEA versions. But as far as we know, they work!

IMPORTANT: Running the Sample Applications from Eclipse or non-IDEA IDEs

Currently the sample applications can be deployed using the Maven 2 Jetty plugin. For example, you can run the showcase example application from the command line:

Code Block
titleRunnning Showcase in Linux

cd apps/showcase
mvn jetty:run

You could also use one of the Maven IDE plugins to run the plugin or simply execute the mvn or mvn.bat file as an external application within your IDE.
A good tutorial on how to use the Maven 2 jetty plugin along with your IDE, including JPDA debugging support, can be found at the Apache Wicket documentation.

Maven Tips

A few helpful tips for using Maven are provided:

Skip exporting pages from Confluence

The whole Struts2 documentation resists on Confluence and during normal build process is exported with SiteExporter tool locally to html files. To perform that, you must have an account on Confluence. In most cases you don't need to export the whole Confluence, so you can skip this, just type command:

Code Block

mvn clean install -DskipWiki

Skip creating assemblies

During normal development cycle you don't need to create assembly packages which consist of all the libraries, example apps and docs - you can skip them as well:

Code Block

mvn clean install -DskipAssembly

Offline mode

If you are disconnected from the Internet or simply wish to make your build faster, pass in the -o argument and Maven won't check for new modules to download.

Code Block
titleOffline Mode

mvn -o

OutOfMemoryError

If you get an OutOfMemoryError while running the tests:

Code Block
titleMemory Settings

// Bash
export MAVEN_OPTS=-Xmx512m

// Windows
set MAVEN_OPTS=-Xmx512m

Skipping test execution

Although this shouldn't ever happen, sometimes tests do fail and you need to build the framework anyway. If there's a problem, you can pass in the skip tests parameter.

Code Block
titleSkip Tests

mvn -Dmaven.test.skip=true

Of course, if you find tests are failing, please submit a patch to fix them!

Debugging build failures

Struts 2 depends on the current snapshot artifact of XWork 2. Unfortunately, if XWork 2 is modified in a significant way, the Struts build doesn't check for and retrieve a new version of the XWork snapshot jar, resulting in compilation or unit test failures.

The solution is to clear out any stale XWork 2 jars in your local Maven repository, usually by removing the directory ~/.m2/repository/opensymphony. This will force the Struts Maven build to pull down a fresh copy of XWork and hopefully resolve your problemIf the assembly built correctly, you should see the release files in the target/assembly/out directory.

Mirrors

The default mirror for Maven builds ("ibiblio") can be slow and unreliable. Maven lets you specify alternative mirrors so that you don't have to depend on ibiblio for everything.

...