如何在IVY中复制没有提供库的运行时库 [英] How to copy runtime libraries without the provided ones in IVY
问题描述
我以为我不需要问这个,但是我没有任何进展.
I thought I wouldn't need to ask this but I am not having any progress.
此问题的解决方案: ivy如何将maven范围映射到ivy配置实际上是在理论部分解决问题.
The solution to this question: How are maven scopes mapped to ivy configurations by ivy actually addresses question but in its theoretical part.
我有此配置:
<conf name="compile" description="???" />
<conf name="runtime" description="???" extends="compile" />
<conf name="test" description="???" extends="runtime" />
<conf name="provided" description="???" />
假设我具有这种依赖性:
Assume I have this dependency:
<dependency org="org.apache.tomcat" name="servlet-api" rev="6.0.16" transitive="false" />
我想要的是:当我将ivy:retrieve绑定到.war lib目录之前将其复制到库中时,我只想复制所有运行时(并隐式编译),而没有servlet-api.
What I want is: when I invoke the ivy:retrieve to copy the libraries to the .war lib directory before bundling it, I want only to copy all runtime (and compile implicitly) but no servlet-api.
那么如何使用ivy:retrieve呢?
so how to use ivy:retrieve then?
<ivy:retrieve conf="WHAT_TO_PUT_HERE" />
以及如何配置依赖项:
<dependency conf="WHAT_IS_THE_CONF_MAPPING" org="org.apache.tomcat" name="servlet-api" rev="6.0.16" transitive="false" />
我在这里高原,因此,请提供任何帮助.
I'm plateauing here, so please any help would be appreciated.
知道servlet-api的ivy.xml定义了工件
Knowing that the ivy.xml for servlet-api defines the artifact with
conf="master"
所以我认为问题是如何真正"映射所提供的maven范围到所提供的IVY配置.
So I think the question is how to 'really' map Provided scope of maven to the provided configuration of IVY.
推荐答案
这是将依赖项映射到本地提供"配置的方式:
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"/>
配置映射如下:
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:
这意味着不需要"transitive = false"属性.
This means the "transitive=false" attribute is not required.
如何使用配置由您决定.第一种方法比较简单,但是我更喜欢第二种方法,因为我的配置报告与我的类路径内容匹配
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
您可以创建一个单一的类路径,如下所示:
You can create a single classpath as follows:
<ivy:cachepath pathid="compile.path" conf="compile,provided"/>
然后可以在javac任务中使用它,如下所示:
This can then be used in the javac task as follows:
<javac ... classpathref="compile.path">
..
选项2
或者我更喜欢在配置和类路径之间建立一二一映射:
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"/>
后一种方法的问题在于,javac任务需要具有如下明确声明的类路径用法:
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.
这篇关于如何在IVY中复制没有提供库的运行时库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!