m2eclipse as pillar of development
There are two main approaches for using Maven and Eclipse efficiently: The Eclipse plugins m2eclipse or IAM aim at integrating Maven and Eclipse seamlessly. Alternatively, the Maven Eclipse Plugin provides the goal eclipse:eclipse and generates the Eclipse project configuration from the command line. I prefer the seamless integration due to the main reasons given in table 1. As it seems more widely adopted than IAM, I have chosen m2eclipse.[3] There is a detailed side-by-side comparison of all three alternatives on the Codehaus wiki.[4]
| ||||||||||||||||||
Table 1: Comparison of approaches for using Maven and Eclipse together (only my main criterions) |
m2eclipse is still in the incubation phase. Nevertheless, as of version 0.10.0, I consider it as appropriate for enterprise IT usage - even in multi-module projects with EARs and WARs. But for all known bugs and problems, the developers should be provided with workarounds and information. The most obvious topics are spurious, but harmless error messages[5]-[7] and resource filtering in combination with WTP[8],[9].
The official m2eclipse way with project configurators
As of version 0.9.4 m2eclipse introduced the projectConfigurator extension point to support integration between Maven and Eclipse plugins. If an Eclipse plugin is registered as projectConfigurator, it will participate in the project imports, configurations and reconfigurations triggered by m2eclipse.[10],[11] The project configurator reads configurations of one ore more maven plugin from pom.xml and applies this configuration to the Eclipse project. One prominent project configurator integrates Maven and WTP.[12]
Let's take PMD[13] as our example for integration of Maven and Eclipse. PMD uncovers bad programming style using a set of rules. This ruleset is defined in a XML file called ruleset.xml for example. The PMD Eclipse plugin integrates these checks into the IDE. It uses the file .pmd for the Eclipse specific configuration parts.
Figure 2: PMD Eclipse plugin as project configurator (click to enlarge) |
Figure 2 shows how PMD integrates into Maven and Eclipse. A portable build with Maven outside of Eclipse involves the following steps:
- The Maven PMD plugin retrieves its configuration from pom.xml. The configuration states that the plugin depends on the build configuration project.
- Maven retrieves the build configuration project from the repository and adds it to the classpath. The build configuration project contains the PMD ruleset.
- The Maven PMD plugin reads the ruleset from the classpath and analyzes the java project.
- On checking out or editing pom.xml, m2eclipse initiates the configuration of the java project. It calls every project configurator that had been registered before.
- The project configurator of the PMD Eclipse plugin retrieves the configuration of the Maven PMD plugin from pom.xml.
- The project configurator adds the PMD project facet and the PMD builder to the project and creates the file .pmd.
- m2eclipse retrieves the build configuration project from the repository and adds it to the classpath.
- During builds or on user demand, the PMD Eclipse plugin analyzes the java project.
- m2eclipse is evolving much faster than PMD and Checkstyle.
- PMD and Checkstyle might consider the m2eclipse integration less important than other new features.
References
- ^ Ackermann, M. Solutions for Enterprise IT. "m2e-extensions or m2e-code-quality as Project Configurators for Checkstyle, PMD and FindBugs" [cited 2011 Feb 16]
- ^ Ackermann, M. Solutions for Enterprise IT. "Configure Eclipse Projects from Maven with AntRun and XMLTask" [cited 2011 Mar 6]
- ^ Stack Overflow Internet Services, Inc. Stack Overflow. "Which is the best Maven Eclipse plugin?" [cited 2011 Feb 6]
- ^ McWhirter B., Walding B. The Codehaus. "Eclipse Integration, Eclipse Integration" [cited 2011 Feb 6]
- ^ Eclipse Foundation, Inc. Eclipse.org. "IllegalArgumentException from IFolder#refreshLocal" [cited 2011 Feb 6]
- ^ Eclipse Foundation, Inc. Eclipse.org. "After installing m2eclipse i get error "A handler conflict occured"" [cited 2011 Feb 6]
- ^ Sonatype, Inc. Sonatype Forge. "Plug-in 'org.maven.ide.eclipse.refactoring' contributed an invalid Menu Extension" [cited 2011 Feb 6]
- ^ Sonatype, Inc. Sonatype Forge. "Web resources filtering with m2eclipse" [cited 2011 Feb 6]
- ^ Sonatype, Inc. Sonatype Forge. "Resources are always excluded" [cited 2011 Feb 6]
- ^ Sonatype, Inc. Sonatype Forge. "Extensible project configuration framework" [cited 2011 Jan 23]
- ^ Sonatype, Inc. Sonatype Forge. "ProjectConfigurator contributor guide" [cited 2011 Jan 23]
- ^ Sonatype, Inc. Sonatype Forge. "Integration with WTP" [cited 2011 Jan 23]
- ^ Geeknet, Inc. SourceForge. "PMD" [cited 2011 Jan 23]
- ^ Geeknet, Inc. SourceForge. "PMD Project Configurator" [cited 2011 Jan 23]
- ^ Hayes, P. Sonatype Forge. "Configure Eclipse project with specified additional natures" [cited 2011 Jan 16]
- ^ Geeknet, Inc. SourceForge. "eclipse-cs Release Notes Release 5.0.0final" [cited 2011 Jan 23]
- ^ Geeknet, Inc. SourceForge. "eclipse-cs Release Notes Release 5.0.2" [cited 2011 Jan 23]
No comments:
Post a Comment