问题描述
到目前为止,我仅在构建中生成一个dist/imasUtils.jar
文件(使用Ant),并使用以下Ant代码对其进行公开:
Up until now, I was only generating a dist/imasUtils.jar
file in the build (using Ant), and publiching it with the following Ant code:
<ivy:resolve/>
<ivy:publish resolver="imas-ssh" overwrite="true" publishivy="true">
<artifacts pattern="dist/[artifact].[ext]"/>
</ivy:publish>
到目前为止,这是可行的,但是现在我也要发布源代码,因此我也在生成dist/imasUtils_src.zip
. 根据我对常春藤手册的理解,我可以做到这一点:
So far, this worked, but now I want to publish also the source, so I am also generating dist/imasUtils_src.zip
. According to my understanding of the ivy manual, I could do this:
<ivy:resolve/>
<ivy:publish resolver="imas-ssh" overwrite="true" publishivy="true">
<artifacts pattern="dist/[artifact](_[type]).[ext]"/>
</ivy:publish>
并且可以识别我的文件dist/imasUtils.jar
和dist/imasUtils_src.zip
,唯一的区别是,当我发布它们时,jar文件的type
属性将为null
.
and that would recognize both of my files dist/imasUtils.jar
and dist/imasUtils_src.zip
, the only difference is that when I published them the type
attribute would be null
for the jar file.
相反,我收到以下错误消息:
Instead, I am getting the following error message:
/[myDirectory]/build.xml:119: impossible to publish artifacts for net.conselldemallorca.imas#imasUtils;1.2.0:
java.io.IOException: missing artifact net.conselldemallorca.imas#imasUtils;1.2.0!imasUtils.jar
at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:225)
at org.apache.ivy.core.publish.PublishEngine.publish(PublishEngine.java:172)
at org.apache.ivy.Ivy.publish(Ivy.java:621)
at org.apache.ivy.ant.IvyPublish.doExecute(IvyPublish.java:311)
at org.apache.ivy.ant.IvyTask.execute(IvyTask.java:271)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
...
我的ivy.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">
<info organisation="net.conselldemallorca.imas"
module="imasUtils" revision="${ivy.revision}"/>
<publications>
<artifact />
</publications>
</ivy-module>
和我的组织ivy-settings.xml
文件:
<ivysettings>
<property name="ivy.pattern" value="artifacts/[organisation]/[module]/r[revision]/ivy-[revision].xml" override="false"/>
<property name="artifact.pattern" value="artifacts/[organisation]/[module]/r[revision]/[artifact].[ext]" override="false"/>
<settings defaultResolver="shared"/>
<resolvers>
<ssh name="imas-ssh" host="MYHOST" publishPermissions="0770">
<ivy pattern="/var/www/html/Ivy/${ivy.pattern}"/>
<artifact pattern="/var/www/html/Ivy/${artifact.pattern}"/>
</ssh>
<chain name="shared">
<url name="imas">
<ivy pattern="http://ivy.proves.imasmallorca.net/Ivy/${ivy.pattern}"/>
<artifact pattern="http://ivy.proves.imasmallorca.net/Ivy/${artifact.pattern}"/>
</url>
<ibiblio name="public" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>
我正在使用Apache Ant 1.9.3和Ivy 2.4.0
I am using Apache Ant 1.9.3 and Ivy 2.4.0
推荐答案
我怀疑问题可能是您在模式中定义类型"的方式.您还需要在常春藤文件的出版物部分中声明多个文件.
I suspect the problem might be the way you've defined the "type" in the pattern. You also need to declare more than one file in your ivy file's publications section.
我建议对您的常春藤文件进行以下更改:
I suggest the following change to your ivy file:
<ivy-module version="2.0" xmlns:e="http://ant.apache.org/ivy/extra">
<publications>
<artifact name="imasUtils" type="jar"/>
<artifact name="imasUtils" type="zip" e:classifier="src"/>
</publications>
以及发布任务模式的相应更改:
And corresponding change in the publish task's pattern:
<ivy:publish .. >
<artifacts pattern="dist/[artifact](_[classifier]).[ext]"/>
</ivy:publish>
分类器"是自定义额外的示例属性.
示例:
以下链接提供了更多有关常春藤如何与Maven存储库进行交互的说明,该存储库对源"属性具有固定的理解.
The following link provides more explanation on how ivy interacts with Maven repos which has a fixed understanding of a "sources" attribute.
这篇关于尝试在工件模式中使用可选令牌时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!