问题
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>
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>
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)
...
My ivy.xml
file:
<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>
and my organization ivy-settings.xml
file:
<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>
I am using Apache Ant 1.9.3 and Ivy 2.4.0
回答1:
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>
The "classifier" is an example of a custom extra attribute.
Example:
- Convert ivy.xml to pom.xml
The following link provides more explanation on how ivy interacts with Maven repos which has a fixed understanding of a "sources" attribute.
- how to publish 3rdparty artifacts with ivy and nexus
来源:https://stackoverflow.com/questions/28873991/error-when-trying-to-use-optional-token-in-artifacts-pattern