Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 我可以使用ivy.xml文件中的属性来避免重复依赖项的版本号吗?_Apache_Dependencies_Ivy - Fatal编程技术网

Apache 我可以使用ivy.xml文件中的属性来避免重复依赖项的版本号吗?

Apache 我可以使用ivy.xml文件中的属性来避免重复依赖项的版本号吗?,apache,dependencies,ivy,Apache,Dependencies,Ivy,下面是我的ivy.xml现在的样子: <dependency org="org.springframework" name="org.springframework.core" rev="3.0.2.RELEASE" /> <dependency org="org.springframework" name="org.springframework.context" rev="3.0.2.RELEASE" /> <dependency org="org.spring

下面是我的ivy.xml现在的样子:

<dependency org="org.springframework" name="org.springframework.core" rev="3.0.2.RELEASE" />
<dependency org="org.springframework" name="org.springframework.context" rev="3.0.2.RELEASE" />
<dependency org="org.springframework" name="org.springframework.jdbc" rev="3.0.2.RELEASE" />
<dependency org="org.springframework" name="org.springframework.beans" rev="3.0.2.RELEASE" />
<dependency org="org.springframework" name="org.springframework.jms" rev="3.0.2.RELEASE" />

以下是我希望它看起来的样子:

<dependency org="org.springframework" name="org.springframework.core" rev="${spring.version}" />
<dependency org="org.springframework" name="org.springframework.context" rev="${spring.version}" />
<dependency org="org.springframework" name="org.springframework.jdbc" rev="${spring.version}" />
<dependency org="org.springframework" name="org.springframework.beans" rev="${spring.version}" />
<dependency org="org.springframework" name="org.springframework.jms" rev="${spring.version}" />


这可能吗?语法是什么?

语法正确。您所需要做的就是在某个地方设置ANT属性

比如说

ant -Dspring.version=3.0.2.RELEASE
另一种选择是将属性声明添加到ivysettings.xml文件中

<ivysettings>

    <property name="spring.version" value="3.0.2.RELEASE"/>

    <settings defaultResolver="maven2"/>
    <resolvers>
        <ibiblio name="maven2" m2compatible="true"/>
    </resolvers>
</ivysettings>

我最终使用XML实体进行替换。这会将所有内容保存在同一个文件中,这对于我的用例很重要

<?xml version="1.0"?>
<!DOCTYPE ivy-module [
    <!ENTITY spring.version "3.0.2.RELEASE">
]>
<ivy-module version="2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd">

    <info organisation="org" module="mod"/>

    <dependencies>
        <dependency org="org.springframework" name="org.springframework.core" rev="&spring.version;" />
        <dependency org="org.springframework" name="org.springframework.context" rev="&spring.version;" />
        <dependency org="org.springframework" name="org.springframework.jdbc" rev="&spring.version;" />
        <dependency org="org.springframework" name="org.springframework.beans" rev="&spring.version;" />
        <dependency org="org.springframework" name="org.springframework.jms" rev="&spring.version;" />
    </dependencies>
</ivy-module>

您可以使用如下所述的属性文件:



insite ivysettings.xml

酷!是否可以在
ivy.xml
中设置属性?这样所有的依赖项信息都可以放在一起。将属性声明放在常春藤设置文件中可以实现相同的目标,即保持依赖项信息在一起谢谢你的回答,但我还是选择了我的解决方案()因为我想将版本声明保存在同一个文件中。这在命令行上非常有效,但似乎与用于IntelliJ的IvyIdea插件不兼容。有什么建议吗?听起来好像常春藤插件没有选择设置文件。我不熟悉那个插件,所以不能提供权威性的建议。XML实体的大量使用。确实很有帮助。
<properties file="${ivy.project.dir}/build.properties" />