Paul C
Paul C

Reputation: 8497

Trying to convert ivy artifacts into maven - missing artifact exception for the pom, even though it is there

Not sure if I'm going about this the right way, but I have some artifacts that I'm trying to convert to maven using ivy ant tasks and push into my maven repo.

the component in question is mystuff.services.common.

First I make the pom...

    <ivy:makepom ivyfile="${ivy.lib.dir}/ivy/cache/myorg/mystuff.services.common/ivy-mystuff.services.common.xml" pomfile="${ivy.lib.dir}/ivy/cache/myorg/mystuff.services.common/poms/mystuff.services.common.pom">
        <mapping conf="default" scope="compile"/>
        <mapping conf="runtime" scope="runtime"/>
    </ivy:makepom>

Then a little hackery - I insert an artifact element in the ivy file using xml task. This works ok...

    <xmltask source="${ivy.lib.dir}/ivy/cache/myorg/mystuff.services.common/ivy-${resolved.revision}.xml" dest="${ivy.lib.dir}/ivy/cache/myorg/mystuff.services.common/ivy-${resolved.revision}.xml">
        <insert path="/ivy-module/publications" >
            <![CDATA[
               <artifact name="mystuff.services.common" type="pom"/>
            ]]>
        </insert>
    </xmltask>

Then I resolve/deliver/publish, as per various docs I've seen on how to do this.

    <ivy:resolve file="${ivy.lib.dir}/ivy/cache/myorg/mystuff.services.common/ivy-${resolved.revision}.xml"/>
    <!--<echoproperties/>-->
    <ivy:deliver conf="*" delivertarget="recursive-deliver"/>
    <ivy:publish resolver="myrepo-publish" publishivy="false" overwrite="true">
        <artifacts pattern="lib/myorg/[module]/[type]s/[artifact].[ext]"/>
    </ivy:publish>

And the error I get:

build.xml:235: impossible to publish artifacts for
  myorg#mystuff.services.common;1.0.1: java.io.IOException: missing artifact
  myorg#mystuff.services.common;1.0.1!mystuff.services.common.pom

If I leave out the pom from the artifacts in the ivy file, the other artifacts just publish fine.

What am I doing wrong?

This is what the ivy file looks like after inserting the pom entry for artifacts

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="../../ivy-doc.xsl"?>
<ivy-module version="1.0">

  <info organisation="myorg" module="mystuff.services.common" revision="1.0.1" status="integration" publication="20130206204156"/>

  <configurations>
    <conf name="default"/>
    <conf name="compile" extends="default"/>
  </configurations>

  <publications>
    <artifact name="services.common" type="jar" conf="compile"/>
    <artifact name="services.common~test" type="jar" conf="compile"/>

    <artifact name="services.common" type="javadoc-zip" ext="zip" conf="compile"/>
    <artifact name="services.common~test" type="javadoc-zip" ext="zip" conf="compile"/>

    <artifact name="services.common" type="src-zip" ext="zip" conf="compile"/>
    <artifact name="services.common~test" type="src-zip" ext="zip" conf="compile"/>

    <artifact name="com.myorg.mystuffservices.common" type="osgi-module" ext="jar" conf="compile"/>
    <artifact name="services.common" type="pom"/>
  </publications>

  <dependencies>
    <dependency org="org.testng" name="testng" rev="5.11" conf="compile->compile-15"/>
  </dependencies>

</ivy-module>

Upvotes: 0

Views: 1983

Answers (1)

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 78021

Your publish does not have an artifact pattern that finds the pom generated by your "makepom" task.

Either change the location or alternatively add an extra artifacts tag to your publish task:

<ivy:publish resolver="myrepo-publish" publishivy="false" overwrite="true">
    <artifacts pattern="lib/myorg/[module]/[type]s/[artifact].[ext]"/>
    <artifacts pattern="${ivy.lib.dir}/ivy/cache/myorg/mystuff.services.common/poms/mystuff.services.common.pom"/>
</ivy:publish>

I also don't understand why you're inserting a POM entry into you ivy file. Why don't you just list in your publications section?

For a detailed example see:

Upvotes: 2

Related Questions