Friday, June 28, 2013

Adding external libraries (jar files) to an ivy project (Nutch)

I wanted to use my Apache Giraph fork in Apache Nutch 2.1. The Problem was that Giraph used mvn and Nutch used ivy. Although Nutch could fetch jar files from maven repositories, my customized jars are in none of those repos. So I had to find a way to use my local jars.


Add the following line to ivysettings.xml of Nutch:
<module organisation="org.apache.giraph" name=".*" resolver="internal"/>

Add the following lines to ivy.xml of Nutch:
    <dependency org="org.apache.giraph" name="giraph" rev="1.1.0-SNAPSHOT"
      conf="*->default" />
    <dependency org="org.apache.giraph" name="giraph-hbase" rev="1.1.0-SNAPSHOT"
      conf="*->default" />
    <dependency org="org.apache.giraph" name="giraph-examples" rev="1.1.0-SNAPSHOT"
      conf="*->default" />


Now create put jar files under .ivy2 subfolders:

/home/emre/.ivy2/local/org.apache.giraph/giraph/1.1.0-SNAPSHOT/jars/giraph.jar
/home/emre/.ivy2/local/org.apache.giraph/giraph-hbase/1.1.0-SNAPSHOT/jars/giraph-hbase.jar
/home/emre/.ivy2/local/org.apache.giraph/giraph-examples/1.1.0-SNAPSHOT/jars/giraph-examples.jar  

Now when you run ant runtime and start a crawling, you will see that your local jar files are binded to your app:
SLF4J: Found binding in [jar:file:/home/emre/tmp/apache-nutch-2.1/runtime/local/lib/giraph-1.1.0-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/emre/tmp/apache-nutch-2.1/runtime/local/lib/giraph-examples-1.1.0-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/emre/tmp/apache-nutch-2.1/runtime/local/lib/giraph-hbase-1.1.0-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]

No comments: