Hi,
I can’t compile my java class using my |pom.xml|, and I can’t find the
problem. Can anyone help me to point what it is wrong?
Directory structure
|hadoop-wordcount-coc$ tree
.
├── output.txt
├── pom.xml
└── src
└── org
└── apache
└── hadoop
└── mapred
└── examples
├── WordCount.java
└── workbench.xmi
|
output of the jar created with with |pom.xml|
|hadoop-wordcount-coc$ jar tf target/wordcount.jar
META-INF/
META-INF/MANIFEST.MF
META-INF/maven/
META-INF/maven/org.apache.hadoop.mapred.example/
META-INF/maven/org.apache.hadoop.mapred.example/WordCount/
META-INF/maven/org.apache.hadoop.mapred.example/WordCount/pom.xml
META-INF/maven/org.apache.hadoop.mapred.example/WordCount/pom.properties
|
|pom.xml|
|hadoop-wordcount-coc$ cat pom.xml
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.hadoop.mapred.example</groupId>
<artifactId>WordCount</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>WordCount CoC</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.7</jdk.version>
<junit.version>4.11</junit.version>
<log4j.version>1.2.17</log4j.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-api</artifactId>
<version>2.6.0</version>
</dependency>
</dependencies>
<build>
<finalName>wordcount</finalName>
<sourceDirectory>${basedir}/src/org/apache/hadoop/mapred/examples</sourceDirectory>
<plugins>
<!-- download source code in Eclipse, best practice -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
</configuration>
</plugin>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<includes>
<include>src/**/*.java</include>
</includes>
</configuration>
</plugin>
<!-- Compile the code -->
<!-- plugin>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<mainClass>org.apache.hadoop.mapred.examples.WordCount</mainClass>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<groupId>org.codehaus.mojo</groupId>
<version>1.2.1</version>
</plugin -->
<!-- Make this jar executable -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<mainClass>org.apache.hadoop.mapred.examples.WordCount</mainClass>
<excludes>
<exclude>**/log4j.properties</exclude>
</excludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>org.apache.hadoop.mapred.examples.WordCount</mainClass>
<classpathPrefix>dependency-jars/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<!-- Copy project dependency -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- exclude junit, we need runtime dependency only -->
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>target</directory>
<includes><include>**/*.class</include></includes>
</resource>
<resource>
<directory>src/main/resources/META-INF</directory>
<targetPath>${basedir}/target</targetPath>
<includes> <include>log4j.properties</include>
<include>servers.json</include> </includes>
</resource>
</resources>
</build>
</project>
|