How to setup a java project with default, compile and test configurations using Ivy?

StackOverflow https://stackoverflow.com/questions/19386769

  •  30-06-2022
  •  | 
  •  

Вопрос

I am working on IBM RAD 8.5 and trying to configure Apache Ivy framework for my java project. As I am about to add Ivy managed library I do not see the compile and test configurations being listed. Is there a way I can add these configurations now?

Это было полезно?

Решение

Configurations are listed in your ivy file.

How to use ivy configurations

Ivy configurations can be used to emulate Maven scopes, but in fact an ivy configuration can represent any logical grouping of dependencies.

Here are the 3 standard classpaths required in any Java build:

<configurations>
    <conf name="compile" description="Required to compile application"/>
    <conf name="runtime" description="Additional run-time dependencies" extends="compile"/>
    <conf name="test"    description="Required for test only" extends="runtime"/>
</configurations>

Note the "extends" syntax that enables you to create larger sets. For example, the runtime set of jars also includes anything needed to compile the code your code.

Ivy configurations are difficult to understand until you realise that they can be used to selectively populate an ANT path:

<ivy:cachepath pathid="compile.path" conf="compile"/>

<javac ..... classpathref="compile.path"/>

Or used to selectively populate a directory

<ivy:retrieve pattern="build/WEB-INF/lib/[artifact].[ext]" conf="runtime"/>

Configuration mappings

Mappings are used to decide how groups of jars in your project relate to groups of jars in other projects.

This normally happens as follows:

<dependency org="org.slf4j" name="slf4j-api" rev="1.6.4" conf="compile->default"/>

Here our compile configuration is populate by the remote default configuration (normally the other modules compile dependencies)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top