Posts

Showing posts with the label Maven

Maven Lifecycle Phases - Fitting in Code Analysis and Other Tools

Image
The build management portion of Maven operates on a type of Template Pattern. Maven moves from lifecycle-phase to lifecycle-phase until there a step failure or until all steps are complete. The following diagram lists the build lifecycle phases. The orange squares represent the main targets that people run. Every phase is executed starting with Validate until the requested end phase is reached. For example "mvn validate"  runs just the Validate  phase. " mvn compile" runs Validate, Initialize, Generate Sources, Process Sources, Generate Resources, Process Resources and Compile. Each Maven Plugin  executes with in a phase. The Surefire  unit test plugin, as an example, typically runs the tests in the Test  phase.  This means that unit tests don't run if Validation, Compilation, class processing or any of the other preceding phases run with errors. Maven plugins can execute in their default phase or in any phase of your choosing.  Lifecy...

Creating an Eclipse Dynamic War project from a Maven project is easy

The Maven Eclipse plugin is a great tool that lets you create an Eclipse project from a Maven project with just the mvn eclipse:eclipse command.  It always seems to work great on my big projects,probably  because someone has already done the configuration required to get the right information generated into .project and .classpath.   I've always struggled to make it work in a small demonstration or test project.  The maven constructed Eclipse project is never configured right and I can't run the war on my local Servlet container. Eclipse supports web files through the Eclipse Web Tools Project (WTP) project and through the Dynamic Web Facet when facets are enabled.  The Dynamic Web Facet is either missing or mis-configured after the  mvn eclipse:eclipse command. You must tell the Maven Eclipse Plugin (not to be confused with m2e) to use WTP when building the Eclipse project. The simplest command is:        mvn -Dwtpversion=2.0 ec...