Java Reference
In-Depth Information
Maven archetypes
The Groovy-Eclipse plugin uses regular Java archetypes and adds Groovy functionality.
The GMaven approach in the next section includes a basic archetype to get started.
This generates a Java project with the standard layout, meaning the source code directory
is src/main/java and the testing directory is src/test/java. The quick start archetype includes
a trivial App.java and AppTest.java in those directories, respectively. The generator also
adds a standard Maven POM file in the root directory, whose only dependency is on JUnit,
as shown in the next listing.
Listing 5.8. The Maven pom.xml file for a standard Java project
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>mjg</groupId>
<artifactId>weather</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>weather</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The only change I've made so far from the standard is to upgrade the JUnit dependency to
4.10 from 3.8.1.
To do the actual work I need a class to send the request to Yahoo and parse the response,
and a POJO to hold the resulting weather information. Starting with the POJO, for a given
city, region, and country I want to store the condition, temperature, wind chill, and humid-
ity. The web service returns a lot more information than this, but this will suffice to get
started.
Search WWH ::




Custom Search