我没有构建Java项目的经验,我正在尝试为Solr构建一个标记器(在这里找到:https://github.com/LucidWorks/auto-phrase-tokenfilter)。我在编译期间得到一个关于无法解决的依赖项的错误。缺少的依赖项是org。Restlet和org.restlet.servlet。它们的存储库在这里:http://maven.restlet.com/org/restlet/jee/org.restlet/2.1.1/。Ant/Ivy/Maven似乎在repo1.maven.org上查找restlet依赖项。我不确定如何让艾薇在正确的地方找到这些。
我尝试手动下载restlet,但我不确定将jar文件放在哪里。它看起来像是在/usr/share/maven-repository/的某个地方,但是我没有运气把它们放在那里,我不确定如果我把它们放在正确的地方,ant/ivy/maven是否会在那里看。
任何帮助或指导将不胜感激。
下面是构建输出:
root@solrtest:/usr/src/auto-phrase-tokenfilter# ant
Buildfile: /usr/src/auto-phrase-tokenfilter/build.xml
init:
ivy-download:
ivy-init:
ivy-resolve:
[ivy:resolve] :: Apache Ivy 2.3.0 - 20130110142753 :: http://ant.apache.org/ivy/ ::
[ivy:resolve] :: loading settings :: file = /usr/src/auto-phrase-tokenfilter/ivy/ivy-settings.xml
[ivy:resolve] :: resolving dependencies :: com.lucidworks.demo#autophrase-tokenfilter;working@solrtest
[ivy:resolve] confs: [default, compile, test]
[ivy:resolve] found org.apache.lucene#lucene-analyzers-common;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-core;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-codecs;4.10.3 in central
[ivy:resolve] found org.apache.solr#solr-core;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-analyzers-kuromoji;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-analyzers-phonetic;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-expressions;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-grouping;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-highlighter;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-join;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-memory;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-misc;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-queries;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-queryparser;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-spatial;4.10.3 in central
[ivy:resolve] found org.apache.lucene#lucene-suggest;4.10.3 in central
[ivy:resolve] found org.apache.solr#solr-solrj;4.10.3 in central
[ivy:resolve] found commons-io#commons-io;2.3 in central
[ivy:resolve] found org.apache.httpcomponents#httpclient;4.3.1 in central
[ivy:resolve] found org.apache.httpcomponents#httpcore;4.3 in central
[ivy:resolve] found org.apache.httpcomponents#httpmime;4.3.1 in central
[ivy:resolve] found org.apache.zookeeper#zookeeper;3.4.6 in central
[ivy:resolve] found org.codehaus.woodstox#wstx-asl;3.2.7 in central
[ivy:resolve] found org.noggit#noggit;0.5 in central
[ivy:resolve] found org.slf4j#slf4j-api;1.7.6 in central
[ivy:resolve] found com.carrotsearch#hppc;0.5.2 in central
[ivy:resolve] found com.google.guava#guava;14.0.1 in central
[ivy:resolve] found com.google.protobuf#protobuf-java;2.5.0 in central
[ivy:resolve] found com.googlecode.concurrentlinkedhashmap#concurrentlinkedhashmap-lru;1.2 in central
[ivy:resolve] found com.spatial4j#spatial4j;0.4.1 in central
[ivy:resolve] found commons-cli#commons-cli;1.2 in central
[ivy:resolve] found commons-codec#commons-codec;1.9 in central
[ivy:resolve] found commons-configuration#commons-configuration;1.6 in central
[ivy:resolve] found commons-fileupload#commons-fileupload;1.2.1 in central
[ivy:resolve] found commons-lang#commons-lang;2.6 in central
[ivy:resolve] found dom4j#dom4j;1.6.1 in central
[ivy:resolve] found joda-time#joda-time;2.2 in central
[ivy:resolve] found log4j#log4j;1.2.17 in central
[ivy:resolve] found org.antlr#antlr-runtime;3.5 in central
[ivy:resolve] found org.apache.hadoop#hadoop-annotations;2.2.0 in central
[ivy:resolve] found org.apache.hadoop#hadoop-auth;2.2.0 in central
[ivy:resolve] found org.apache.hadoop#hadoop-common;2.2.0 in central
[ivy:resolve] found org.apache.hadoop#hadoop-hdfs;2.2.0 in central
[ivy:resolve] found org.eclipse.jetty#jetty-continuation;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-deploy;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-http;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-io;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-jmx;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-security;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-server;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-servlet;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-util;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-webapp;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty#jetty-xml;8.1.10.v20130312 in central
[ivy:resolve] found org.eclipse.jetty.orbit#javax.servlet;3.0.0.v201112011016 in central
[ivy:resolve] found org.ow2.asm#asm;4.1 in central
[ivy:resolve] found org.ow2.asm#asm-commons;4.1 in central
[ivy:resolve] found org.apache.lucene#lucene-test-framework;4.10.3 in central
[ivy:resolve] found com.carrotsearch.randomizedtesting#junit4-ant;2.1.6 in central
[ivy:resolve] found com.carrotsearch.randomizedtesting#randomizedtesting-runner;2.1.6 in central
[ivy:resolve] found junit#junit;4.10 in central
[ivy:resolve] found org.apache.ant#ant;1.8.2 in central
[ivy:resolve] found org.apache.solr#solr-test-framework;4.10.3 in central
[ivy:resolve] :: resolution report :: resolve 8098ms :: artifacts dl 47ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 59 | 0 | 0 | 0 || 57 | 0 |
| compile | 59 | 0 | 0 | 0 || 57 | 0 |
| test | 65 | 0 | 0 | 0 || 63 | 0 |
---------------------------------------------------------------------
[ivy:resolve]
[ivy:resolve] :: problems summary ::
[ivy:resolve] :::: WARNINGS
[ivy:resolve] module not found: org.restlet.jee#org.restlet;2.1.1
[ivy:resolve] ==== central: tried
[ivy:resolve] http://repo1.maven.org/maven2/org/restlet/jee/org.restlet/2.1.1/org.restlet-2.1.1.pom
[ivy:resolve] -- artifact org.restlet.jee#org.restlet;2.1.1!org.restlet.jar:
[ivy:resolve] http://repo1.maven.org/maven2/org/restlet/jee/org.restlet/2.1.1/org.restlet-2.1.1.jar
[ivy:resolve] module not found: org.restlet.jee#org.restlet.ext.servlet;2.1.1
[ivy:resolve] ==== central: tried
[ivy:resolve] http://repo1.maven.org/maven2/org/restlet/jee/org.restlet.ext.servlet/2.1.1/org.restlet.ext.servlet-2.1.1.pom
[ivy:resolve] -- artifact org.restlet.jee#org.restlet.ext.servlet;2.1.1!org.restlet.ext.servlet.jar:
[ivy:resolve] http://repo1.maven.org/maven2/org/restlet/jee/org.restlet.ext.servlet/2.1.1/org.restlet.ext.servlet-2.1.1.jar
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve] :: UNRESOLVED DEPENDENCIES ::
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve] :: org.restlet.jee#org.restlet;2.1.1: not found
[ivy:resolve] :: org.restlet.jee#org.restlet.ext.servlet;2.1.1: not found
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve]
[ivy:resolve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
BUILD FAILED
/usr/src/auto-phrase-tokenfilter/build.xml:115: impossible to resolve dependencies:
resolve failed - see output for details
Total time: 9 seconds
build . xml:
<project name="auto-phrase-tokenfilter" default="dist" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant" >
<description>Builds Autophrasing Token Filter</description>
<!-- set global properties for this build -->
<property name="build.dir" location="build"/>
<property name="dist.dir" location="dist"/>
<property name="build.lib.dir" value="${basedir}/build-lib"/>
<property name="src.dir" location="src/main/java"/>
<property name="classes.dir" location="${build.dir}/java" />
<property name="test.dir" location="src/test" />
<property name="test.classes.dir" location="${build.dir}/test" />
<property name="ivy.dir" location="${basedir}/ivy"/>
<property name="ivy.dep.file" location="ivy.xml" />
<property name="ivy.version" value="2.3.0"/>
<property name="ivy.lib.dir" location="${build.lib.dir}/ivy/lib" />
<property name="project.name" value="${ant.project.name}" />
<property name="version.number" value="1.0"/>
<!-- change this to include ivy download dest -->
<target name="set-classpaths" depends="ivy-retrieve" >
<path id="compile-classpath" >
<fileset dir="${ivy.lib.dir}/compile" includes="*.jar"/>
</path>
<path id="test-classpath">
<fileset dir="${ivy.lib.dir}/test" includes="*.jar"/>
</path>
</target>
<target name="init">
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build.dir}"/>
<mkdir dir="${classes.dir}"/>
<mkdir dir="${test.classes.dir}"/>
</target>
<target name="compile" depends="init,ivy-retrieve,set-classpaths" description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false" >
<classpath>
<fileset dir="${ivy.lib.dir}" includes="compile/*.jar" />
</classpath>
</javac>
</target>
<target name="compile-test" depends="compile" >
<javac srcdir="${test.dir}" destdir="${test.classes.dir}" includeantruntime="false" >
<classpath>
<fileset dir="${ivy.lib.dir}" includes="test/*.jar" />
<pathelement location="${classes.dir}" />
</classpath>
</javac>
</target>
<target name="dist" depends="compile,test" description="generate the distribution" >
<!-- Create the distribution directory -->
<ivy:resolve/>
<mkdir dir="${classes.dir}"/>
<jar jarfile="${dist.dir}/${project.name}-${version.number}.jar" basedir="${classes.dir}"/>
<!-- Add JavaDocs -->
</target>
<target name="clean" description="clean up" >
<!-- Delete the ${build.dir} and ${dist.dir} directory trees -->
<ivy:cleancache/>
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete dir="${ivy.lib.dir}"/>
</target>
<target name="test" depends="compile,compile-test">
<echo message=""/>
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<formatter usefile="false" type="plain"/>
<classpath>
<path refid="test-classpath"/>
<pathelement location="${classes.dir}"/>
<pathelement location="${test.classes.dir}" />
</classpath>
<assertions>
<enable/>
</assertions>
<test name="com.lucidworks.analysis.TestAutoPhrasingTokenFilter"/>
</junit>
</target>
<!-- Ivy -->
<condition property="ivy.jar.exists">
<or>
<available file="${build.lib.dir}/ivy-${ivy.version}.jar"/>
<isset property="offline"/>
</or>
</condition>
<target name="ivy-download" unless="ivy.jar.exists">
<mkdir dir="${build.lib.dir}"/>
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"
dest="${build.lib.dir}/ivy-${ivy.version}.jar"
usetimestamp="true"/>
</target>
<target name="ivy-init" depends="ivy-download" unless="skip.ivy" description="initialize ivy">
<path id="ivy.lib.path">
<fileset dir="${build.lib.dir}" includes="ivy-${ivy.version}.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
<ivy:settings file="${ivy.dir}/ivy-settings.xml"/>
</target>
<target name="ivy-resolve" depends="ivy-init" >
<ivy:resolve />
</target>
<target name="ivy-retrieve" depends="ivy-resolve" >
<ivy:retrieve pattern="${ivy.lib.dir}/[conf]/[artifact]-[revision].[ext]" sync="true" />
</target>
</project>
常春藤/ivy-settings.xml: <ivysettings>
<settings defaultResolver="central"/>
<resolvers>
<ibiblio name="central" m2compatible="true"/>
</resolvers>
</ivysettings>
这是我最终解决依赖问题的方法。我不确定我配置的哪个模块行是拾取依赖项的模块行。链就是这样做的——它将按照指定的顺序处理存储库。
<ivysettings>
<settings defaultResolver="my-chain"/>
<resolvers>
<chain name="my-chain">
<ibiblio name="restlet" m2compatible="true" root="http://maven.restlet.com"/>
<ibiblio name="central" m2compatible="true"/>
</chain>
</resolvers>
<modules>
<module organization="org.restlet.jee" resolver="restlet"/>
<module organization="restlet" resolver="restlet"/>
<module organization="org.restlet" resolver="restlet"/>
</modules>
</ivysettings>
我也有同样的错误,Ivy的更新问题。原来我已经取消了之前的构建一半,并在~/。在ivy2/cache目录中,工件有XML元数据,但没有jar。我删除了缓存中的目录,这为我解决了这个问题。