【问题标题】:How does ivy:publish use the [classifier] attributeivy:publish 如何使用 [classifier] 属性
【发布时间】:2011-01-17 20:15:56
【问题描述】:

在 ivy:publisher 中,默认的交付模式是 ${ivy.distrib.dir}/[type]s/[artifact]-[revision](-[classifier]).[ext]

我尝试通过向元素添加属性 e:classifier="" 在我的 ivy.xml 下设置分类器。

但是[分类器]没有设置? 当 ivy:publish 在我的 build.xml 文件中运行时,它看起来是空的,因此不包含在文件名模式中。

【问题讨论】:

    标签: ant ivy


    【解决方案1】:

    我想我已经解决了你的问题。

    需要明确的是,确定存储库文件名的是配置的解析器,而不是 publish 任务。这是我的示例,它在工件和 ivy 文件名模式中使用了两个额外属性 greetingauthor

    <ivysettings>
        <property name="repo.dir" value="${ivy.basedir}/build/repo"/>
        <property name="ivy.checksums" value=""/> <!-- Suppress the generation of checksums -->
    
        <settings defaultResolver="internal"/>
    
        <resolvers>
            <filesystem name="internal">
                <ivy pattern="${repo.dir}/[module]/[author]-ivy(-[greeting])-[revision].xml" />
                <artifact pattern="${repo.dir}/[module]/[author]-[artifact]-[greeting]-[revision].[ext]" />
            </filesystem>
        </resolvers>
    </ivysettings>
    

    额外属性的值由ivy.xml文件决定:

    <ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
      <info organisation="myorg" module="hello" e:author="Mark"/>
      <publications>
        <artifact name="English" ext="txt" type="doc" e:greeting="hello"/>
        <artifact name="Irish" ext="txt" type="doc" e:greeting="dia_dhuit"/>
        <artifact name="Spanish" ext="txt" type="doc" e:greeting="Hola"/>
      </publications>
    </ivy-module>
    

    果然,当我发布文件时,greeting 和 author 标记的值就出现了:

    $ find build -type f
    build/repo/hello/Mark-English-hello-1.0.txt
    build/repo/hello/Mark-Irish-dia_dhuit-1.0.txt
    build/repo/hello/Mark-Spanish-Hola-1.0.txt
    build/repo/hello/Mark-ivy-1.0.xml
    

    【讨论】:

      【解决方案2】:

      我遇到了问题

      属性分类器不允许出现在元素'artifact'中

      我只是在声明中添加了“额外”命名空间,并且能够使用分类器。

      <ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd" 
             xmlns:e="http://ant.apache.org/ivy/extra"> 
      
          <dependency org="orphans" name="vaadin-timeline-cval" rev="2.0">
              <artifact name="vaadin-timeline-cval" e:classifier="1.3.1" ext="jar"/>
          </dependency>
      

      【讨论】:

        【解决方案3】:

        我相信你想要这样的模式。如果问候语未定义,它将被忽略。

        [作者]-[工件](-[问候语])-[修订].[ext]

        【讨论】:

          【解决方案4】:

          我遇到了同样的问题,我们找到了一种方法来获取额外的属性。

          我在 ivysettings.xml 中的示例看起来像...

          <resolvers>
          <filesystem name="internal">
              <ivy pattern="${repo.dir}/[module]/[author]-ivy(-[greeting])-[revision].xml" />
              <artifact pattern="${repo.dir}/[module]/[author]-[artifact]-[greeting]-[revision].[ext]" />
          </filesystem>
          

          在您的 ivy.xml 文件中,我输入了以下内容:请注意,我希望每次发布内容时问候值都是动态值 (${someValue})

          <ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
          <info organisation="myorg" module="hello" e:author="Mark"/>
          <publications>
              <artifact name="English" ext="txt" type="doc" e:greeting="${someValue}"/>
          </publications>
          

          这就是诀窍所​​在 -> 在我调用 ivy:publish 函数的构建文件中,必须将以下属性设置为 true (forcedeliver)

          <ivy:publish resolver="@{ivy.resolver}"
                   pubrevision="@{publish.revision}"
                   status="@{status}"
                   forcedeliver="true"
                   overwrite="@{overwrite}"
                   update="true" />
          

          就是这样

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2014-07-17
            • 1970-01-01
            • 2013-03-02
            • 2020-02-25
            • 2017-09-25
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多