当前位置: 动力学知识库 > 问答 > 编程问答 >

maven - Howto retrieve the latest Snapshot from Nexus OSS 3.0

问题描述:

We're currently using Nexus OSS 3.0.0-03 and I need to retrieve the latest Snapshot (or Snapshot-Name) via Console.

The Rest-API (.../service/local/artifact/maven/... ) mentioned in different other Posts is not available anymore in Nexus OSS 3.x (I get a 404 not found)

As described in https://books.sonatype.com/nexus-book/3.0/reference/scripting.html#_writing_scripts it is possible to write "own" Rest Calls but I found no documentation how to write them (No API-Doc, no example in https://github.com/sonatype/nexus-book-examples/tree/nexus-3.0.x)

Does anybody know if and how it is possible how to retrieve the Snapshot-Name

  • via URL
  • via "own" Rest-Script (e.g. repository.getLastestSnapshot(...)
  • via Gradle (like repositories.mavenDeployer)

网友答案:

There is currently no REST API or supported internal API to calculate the latest SNAPSHOT version.

网友答案:

Althow I do not recommend it there is a goal in the dependency plugin get. In conjunction with the "--update-snapshots" flag should work fine in your scenario.

网友答案:

I solved the Problem with a small Groovy-Script using Groovy Grapes:

@GrabResolver(name = 'my-SNAPSHOT', root = 'http://mynexus:8081/repository/Snapshot-Repo/', m2Compatible = 'true')
@Grab('commons-io:commons-io:1.2')
import org.apache.commons.io.*


public class exec {
    public static void main(String[] args) {
        try {
            def g = groovy.grape.Grape.grab(group: "com.x.x.x", module: args[0], version: args[1], ext: 'zip')
            def depfile = groovy.grape.Grape.resolve([:], [group: "com.x.x.x", module: args[0], version: args[1], ext: 'zip'])[0]
            def workingFile = new File("release.zip");
            FileUtils.copyFile(new File(depfile), workingFile)
        } catch(Exception e){
            println e
        }
    }
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: