【问题标题】:Building Nutch Plugin: class dependency构建 Nutch 插件:类依赖
【发布时间】:2015-04-15 06:43:53
【问题描述】:

我写了一些 Nutch 插件,使用不同的扩展点,如协议、解析器等。这些插件在 eclipse 中完美运行。但是为了在 hadoop 集群上使用它们,它应该使用 ANT 构建。我的问题是,我在核心文件夹(src)内的一些新包中编写了一些类。这些类在不同的开发插件之间共享。我的问题是在开发插件的构建时,ANT 找不到提到的共享类,所以我无法成功完成构建过程。为了更好地理解我的问题这是我的一个插件的 build.xml:

<project name="filter-news" default="jar-core">

  <import file="../build-plugin.xml"/>

    <!-- Build compilation dependencies -->
        <target name="deps-jar">
          <ant target="jar" inheritall="false" dir="../lib-xml"/>
        </target>

        <!-- Add compilation dependencies to classpath -->
        <path id="plugin.deps">
          <fileset dir="${nutch.root}/build">
            <include name="**/lib-xml/*.jar" />
          </fileset>
        </path>

        <!-- Deploy Unit test dependencies -->
  <!-- Deploy Unit test dependencies -->

  <!-- for junit test -->

</project>

ivy.xml:

<ivy-module version="1.0">
  <info organisation="org.apache.nutch" module="${ant.project.name}">
    <license name="Apache 2.0"/>
    <ivyauthor name="Apache Nutch Team" url="http://nutch.apache.org"/>
    <description>
        Apache Nutch
    </description>
  </info>

  <configurations>
    <include file="../../..//ivy/ivy-configurations.xml"/>
  </configurations>

  <publications>
    <!--get the artifact from our module name-->
    <artifact conf="master"/>
  </publications>

  <dependencies>
<dependency org="mysql" name="mysql-connector-java" rev="5.1.31"/>
<dependency org="net.sourceforge.htmlcleaner" name="htmlcleaner" rev="2.2"/>
<dependency org="commons-jxpath" name="commons-jxpath" rev="1.3"/>

  </dependencies>

</ivy-module>

plugin.xml:

<plugin id="filter-news" name="Apache Nutch XML/HTML Parser/Indexing Filter" version="1.4" provider-name="nutch.org">

    <runtime>
        <library name="filter-news.jar">
            <export name="*"/>
        </library>
        <library name="ant-1.7.0.jar"/>
        <library name="ant-launcher-1.7.0.jar"/>
        <library name="jdom-1.1.jar"/>
        <library name="commons-jxpath-1.3.jar"/>
        <library name="htmlcleaner-2.2.jar"/>
        <library name="mysql-connector-java-5.1.31.jar"/>
    </runtime>

    <requires>
        <import plugin="nutch-extensionpoints"/>
    </requires>

    <extension id="org.apache.nutch.parse" name="Nutch XML/HTML Html parser filter" point="org.apache.nutch.parse.HtmlParseFilter">
        <implementation id="com.ictcert.nutch.filter.news.NewsHtmlFilter"                       class="com.ictcert.nutch.filter.news.NewsHtmlFilter" />
    </extension>
    <extension id="org.apache.nutch.indexer" name="Nutch XML/HTML Indexing Filter" point="org.apache.nutch.indexer.IndexingFilter">
        <implementation id="com.ictcert.nutch.filter.news.NewsIndexingFilter" class="com.ictcert.nutch.filter.news.NewsIndexingFilter"/>
    </extension>

</plugin>

当我尝试构建这个插件时,ant 找不到与位于 nutch (src) 核心部分的com.ictcert.nutch 包相关的所有类依赖项。而对于位于org.apache.nutch 的其他课程,我没有这样的问题。请您告诉我我的配置有什么问题,ANT 可以找到默认包但新包找不到。

【问题讨论】:

    标签: java ant nutch


    【解决方案1】:

    根据我的经验,实现 id 应该与您的扩展点具有相同的包结构。你可以试试看它是否能解决你的问题。

    【讨论】:

    • 你确定吗?你知道我在哪里可以更改包结构吗?可能有为此目的的 ant 配置。
    • 不要把你的过滤器放在 eclipse 中的 'com.ictcert.nutch.filter.news' 。你应该把它放在 'org.apache.nutch.parse.news' 下
    • 当我尝试从核心源创建一个 jar 文件时,将它们放入 lib 目录,问题就解决了。我不认为这是 nutch 的限制,我认为我的 build.xml 或 ANT 配置有问题,应该解决。 java中没有这样的限制,你的包结构在项目之间应该是相同的。
    • 很高兴知道这一点。我没说是java的限制,我以为是nutch的限制。你能仔细检查并运行爬虫吗?只是为了确保您的配置能够运行
    • 亲爱的@ameertawfik,是的,它可以工作,但我不想更改包名称,因为它使我的代码与 nutch 基础区分开来。因此应该有一些与nutch/ANT相关的配置。我正在寻找那个配置。
    猜你喜欢
    • 2017-08-14
    • 1970-01-01
    • 1970-01-01
    • 2012-05-03
    • 2015-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多