Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Maven clients push content to Nexus using a normal HTTP "POST" operation. If all you want to do is publish content, then you don't need all the logic for downloading and resolving dependencies.... </p> <p>If you decide you need full-blown Maven repository interoperability then I'd suggest emulating what other projects like Groovy, Gradle and Scala have done, which is to embed <a href="http://ant.apache.org/ivy/" rel="nofollow">Apache Ivy</a>. </p> <p>I found the following article describing how to add ivy into your java project (Single jar dependency):</p> <p><a href="http://developers-blog.org/blog/default/2010/11/08/Embed-Ivy-How-to-use-Ivy-with-Java" rel="nofollow">http://developers-blog.org/blog/default/2010/11/08/Embed-Ivy-How-to-use-Ivy-with-Java</a></p> <h1>Groovy Example</h1> <p>Your question is specifically how to add support for publishing content.</p> <p>The following code uses ivy to publish to a Nexus repo. Groovy enables you to use <a href="http://ant.apache.org/ivy/history/latest-milestone/ant.html" rel="nofollow">Ivy's documented ANT tasks</a>. </p> <pre><code>import groovy.xml.NamespaceBuilder import groovy.xml.MarkupBuilder // Methods // ======= def generateIvyFile(String fileName) { def file = new File(fileName) file.withWriter { writer -&gt; xml = new MarkupBuilder(writer) xml."ivy-module"(version:"2.0") { info(organisation:"org.dummy", module:"dummy") publications() { artifact(name:"dummy", type:"pom") artifact(name:"dummy", type:"jar") } } } return file } def generateSettingsFile(String fileName) { def file = new File(fileName) file.withWriter { writer -&gt; xml = new MarkupBuilder(writer) xml.ivysettings() { settings(defaultResolver:"central") credentials(host:"myrepo.com" ,realm:"Sonatype Nexus Repository Manager", username:"deployment", passwd:"deployment123") resolvers() { ibiblio(name:"central", m2compatible:true) ibiblio(name:"myrepo", root:"http://myrepo.com/nexus", m2compatible:true) } } } return file } // Main program // ============ def ant = new AntBuilder() def ivy = NamespaceBuilder.newInstance(ant, 'antlib:org.apache.ivy.ant') generateSettingsFile("ivysettings.xml").deleteOnExit() generateIvyFile("ivy.xml").deleteOnExit() ivy.resolve() ivy.publish(resolver:"myrepo", pubrevision:"1.0", publishivy:false) { artifacts(pattern:"build/poms/[artifact].[ext]") artifacts(pattern:"build/jars/[artifact].[ext]") } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload