【问题标题】:Ivy repository structure for module with multiple builds (profiles)?具有多个构建(配置文件)的模块的常春藤存储库结构?
【发布时间】:2012-03-01 12:54:20
【问题描述】:

我在 .NET 商店中使用 Ant 和 Ivy 进行依赖管理,并取得了很大的成功,但我无法找到解决此问题的方法。我的问题与具有多个不同配置文件的模块的存储库结构有关(因为缺少 更好的术语)。例如,我尝试在存储库中设置的模块(它是第 3 方库 - Castle)已针对不同版本的 .NET 平台进行编译。此发行版具有以下目录结构:

  • net35/Castle.Core.dll
  • net40clientprofile/Castle.Core.dll
  • sl3/Castle.Core.dll
  • sl4/Castle.Core.dll

我的 ivysettings.xml 文件的文件解析器设置如下:

<filesystem name="fs.resolver" cache="nn.repo.cache">
    <ivy pattern="${repository.dir}/[organisation]/[module]/[shortRevision]/[revision]/ivy.xml" />
    <artifact pattern="${repository.dir}/[organisation]/[module]/[shortRevision]/[revision]/[artifact].[ext]" />
</filesystem>

起初,我认为配置可以用于此,但没有 取得很大进展。如何在 Ivy.xml 文件中多次指定具有相同名称的工件?我不认为你可以。另外,如果我在存储库中添加子目录,我会 必须在 ivysettings.xml 中修改我的工件模式?

建议使用 Ivy 设置此模块的方法是什么? 这个模块的 Ivy.xml 文件是什么样的?会怎样 为此需要修改ivysettings.xml文件吗?

希望我不必为同一版本库的每个不同编译创建单独的模块。

提前感谢您的帮助。

【问题讨论】:

    标签: ant ivy


    【解决方案1】:

    在 ivy 中,您可以将 extra attributes 添加到模块工件中。

    项目设置:

    |-- build.xml
    |-- ivysettings.xml
    |-- ivy.xml
    `-- repository
        `-- myorg
            `-- Castle
                `-- 1.0
                    |-- ivy.xml
                    |-- net35
                    |   `-- Castle.Core.dll
                    |-- net40clientprofile
                    |   `-- Castle.Core.dll
                    |-- sl3
                    |   `-- Castle.Core.dll
                    `-- sl4
                        `-- Castle.Core.dll
    

    ivy.xml

    使用配置映射来选择要下载的工件:

     <ivy-module version="2.0">
        <info organisation="org.demo" module="demo"/>
        <dependencies>
            <dependency org="myorg" name="Castle" rev="1.0" conf="default->net35"/>
        </dependencies>
    </ivy-module>
    

    ivysettings.xml

    工件模式包括一个名为“profile”的extra attribute

    <ivysettings>
        <settings defaultResolver="local"/>
        <resolvers>
            <filesystem name="local">
                <ivy pattern="${ivy.settings.dir}/repository/[organisation]/[module]/[revision]/ivy.xml" />
                <artifact pattern="${ivy.settings.dir}/repository/[organisation]/[module]/[revision]/[profile]/[artifact].[ext]" />
            </filesystem>
        </resolvers>
    </ivysettings>
    

    repository/myorg/Castle/1.0/ivy.xml

    extra attribute“配置文件”用于区分模块内的工件。这些配置用于启用客户端模块的配置映射。

    <ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
        <info organisation="myorg" module="Castle" revision="1.0" status="release"/>
        <configurations>
            <conf name="net35"/>
            <conf name="net40clientprofile"/>
            <conf name="sl3"/>
            <conf name="sl4"/>
        </configurations>
        <publications>
            <artifact name="Castle.Core" type="dll" e:profile="net35" conf="net35"/>
            <artifact name="Castle.Core" type="dll" e:profile="net40clientprofile" conf="net40clientprofile"/>
            <artifact name="Castle.Core" type="dll" e:profile="sl3" conf="sl3"/>
            <artifact name="Castle.Core" type="dll" e:profile="sl4" conf="sl4"/>
        </publications>
    </ivy-module>
    

    【讨论】:

    • 马克,谢谢。关于您的回答,由于额外属性和配置具有相同的值,我不能只使用 [conf] 作为工件模式而不是添加额外属性吗?你可以在 ivysettings 中使用 [conf] 来解析文件吗?
    • 我也有同样的想法。但是,它不是那样工作的。试一试,你会发现它试图为工件模式的 [conf] 部分使用值“default”......那是因为“default”是在依赖声明中映射的配置。很难描述,但额外属性是向模块中的工件添加额外元数据的机制。另一方面,配置是一种决定检索哪些工件的机制。
    • 感谢您的洞察力,这将有很大帮助。
    猜你喜欢
    • 2012-12-23
    • 1970-01-01
    • 2018-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-02
    • 2014-10-23
    相关资源
    最近更新 更多