Java Groovy Grape没有下载新版本

Java Groovy Grape没有下载新版本,java,groovy,grape,Java,Groovy,Grape,我相信我已经正确地配置了所有内容,因此grape应该询问存储库是否有新的修订,但事实并非如此。只要jar存在于.groovy/grapes中,它就会使用它 我正在通过应用程序的API通过Java代码进行抓取,因此如果脚本有@grab,那么可能会有一些预处理不那么容易处理,如果这很重要的话 Map<String,Object> args = new HashMap<String, Object>(); args.put("validate", true); args.put

我相信我已经正确地配置了所有内容,因此grape应该询问存储库是否有新的修订,但事实并非如此。只要jar存在于.groovy/grapes中,它就会使用它

我正在通过应用程序的API通过Java代码进行抓取,因此如果脚本有@grab,那么可能会有一些预处理不那么容易处理,如果这很重要的话

Map<String,Object> args = new HashMap<String, Object>();
args.put("validate", true);
args.put("classLoader", gcl);

Map<String,Object> dependencies = new HashMap<String, Object>();
dependencies.put("group", groupID);
dependencies.put("module", artifactID);
dependencies.put("version", version);
dependencies.put("force", true);
dependencies.put("changing", true);

Grape.grab(args, dependencies);
grab(“测试”、“示例”、“1.0-SNAPSHOT”)正确返回-1版本。如果我随后上传新版本:

test
|----sample
|--------1.0-SNAPSHOT
|----------sample-1.0-20141125.185508-1.jar
|----------sample-1.0-20141125.185508-1.pom
|----------sample-1.0-20141125.191916-2.jar
|----------sample-1.0-20141125.191916-2.pom
grab(“test”、“sample”、“1.0-SNAPSHOT”)甚至不询问存储库是否有新内容,而是返回缓存的-1jar

grab(“test”、“sample”、“*”)向存储库请求元数据,但仍然返回缓存的jar,然后使grab(“test”、“sample”、“1.0-SNAPSHOT”)不工作(返回未找到)


我觉得我肯定错过了一些明显的东西…

我下意识的反应是你使用它的方式不是故意的,因此得到了奇怪的结果。相反,也许您应该更明确地获取依赖项,并将Grape/Grab排除在外

下面是一些示例代码,您可以如何做到这一点

def downloadArtifact(repo, groupId, artifactId, version, e) {
    println "Fetching ${artifactId}..."
    def artifactResUrl = "${nexusServerUri}${resolvePath}?r=$repo&g=$groupId&a=$artifactId&v=$version&e=$e"
    def artifactRes = new XmlSlurper().parse(artifactResUrl)
    def repoPath = artifactRes.data.repositoryPath
    def address = "${nexusServerUri}${contentPath}/${repo}${repoPath}"
    def filename = "${artifactId}-$version.${e}"
    def file = new File('lib', filename)
    def fos = new FileOutputStream(file)
    def out = new BufferedOutputStream(fos)
    out << new URL(address).openStream()
    out.close()
    println "Done."
}

nexusServerUri = 'http://some.server.com:8081/nexus'
resolvePath = '/service/local/artifact/maven/resolve'
contentPath = '/content/groups'
repo = 'sprn-maven2'
groupId = 'com.abc.somethign'
version = '1.0-SNAPSHOT'
e = 'jar'

downloadArtifact(repo, groupId, 'artifact-id', version, e)
def下载工件(repo、groupId、artifactId、version、e){
println“正在获取${artifactId}…”
def artifactresul=“${nexusServerUri}${resolvePath}?r=$repo&g=$groupId&a=$artifactId&v=$version&e=$e”
def artifactRes=new XmlSlurper().parse(artifactresul)
def repoPath=artifactRes.data.repositoryPath
def address=“${nexusServerUri}${contentPath}/${repo}${repoPath}”
def filename=“${artifactId}-$version.${e}”
def file=新文件('lib',文件名)
def fos=新文件输出流(文件)
def out=新的缓冲输出流(fos)
出来
test
|----sample
|--------1.0-SNAPSHOT
|----------sample-1.0-20141125.185508-1.jar
|----------sample-1.0-20141125.185508-1.pom
|----------sample-1.0-20141125.191916-2.jar
|----------sample-1.0-20141125.191916-2.pom
def downloadArtifact(repo, groupId, artifactId, version, e) {
    println "Fetching ${artifactId}..."
    def artifactResUrl = "${nexusServerUri}${resolvePath}?r=$repo&g=$groupId&a=$artifactId&v=$version&e=$e"
    def artifactRes = new XmlSlurper().parse(artifactResUrl)
    def repoPath = artifactRes.data.repositoryPath
    def address = "${nexusServerUri}${contentPath}/${repo}${repoPath}"
    def filename = "${artifactId}-$version.${e}"
    def file = new File('lib', filename)
    def fos = new FileOutputStream(file)
    def out = new BufferedOutputStream(fos)
    out << new URL(address).openStream()
    out.close()
    println "Done."
}

nexusServerUri = 'http://some.server.com:8081/nexus'
resolvePath = '/service/local/artifact/maven/resolve'
contentPath = '/content/groups'
repo = 'sprn-maven2'
groupId = 'com.abc.somethign'
version = '1.0-SNAPSHOT'
e = 'jar'

downloadArtifact(repo, groupId, 'artifact-id', version, e)