gpt4 book ai didi

java - Gradle - 如何获取 ivy XML 文件

转载 作者:行者123 更新时间:2023-11-30 03:11:31 26 4
gpt4 key购买 nike

我有一个 gradle 脚本,基本上可以从我们公司的存储库中获取 jar 到当前工作目录中。
我想做的是添加一个任务,该任务还可以在另一个目录中提取 ivy.xml 文件。

build.gradle 看起来像这样:

repositories {  
ivy {
url 'protocol://repo.foocompany.com/'
credentials {
username "foo"
password "bar"
}
layout 'pattern', {
artifact '[organisation]/[module]/[module]-[revision].[ext]'
ivy '[organisation]/[module]/ivy-[revision].xml'
}
}

dependencies {
compile 'com.foocompany:bartifact:rev@ext'
}

task list << {
configurations.compile.each {
File file -> println file.name
}
}

// that's the part I actually use
task fetch(type: Copy) {
from configurations.compile
into System.getProperty("user.dir")
}

task fetchXml {
// and that's where I'm stuck no clue what I should put in there
}

运行脚本时,我的获取任务按预期工作:

$> gradle fetch  
Download protocol://repo.foocompany.com/com.foo/bartifact/ivy-rev.xml
Download protocol://repo.foocompany.com/com.foo/bartifact/bartifact-rev.ext
:fetch

$> ls
bartifact-rev.ext

我无法获取该 XML 文件。我已经尝试了很多东西,但除了手动从 gradle 的缓存中获取之外,我无法从其他任何地方获取它。

最佳答案

只需为 Ivy 文件添加一个新的 Ivy 存储库即可:

repositories {
ivy {
// Change the values here to match your environment.
url 'http://archiecobbs.github.io/ivyroundup/repo/modules/'
layout 'pattern', {
artifact '[organisation]/[module]/[revision]/ivy.[ext]'
}
}
}

configurations {
ivyFiles
}

dependencies {
ivyFiles 'org.apache.geronimo.specs:activation:1.1@xml'
}

task downloadIvyFiles(type: Copy) {
from configurations.ivyFiles
into temporaryDir
}

关于java - Gradle - 如何获取 ivy XML 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33541452/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com