Java Magazine, Jan/Feb 2017
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2017 17 tools Apache Maven is the most widely used build tool for the JVM During the last decade it introduced new ideas such as dependency management and the usage of repositories to the development ecosystem The central repository also known as Maven Central is the default repository in Maven from which plugins and dependencies are downloaded It is an exchange hub for open source artifacts in the JVM ecosystem and is used by Maven and other build tools such as Gradle sbt Ant Ivy and others As such Maven continues to be an important tool for the open source community as well as for enterprise users XMLs Pros and Cons One common complaint from Maven users over the years is the use of XML as the markup language for the main build file in the project object model POM or pom xml for short XML was a natural choice when Maven was created more than 10 years ago It has proven to be very useful thanks to its stable structure well known syntax and the powerful tooling available for it However times change and XML is not the latest and greatest option anymore Today developers demand a terse syntax and features such as inlined scripts This article shows how Polyglot for Maven an open source project provides the ability to use Ruby YAML Groovy and other languages to define the POM On the surface Maven has always used the pom xml file A minimal pom xml file simply defines an identifier for the project It comprises the values for groupId artifactId and version the so called GAV coordinates see Listing 1 Listing 1 project modelVersion 400 modelVersion groupId com example project groupId artifactId hello world demo artifactId version 100 version project With this simple setup you can build your JAR archive and as part of that build you can assemble resources compile source code and test it and package the archive This simple example shows the power of Maven which derives from several built in conventions But it also shows how the verbose nature of the XML file can bury the important information In reality a pom xml file ends up typically being longer due to the inclusion of dependencies configuration information for plugins and other aspects about the build and the project at hand Picking up the pom xml file from the project directory parsing it and then proceeding to initiate the build by invok Polyglot for Maven Moving Maven into Scripting A new tool from the developer of Maven enables POM files to be written in Ruby YAML Groovy and other languages JASON VAN ZYL AND MANFRED MOSER
You must have JavaScript enabled to view digital editions.