在 ivy:publisher 中,默认的交付模式是 ${ivy.distrib.dir}/[type]s/[artifact]-[revision](-[classifier]).[ext]
我尝试通过向元素添加属性 e:classifier="" 在我的 ivy.xml 下设置分类器。
但是[分类器]没有设置?当 ivy:publish 在我的 build.xml 文件中运行时,它看起来是空的,因此不包含在文件名模式中。
我想我已经弄清楚了你的问题。
需要明确的是,确定存储库文件名的是配置的解析器,而不是发布任务。这是我的示例,它在工件和常春藤文件名模式中使用了两个额外的属性greeting和author :
<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
我有一个问题
属性分类器不允许出现在元素“工件”中
我只是在声明中添加了“额外”命名空间,并且能够使用分类器。
<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>
我遇到了同样的问题,我们找到了一种获取额外属性的方法。
我在 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" />
而已
我相信你想要这样的模式。如果问候语未定义,它将被忽略。
[作者]-[工件](-[问候语])-[修订].[ext]