gpt4 book ai didi

Gradle,如何检索默认资源目录以添加文件

转载 作者:行者123 更新时间:2023-12-03 05:09:48 24 4
gpt4 key购买 nike

所以,我正在尝试为我们的 openvr kotlin port 自动下载 native 库。 .

使用 Gradle-Download-Task我设法下载了本地人(到构建目录):

task downloadNatives {
doLast {
// download directory listing via GitHub API
def dirBin = 'https://api.github.com/repos/ValveSoftware/openvr/contents/bin'
def content_linux32 = new File(buildDir, "directoryContents_linux32.json")
download {
src "$dirBin/linux32"
dest content_linux32
} // parse directory listing
def contents_linux32 = new groovy.json.JsonSlurper().parseFile(content_linux32, "utf-8")

// download files
download {
src contents_linux32.collect { it.download_url }
dest "buildDir/linux32"
}

现在我想把它们放在默认的资源目录下,即 src/main/resources
我尝试使用这些:
    println sourceSets.main.getResources()
println sourceSets.main.resources

但没有太大的成功..

那么,我应该改用什么?

最佳答案

一、在第二download block ,buildDir只是一个字符串而不是变量。

然后,您可以将文件下载到主要资源目录中:

download {
src contents_linux32.collect { it.download_url }
dest sourceSets.main.resources.srcDirs[0]
}

关于Gradle,如何检索默认资源目录以添加文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49980430/

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