Maven3 pom using Groovy, Ruby, Scala, Yaml (Sonatype Polyglot)By neokrates, written on July 8, 2010 |
article |
- neokrates
- Email: uwarov@yahoo.com
- Website: http://www.thinkplexx.com
- Join date: 05-31-09
- Posts: 20
What build management tool does your project or firm use?
- Buildr (47%, 15 Votes)
- Maven 2 (6%, 2 Votes)
- Ant (6%, 2 Votes)
- Maven (3%, 1 Votes)
- Maven 3 (3%, 1 Votes)
- Ivy (0%, 0 Votes)
- GAnt (0%, 0 Votes)
- Gradle (0%, 0 Votes)
- Rake (0%, 0 Votes)
- Raven (0%, 0 Votes)
- Any Make Type Tool (0%, 0 Votes)
Total Voters: 32
Loading ...
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!
Software:
Maven3 polyglot 0.8-SNASPHOT
Should also work for:
other Maven3 polyglot versions
Maven3 (after and if it is integrated)
| 1 |
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 )
| 2 |
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: http://polyglot.sonatype.org/
Get current version, unzip it in your favorite Maven location.
http://polyglot.sonatype.org/site-nexus/download/
In my case, it is (M2_HOME=/opt/pmaven)
Then, in your .bashrc, .profile or anywhere you setup your environment, just add:
M2_HOME=/opt/pmaven
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"
| 3 |
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 'http://maven.apache.org'
def randomNumberClosure = { one, two ->
println "Closures in pom
"+ ( one + two )
}
println "================================="
println "YES, WE CAN GROOVY POM's AND MORE"
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'
}
}
| 4 |
Run it
cd groovy-test mvn compile
Read more
1) http://polyglot.sonatype.org/development.html
2) http://www.mail-archive.com/dev@maven.apache.org/msg82018.html
3) http://www.sonatype.com/people/author/jason/
4) http://blog.xebia.fr/2009/11/27/devoxx-jour-4-maven-reloaded/ (Polyglot Maven)
|
LEARN MORE (amazon bookstore)
|
|
TAGS
|
|
RELATED
|
Pages
Posts
|
|
SOCIAL
|
|
INCOMING SEARCH TERMS
|



















[...] Maven3 pom using Groovy, Ruby, Scala, Yaml (Sonatype Polyglot) | thinkplexx.com [...]
Like or Dislike:
0
0
[...] Maven3 pom using Groovy, Ruby, Scala, Yaml (Sonatype Polyglot) | thinkplexx.com [...]
Like or Dislike:
0
0
[...] Maven3 pom using Groovy, Ruby, Scala, Yaml (Sonatype Polyglot) | thinkplexx.com [...]
Like or Dislike:
0
0
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.
Like or Dislike:
1
0
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.
Like or Dislike:
0
0