gpt4 book ai didi

java - Gradle包含外部资源,包括包含文件夹

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

我正在转换使用Ant构建的项目以使用Gradle。该项目看起来像

root
|-RelevantProject
...
|-LotsOfOtherSubprojects
...
|-Resources
|--resources
|---subfolder
|----bunchOfProps.properties
该代码将它们引用为 Resources/resources/subfolder/bunchOfProps.properties。由于ant脚本需要保持运行,因此无法更改此代码和文件夹结构
我试图将其作为
sourceSets {
main {
resources {
srcDir '../Resources'
}
}
}
由于代码顶级文件夹现在被切断,因此失败。如果寻找 resources/subfolder/bunchOfProps.properties,该代码将起作用。
我也曾尝试 compile files('../Resources')遇到同样的问题。很难说,因为这个没有出现在Build目录中。我希望仅获取相关文件的 compile fileTree(dir: '../', include: '**/*.properties')也没有显示在build目录中。
仅将根目录用作资源文件夹会引起问题,因为它包含其他项目,甚至包括.gradle目录。我还没有以这种方式进行编译。尚不确定是否可以排除足够的东西使它正常工作。

最佳答案

如果您只需要复制文件

ext.prjRoot = project.projectDir.toString()

task copyExtResources(type: Copy) {
from prjRoot
include "Resources/**"
into "$buildDir/resources/main"
}

processResources.dependsOn copyExtResources

关于java - Gradle包含外部资源,包括包含文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62702963/

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