Dec 7, 2011

Aspect-oriented Maven POMs - it's like mixins already in Maven 3.0.3

Since December 2011 I am using what I call "Aspect-Oriented Maven POMs".

The main idea is to have sections in your pom (via profiles) which you turn on or off via the existence of a marker file. If you put, e.g. common config for using Google Web Toolkit (GWT) or Google App Engine or any other orthogonal set of dependencies, plugins and build settings, then you can use AO-POMs.

Our parent pom consists now of this structure:
... main shared part...

  
    gwt</id>
    
      
        uses-gwt.marker</exists>
      </file>
    </activation>
    ... parts specific to GWT (Google Web Toolkit) stuff ...
  </profile>
  
    gwt</id>
    
      
        uses-gae.marker</exists>
      </file>
    </activation>
    ... parts specific to GAE (Google AppEngine) stuff ...
  </profile>

Now we have our pom.xml and next to it each project can contain a 'uses-gwt.marker' file or a 'uses-gae.marker' file, or both. These marker files turn a section of the pom on (the profile).

A simple idea, but I still enjoy it in September 2014. Yes, this post was back-dated to when this was first posted in the wiki of an other project.

No comments:

Post a Comment