How to Open an Ant project (Nutch Source) at Intellij Idea?
Asked Answered
K

4

9

I want to open Nutch 2.1 source file (http://www.eu.apache.org/dist/nutch/2.1/) at Intellij IDEA. Here is an explanation of how to open it at Eclipse: http://wiki.apache.org/nutch/RunNutchInEclipse

However I am not familiar with Ant (I use Maven) and when I open that source file many classes are not known by Intellij. i.e.:

org.apache.hadoop.mapreduce.JobContext
org.apache.gora.mapreduce.GoraMapper

How can I add them to library or what should I do?

Kimmie answered 12/3, 2013 at 9:27 Comment(0)
M
4

I finally figure out how to do it. Now our team can dev nutch in IntellIJ

The process we do

  1. Get nutch source from apache.org

wget http://www.eu.apache.org/dist/nutch/2.3/apache-nutch-2.3-src.tar.gz

  1. Import nutch source in intellij

  2. Get Dependencies by Ant

    • Run ant runtime
    • Run ant test
  3. Import dependencies into Intellij

    • File > Project Structures
    • Library > Ivy
    • Click to Plus button
    • Select all libraries in apache-nutch-2.3/build/lib

Now we have a project with nutch source and all dependencies

Mourn answered 9/11, 2015 at 4:1 Comment(0)
C
1

I think, you should use ant build for nutch project. Because, pom.xml is problematical for nutch. If you want to use it anyway maven, you check maven dependency in pom.xml .

I think, the problem can be solved with the following:

  • You create new project via idea and add nutch source. Idea is not supported ivy ant project. You can install ivy plugin for idea, I suppose, Idea12 does not support it.

or

  • You can create ant project for nutch via eclipse and then save project. Then open the project on idea via eclipse classpath.

or

  • You can configure classpath. If you use ant build, you should add jars : File->ProjectStructure as follows:

Create a library click libraries

Attach Files to add jars

Then, if you use ant build, select jars from NUTCH_HOME/build/lib/* after build. select jars

If you use maven build, select jars from ~/.m2/* (MAVEN_REPO)

Cardio answered 21/5, 2013 at 23:25 Comment(0)
R
1

Although Intellij supports running ant scripts directly through the IDE via the ant plugin, the Intellij editor will not figure out the classpath using your build.xml file by itself.This will result in the editor showing the code littered with errors.

Unfortunately the only solution I found to this is to add all the jars manually.You can get all the jars needed by building the ant project using the ant jar command.

So these are the steps you need to follow :->

1.Run ant jar command in the root of your program

2.Copy all the jars created inside the build folder(they will not be directly inside build folder.I had to go from build->ivy->lib->{project name})

3.Paste these jars to a new folder created somewhere outside the directory

4.Go to File->Project Structure->Libraries. Press the + button.

5.Select all the copied jars and press ok to any prompts which appear.

6.Press finish and wait for indexing to complete.Any dependency errors in the editor should resolve now.

Note: Since you are manually adding jars, you would need to keep them in sync if you change your build.xml file for any dependency change.

Roodepoortmaraisburg answered 10/5, 2017 at 13:56 Comment(0)
P
0

It seems that dependencies are managed using Ivy (see the ivy folder in the sources archives), so you could try to install the Ivy plugin, which would allow you to fix your classpath issues.

Pharisaic answered 12/3, 2013 at 10:8 Comment(4)
How to use that plugin cos it seems nothing has changed?Kimmie
I guess you have to reimport the project (i.e. open ivy/ivy.xml using File > Open), if it works like the maven plugin... See also the Ivy plugin manualPharisaic
it just opens that file. On the other hand there is something Maven at Nutch sources. Is there any possibility to import it as a Maven project?Kimmie
If you just want to browse the sources and know Maven, perhaps you could try this: create a dummy maven project, open it in IDEA, add a dependency to nutch, let IDEA resolve the dependencies, open any class in nutch, and let IDEA automatically download the sources for you. You shouldn't have any missing class anymore.Pharisaic

© 2022 - 2024 — McMap. All rights reserved.