Java Reference
In-Depth Information
5.4.1. The Groovy-Eclipse plugin for Maven
The Groovy-Eclipse compiler plugin ( http://mng.bz/2rHY ) is a standard compiler plugin
for Maven. It emerged from the effort to build a good Eclipse plugin for Groovy that
worked with combined Groovy and Java projects. The Maven plugin is a way to take ad-
vantage of that effort, whether you plan to use the Eclipse IDE or not.
To demonstrate its use I'll build a small project that accesses the Yahoo! Weather web ser-
vice and reports on the current conditions. This is easy enough to do in Java but becomes
particularly simple in Groovy.
The Yahoo! Weather web service ( http://developer.yahoo.com/weather/ ) provides weather
information in the form of an RSS feed. The web service is accessed from a URL of the
form
http://weather.yahooapis.com/forecastrss
The URL has two parameters, one required and one optional. The required parameter is
w , a so-called WOEID (Where On Earth ID), that Yahoo uses to identify a location. The
other parameter is u , which is used to specify the temperature units in Fahrenheit ( f , the
default) or Celsius ( c ). For unknown reasons, there's no way to programmatically look up
a WOEID. Instead Yahoo! directs you to its own weather page and suggests you search for
your city.
A simple HTTP GET request to the proper URL returns an XML response in RSS form. A
sample is included on Yahoo!'s web page.
Suppose I decided to build a simple application to retrieve the current weather conditions
based on this service. Maven recommends that you specify a particular artifact to begin the
project, so I'll start with the classic maven-archetype-quickstart :
> mvn archetype:generate -DgroupId=mjg -DartifactId=weather
-DarchetypeArtifactId=maven-archetype-quickstart
-Dversion=1.0-SNAPSHOT -Dpackage=mjg
Search WWH ::




Custom Search