How does ivy:publish use the [classifier] attribute

天大地大妈咪最大 提交于 2019-11-29 04:30:28

I think I've figured out your problem.

Just to be clear it is the configured resolver that determines the repository filename and not the publish task. Here's my example, which utilises two extra attributes greeting and author in the artifact and ivy filename patterns:

<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>

The values of the extra attributes are determined by the ivy.xml file:

<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>

Sure enough when I published the files the values of the greeting and author tags were present:

$ 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

I had a problem with

Attribute classifier is not allowed to appear in element 'artifact'

I simply added the "extra" namespace in my declaration and was able to use the classifier.

<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>

I believe you want the pattern like so. If the greeting isn't defined it will be left out.

[author]-[artifact](-[greeting])-[revision].[ext]

I faced the same issue and we found a way to get the extra attribute in.

my example in the ivysettings.xml look something like...

<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>

and in your ivy.xml file i put the following: please note that i wanted the greeting value to be dynamic value everytime i publish something (${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>

Here is where the trick come in -> In my build file where i call the ivy:publish function, the following attribute have to be set to true (forcedeliver)

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

That's it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!