gpt4 book ai didi

android - 在buildSrc中访问ApplicationVariants

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

在我的应用程序中,我管理Gradle中的所有buildSrc内容。其中之一是buildTypes。我能够访问buildTypes提供的所有属性。但是,我无法访问applicationVariants中的buildSrc。有什么办法吗?

Sample code block in buildSrc/BuildTypes.kt


internal object Debug : BuildTypeCreator {
override val name = InternalBuildType.DEBUG

override fun create(
namedDomainObjectContainer: NamedDomainObjectContainer<BuildType>,
project: Project,
isLibrary: Boolean,
closure: BuildType.() -> Unit
): BuildType {
return namedDomainObjectContainer.maybeCreate(name).apply {
if (isLibrary) {
versionNameSuffix = "-dev-${project.gitSha}"
} else {
applicationIdSuffix = ".dev"
}
isTestCoverageEnabled = true
isMinifyEnabled = false
isDebuggable = true
closure.invoke(this)
}
}
}

Sample code block in app.gradle.kts(which I want to achieve the same in buildSrc)


applicationVariants.all { -> **This is not accessible in buildSrc**
if (buildType.name == getByName("release").name) {
outputs.all { output: BaseVariantOutput ->
val outputImpl = output as BaseVariantOutputImpl
outputImpl.outputFileName = "calendar-view.apk"
true
}
}
}

提前致谢。

最佳答案

好的,我通过传递参数domainObjectSet: DomainObjectSet<ApplicationVariant>解决了它

关于android - 在buildSrc中访问ApplicationVariants,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59684596/

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