1

同じ jar の 2 つのバージョン (3.2 と 2.2.1) があります。両方を使用する必要がありますが、ivy は古いリビジョンを削除します。2つのバージョンを取るようにivyを設定するには?

    <dependency org="asm" name="asm-all" rev="3.2">
      <artifact name="asm-all" type="jar"/>
    </dependency>

    <dependency org="asm" name="asm-all" rev="2.2.1">
    <artifact name="asm-all" type="jar"/>
    </dependency>
4

1 に答える 1

2

アイビー構成を使用する必要があります。これは、依存関係の任意のグループを管理するための非常に柔軟なメカニズムです。

以下の例では、jar の各バージョンを個別の構成に配置します。これは、ivy cachepathタスクを使用して、後で 2 つのクラスパスを作成するために使用できます。

アイビー.xml

<ivy-module version="2.0">
    <info organisation="com.myspotontheweb" module="demo"/>

    <configurations>
        <conf name="compile1" description="Required to compile application1"/>
        <conf name="compile2" description="Required to compile application2"/>
    </configurations>

    <dependencies>
        <!-- compile1 dependencies -->
        <dependency org="asm" name="asm-all" rev="3.2" conf="compile1->master"/>

        <!-- compile2 dependencies -->
        <dependency org="asm" name="asm-all" rev="2.2.3" conf="compile2->master"/>
    </dependencies>

</ivy-module>

ノート:

  • バージョン 2.2.1は Maven Central に存在しません
  • 構成マッピング "??? -> master" に注意してください。Maven では、リモートマスター構成マッピングは依存関係なしでメイン モジュール アーティファクトに解決されます。(を参照)

build.xml

<project name="demo" default="init" xmlns:ivy="antlib:org.apache.ivy.ant">

    <target name="init" description="Use ivy to resolve classpaths">
        <ivy:resolve/>

        <ivy:report todir='build/ivy' graph='false' xml='false'/>

        <ivy:cachepath pathid="compile1.path" conf="compile1"/>
        <ivy:cachepath pathid="compile2.path" conf="compile2"/>
    </target>

    <target name="clean" description="Clean built artifacts">
        <delete dir="build"/>
    </target>

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

</project>

ノート:

  • アイビー レポートを生成することは常に良い考えです。どのアイビー構成にどの依存関係が存在するかがわかります。
  • この例では、ANT パスを管理する ivy を示しています。また、webapp WAR ファイルのようなものをアセンブルするときに、ivy retrieve タスクで ivy 構成を使用して、ローカルの「lib」ディレクトリにデータを入力することもできます。
于 2012-09-10T17:56:05.923 に答える