Reputation: 17193
Recently I wanted to try the Apache Crunch library. For this purpose I learned about Maven.
To my understanding, in order to use a library one simply needs to add to the project's pom.xml
file the appropriate <dependency>..</dependency>
block, and build the project. All of the dependencies will be downloaded recursively by Maven.
My question is simply: is my understanding correct? Because in this example, I simply pasted the crunch-core
dependency in the pom
file, and only some of the dependencies were downloaded (thus I got ClassNotFoundException
s when running the application, which is what I want to avoid).
My question isn't related specifically to Crunch. I'm trying to verify if my understanding of how to use a third-party library using Maven is correct. Or if I'm missing something.
EDIT: I see my understanding is correct. Regarding my specific problem, here's my pom
:
<?xml version="1.0" encoding="UTF-8"?>
<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>aviv</groupId>
<artifactId>crunch-try</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.crunch</groupId>
<artifactId>crunch-core</artifactId>
<version>0.12.0-hadoop2</version>
</dependency>
</dependencies>
</project>
Any guess why the app fails? Am I expected to download additional dependencies separately?
Upvotes: 1
Views: 59
Reputation: 100050
Several of crunch-core's dependencies are marked 'provided'. This means that the crunch developers expect it to be used only in an environment where someone or something adds them to the classpath for you. You need to either run your app in the intended environment, or make manually add all those provided dependencies to your pom.
The only reason that provided dependencies are in the pom at all is that Maven does not (yet) distinguish between 'the content of the pom needed to build the thing' and 'the content of the pom that enables other things to use it.' Maven does not download these because the original author is saying, 'this jar needs to run inside hadoop, and these things are already in the classpath of hadoop.'
I read them at this convenient location.
Upvotes: 1