在我的应用程序中,我管理Gradle在buildSrc中的所有内容。其中一个是buildTypes。我能够访问buildTypes提供的所有属性。但是,我不能在applicationVariants中访问buildSrc。有没有办法这样做?
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)
}
}
}示例代码块在app.gradle.kts中(我希望在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
}
}
}提前谢谢。
发布于 2020-01-10 15:44:35
好的,我解决了它传递了一个参数domainObjectSet: DomainObjectSet<ApplicationVariant>
https://stackoverflow.com/questions/59684596
复制相似问题