How to copy runtime libraries without the provided ones in IVY

自作多情 提交于 2019-12-01 06:05:30
Mark O'Connor

This is how you map a dependency onto the local "provided" configuration:

<dependency org="org.apache.tomcat" name="servlet-api" rev="6.0.16" conf="provided->master"/>

The configuration mapping works as follows:

provided->master
   ^        ^
   |        |
 Local    Remote
 config   config

As explained in the answer the special "master" configuration contains only the artifact published by this module itself, with no transitive dependencies:

This means the "transitive=false" attribute is not required.

Update

How you use the configuration is up to you. The first option is simpler, but I prefer the second approach because my configuration reports match my classpath contents

Option 1

You can create a single classpath as follows:

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

This can then be used in the javac task as follows:

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

Option 2

Or I prefer to have a one-2-one mapping between configurations and classpaths:

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

The problem with the latter approach is that the javac task need to have the classpath usage explicitly stated as follows:

<javac ...
   <classpath>
      <path refid="compile.path"/>
      <path refid="provided.path"/>
   </classpath>

I think this explicitly explains how you use this special provided scope, but it's really up to you.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!