How to copy runtime libraries without the provided ones in IVY

前端 未结 1 681
夕颜
夕颜 2021-01-12 18:48

I thought I wouldn\'t need to ask this but I am not having any progress.

The solution to this question: How are maven scopes mapped to ivy configurations by ivy actu

相关标签:
1条回答
  • 2021-01-12 19:34

    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:

    • How are maven scopes mapped to ivy configurations by ivy

    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.

    0 讨论(0)
提交回复
热议问题