gpt4 book ai didi

Gradle:使用依赖 jar 中的资源作为源集

转载 作者:行者123 更新时间:2023-12-04 12:39:07 25 4
gpt4 key购买 nike

假设我有一个 build.gradle因此:

dependencies {
compile 'com.group:some-app:1.0.1'
compile 'com.group:some-app:1.0.1:sources'
}

sourceSets {
main {
other {
srcDir 'src/main/other'
}
}
}

所以 some-app-1.0.1-sources.jar其中包含源文件 - 不是 Java 文件,而是可以从中生成 Java 的文件。

我如何在 sourceSets 中包含这些文件?

最佳答案

您可以动态地将源 jar 中的文件提取到一个目录中,并将该目录添加到源集。

configurations {
sourceJar
}

dependencies {
compile 'com.group:some-app:1.0.1'
sourceJar 'com.group:some-app:1.0.1:sources'
}

def generatedDir = "$build/other"
task extractFiles(type: Copy) {

from (zipTree(configurations.sourceJar.singleFile))

into generatedDir
}

sourceSets {
main {
resources {
srcDir generatedDir
}
}
}

关于Gradle:使用依赖 jar 中的资源作为源集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52081413/

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