Maven3 pom using Groovy, Ruby, Scala, Yaml (Sonatype Polyglot)

By neokrates, written on July 8, 2010


  • Join date: 11-30-99
  • Posts: 224
View Counter:
Rate it
  • Trend: what general purpose computer language will dominate IT industry in the next decade?

    View Results

    Loading ... Loading ...
  • bodytext bodytext bodytext

During maven3 evaluation I have found this cool feature. Maven3 pom can be pom.groovy, pom.ruby etc. That creates much cleaner code and lets you integrate logic directly into the pom. And it already works!


✔ Maven3 polyglot 0.8-SNASPHOT

Should also work for:

✔ other Maven3 polyglot versions

✔ Maven3 (after and if it is integrated)


Future of Maven3: multy-language support is built in?

For now maven3 polyglot is not a part of maven3. And it hasn’t reached the 1.0 version as well.
For now it can build from pom files written in languages like Groovy and Scala, and in can transform your pom.xml into other languages like pom.ruby or pom.groovy.

My guess, it will be a part of maven3 tool after it is finished and stable… From what I could learn, it is going to happen (see “Read more” section )


Install maven3 polyglot

👉 Maven3 polyglot is NOT a part of Maven3 (maybe just yet, maybe it will never be).
So, having maven3 will not give you the capability to use another languages for pom.

Here is the site:

Get current version, unzip it in your favorite Maven location.

In my case, it is (M2_HOME=/opt/pmaven)

Then, in your .bashrc, .profile or anywhere you setup your environment, just add:


export PATH=$M2_HOME/bin:$PATH
cd maven3-groovy-test


Test it:

> mvn --version
Apache Maven 3.0-alpha-7 (r921173; 2010-03-09 23:31:07+0100)
Java version: 1.6.0_18
Java home: /opt/dev/lang/jdk1.6.0_18/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.31-20-generic" arch: "i386" Family: "unix"


Simple pom.groovy

pom.groovy is:

  • more readable
  • dynamic, can contain logic
  • shorter

Create some directory, called “groovy-test” and put pom.groovy with following source in it:

project {
    modelVersion '4.0.0'
    artifactId 'groovy-pom'
    groupId 'groovy-pom'
    version '0.0.1-SNAPSHOT'
    name 'groovy-pom'
    url ''
    def randomNumberClosure = { one, two ->
        println "Closures in pom :) "+ ( one + two )
    println "================================="
    println "================================="
    randomNumberClosure ( 10, 20 )
    build {
        testResources {
            testResource {
                filtering 'true'
                directory 'src/test/resources'
    profiles {
        profile {
            id 'development'
            properties {
                'log4j.level' 'DEBUG'
        profile {
            id 'production'
            properties {
                'log4j.level' 'WARN'

    properties {
        'log4j.level' 'info'


Run it

cd groovy-test
mvn compile

Read more

4) (Polyglot Maven)

Be Sociable, Share!

LEARN MORE (amazon bookstore)


Be Sociable, Share!

7 Responses to “Maven3 pom using Groovy, Ruby, Scala, Yaml (Sonatype Polyglot)”

  1. […] Maven3 pom using Groovy, Ruby, Scala, Yaml (Sonatype Polyglot) | […]

  2. […] Maven3 pom using Groovy, Ruby, Scala, Yaml (Sonatype Polyglot) | […]

  3. […] Maven3 pom using Groovy, Ruby, Scala, Yaml (Sonatype Polyglot) | […]

  4. Sam says:

    Please, please, please take whatever steps are necessary to get this into mainline Maven.  I’m so (@%*^$(ing sick and (@%*#^&^($ing tired of XML.  Besides food and drink, XML is a contributing factor to my participation in martial arts classes.  Gotta work out the frustration somehow, and beating on computing hardware just gets expensive after a while.

    • neokrates says:

      Hello Sam
      we have no influence over Sonatype guys. I suggest you tell them directly.
      I have worked with Polyglot maven and liked it very much. You can also try to use polyglot in your project, especially because you hate XML so much:) And if you try it, we would love to hear  how Polyglot worked out for you.

Leave a Reply