2011-09-02 2 views
18

私はANTを使って私のものをTomcatに配備していました。しかし、私は依存関係がなくて困っていました。私はアイビーを追加したがりました。これは私のivy.xmlあるどのように解決するのですか?Apache Ivyでは、モジュールXの複数の成果物が同じファイルに取り込まれますか?

<!-- Ivy settings start--> 

    <condition property="ivy.home" value="${env.IVY_HOME}"> 
     <isset property="env.IVY_HOME" /> 
    </condition> 


    <target name="download-ivy" unless="offline" description="Download Ivy"> 
     <mkdir dir="${ivy.jar.dir}"/> 
      <!-- download Ivy from web site so that it can be used even without any special installation --> 
     <get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" 
      dest="${ivy.jar.file}" usetimestamp="true"/> 
    </target> 


    <target name="init-ivy" depends="download-ivy" description="Initialize Ivy"> 
     <!-- try to load ivy here from ivy home, in case the user has not already dropped 
     it into ant's lib dir (note that the latter copy will always take precedence). 
     We will not fail as long as local lib dir exists (it may be empty) and 
     ivy is in at least one of ant's lib dir or the local lib dir. --> 
     <path id="ivy.lib.path"> 
      <fileset dir="${ivy.jar.dir}" includes="*.jar"/> 
     </path> 
     <taskdef resource="org/apache/ivy/ant/antlib.xml" 
     uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/> 
    </target> 

    <target name="update" depends="init-ivy" description="Download project dependencies"> 
     <!-- edited for brevity --> 

     <ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]" /> 
     <!-- edited for brevity --> 
    </target> 


    <target name="clean-all" depends="clean" description="Purge ivy cache"> 
     <ivy:cleancache/> 
    </target> 

<!-- Ivy settings end--> 

<ivy-module version="2.0"> 
    <info organisation="org.apache" module="hello-ivy"/> 
    <dependencies> 
     <dependency org="commons-lang" name="commons-lang" rev="2.1"/> 
    </dependencies> 
</ivy-module> 

これは私のログです:

Buildfile: C:\Users\Jansu\workspace\HelloWorld\build.xml 
download-ivy: 
     [get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar 
     [get] To: C:\Users\Jansu\.ant\lib\ivy-2.2.0.jar 
     [get] Not modified - so not downloaded 
init-ivy: 
update: 
[ivy:retrieve] :: Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/ :: 
[ivy:retrieve] :: loading settings :: url = jar:file:/C:/Users/Jansu/.ant/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings.xml 
[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;[email protected] 
[ivy:retrieve] confs: [default] 
[ivy:retrieve] found commons-lang#commons-lang;2.1 in public 
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.1/commons-lang-2.1.jar ... 
[ivy:retrieve] ................................................................................................................................................................................................................................................................................................................................................................................................................. (202kB) 
[ivy:retrieve] .. (0kB) 
[ivy:retrieve] [SUCCESSFUL ] commons-lang#commons-lang;2.1!commons-lang.jar (1704ms) 
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.1/commons-lang-2.1-sources.jar ... 
[ivy:retrieve] ........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................ (255kB) 
[ivy:retrieve] .. (0kB) 
[ivy:retrieve] [SUCCESSFUL ] commons-lang#commons-lang;2.1!commons-lang.jar(source) (1819ms) 
[ivy:retrieve] downloading http://repo1.maven.org/maven2/commons-lang/commons-lang/2.1/commons-lang-2.1-javadoc.jar ... 
[ivy:retrieve] ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... 
[ivy:retrieve] ................................................................................................................................................................................................................................................................ (518kB) 
[ivy:retrieve] .. (0kB) 
[ivy:retrieve] [SUCCESSFUL ] commons-lang#commons-lang;2.1!commons-lang.jar(javadoc) (2817ms) 
[ivy:retrieve] :: resolution report :: resolve 2094ms :: artifacts dl 6357ms 
    --------------------------------------------------------------------- 
    |     |   modules   || artifacts | 
    |  conf  | number| search|dwnlded|evicted|| number|dwnlded| 
    --------------------------------------------------------------------- 
    |  default  | 1 | 1 | 1 | 0 || 3 | 3 | 
    --------------------------------------------------------------------- 
[ivy:retrieve] :: retrieving :: org.apache#hello-ivy 
[ivy:retrieve] confs: [default] 

これは

は今、私は私のbuild.xmlファイルにこれを追加しましたエラー:

BUILD FAILED 
    C:\Users\Jansu\workspace\HelloWorld\build.xml:177: impossible to ivy retrieve: java.lang.RuntimeException: problem during retrieve of org.apache#hello-ivy: java.lang.RuntimeException: Multiple artifacts of the module commons-lang#commons-lang;2.1 are retrieved to the same file! Update the retrieve pattern to fix this error. 

    Total time: 11 seconds 

このパターンからエラーが発生しているようですか? :

<ivy:retrieve pattern="lib/[conf]/[artifact]-[revision].[ext]" /> 

しかし、それは私に見えます。

提案がありますか?

<ivy:retrieve pattern="lib/[conf]/[artifact]-[type]-[revision].[ext]" /> 

それとも、ソースとJavadocを必要としない場合は、に依存関係を変更することができます:あなたは、各アーティファクトは、それが自分のローカルファイルの取得するように、タイプを含めるようにパターンを展開する必要が

答えて

29

<ivy-module version="2.0"> 
    <info organisation="org.apache" module="hello-ivy"/> 
    <dependencies> 
     <dependency org="commons-lang" name="commons-lang" rev="2.1" conf="default->master"/> 
    </dependencies> 
</ivy-module> 

これは、依存関係のマスターconf(jar)のみを取得します。

+0

ivyファイルの解析中に問題が発生しました:モジュールorg.apache#hello-ivyのコンフィグレーション 'master'に、commons-lang#commons-lang; 2.1 ' Jansu-PCはこの設定が存在しないため!ファイル:/ C:/Users/Jansu/workspace/HelloWorld/ivy.xml BUILD FAILED' – Jaanus

+0

@jaanusええ、私はそれを混ぜて、今これが正しいと願ってください:) – oers

+0

それは今、 'conf ='の後ろに何を書くべきかを知る。そして、これはアイビーについて知る必要があるのでしょうか?今私はここに新しい依存関係を書いて、それをすべてダウンロードします。なぜこれらのファイルを手作業でダウンロードしていないのですか?ちょうど、それは数秒を節約するか、または...? – Jaanus

関連する問題