title: Publish SNAPSHOT artifacts to Maven using IVY - what's the magic?
body: <p>We have a slight convoluted situation...</p>
  
  <p>For the most part we've been using IVY and ANT to manage our builds and dependencies. Now the company is moving towards using Maven. We have a set of projects called common libraries which are used by several of the core products.</p>
  
  <p>Common libraries use IVY and are published to an IVY repository. We also need to make common libraries available for our new Maven projects. So when common libraries get built and published, I've modified the script to publish to Maven (Artifactory) as well IVY. Here are the two targets that now get called when publishing the built IVY projects:</p>
  
  <pre><code>&lt;target name="publish-ivyrepo" depends="load-ivysettings"&gt;
      &lt;ivy:resolve file="ivy.xml"  /&gt; 
      &lt;ivy:publish 
          module="${ant.project.name}"
          artifactspattern="${dist.dir}/[artifact].[ext]" 
          resolver="integration" 
          pubrevision="${build.version}" 
          status="integration"    
          overwrite="true"
          update="true"/&gt;
  &lt;/target&gt;
  
  &lt;target name="publish-artifactory" depends="load-ivysettings"&gt;
      &lt;ivy:resolve file="ivy.xml"  /&gt; 
      &lt;ivy:publish 
          module="${ant.project.name}"
          artifactspattern="${dist.dir}/[artifact].[ext]" 
          resolver="artifactory" 
          pubrevision="${build.version}-SNAPSHOT" 
          status="integration"    
          overwrite="true"
          update="true"/&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p>And here is the IVY settings detailing the resolvers:</p>
  
  <pre><code>&lt;sftp name="integration" checkmodified="true" changingPattern=".*" host="host" user="ivy" userPassword="abc"&gt;
    &lt;ivy pattern="${ivy.integration.default.root}/${ivy.public.default.ivy.pattern}"/&gt;
    &lt;artifact pattern="${ivy.integration.default.root}/${ivy.public.default.artifact.pattern}"/&gt;
  &lt;/sftp&gt;
  &lt;url name="artifactory" checkmodified="false" changingPattern=".*" m2compatible="true"&gt;
    &lt;ivy pattern="http://server/artifactory/libs-snapshot-local/${maven.default.ivy.pattern}"/&gt;
    &lt;artifact pattern="http://server/artifactory/libs-snapshot-local/${maven.default.artifact.pattern}"/&gt;
  &lt;/url&gt;
  </code></pre>
  
  <p>This kind of works in that I now see the common library jars within Artifactory, with SNAPSHOT substituted for the unique timestamp. However, the source jar and the IVY xml file doesn't have SNAPSHOT substituted. Also, no POM file is being generated (though I dont know if this is necessary.</p>
  
  <p>So this appears to be okay, though there are questions around the need for the POM file and the version naming of the IVY xml and the source jar. However, when I now proceed to specify a dependency from one of the Maven projects to one of the SNAPSHOT versions of the common library projects, it complains that it cannot resolve the dependency:</p>
  
  <blockquote>
    <p>Missing artifact com.smartstream.common_library:common_library_dao:jar:4.0.0.5-4-SNAPSHOT:compile</p>
  </blockquote>
  
  <p>I've tried specifying the repositories to Artifactory via the POM file and via the Maven settings file will little success:</p>
  
  <pre><code>&lt;repository&gt;
      &lt;id&gt;test&lt;/id&gt;
      &lt;name&gt;simple test&lt;/name&gt;
      &lt;url&gt;http://server/artifactory/libs-snapshot&lt;/url&gt;
      &lt;releases&gt;
          &lt;enabled&gt;false&lt;/enabled&gt;
      &lt;/releases&gt;
      &lt;snapshots&gt;
          &lt;enabled&gt;true&lt;/enabled&gt;
      &lt;/snapshots&gt;
  &lt;/repository&gt;
  </code></pre>
  
  <p>What is strange is if I get IVY to publish a release as opposed to a SNAPSHOT into the libs-release-local repository of Artifactory, all resolves as you'd expect. Also, if I specify the unique timestamp as part of the dependency version (the substiute of SNAPSHOT), it also resolves it. So this shows that the Maven projects are able to resolve against Artifactory, just that something is going amiss with SNAPSHOT versions.</p>
  
  <p>I've dug around high and low with little hope on this issue. If you can provide any insight, that'll be highly appreciated.</p>