我希望使用Gradle为不同的客户构建Java库。是否有像Android中的产品风味一样的东西在“纯” Gradle中已知?谢谢。
plugins {
id 'jvm-component'
id 'java-lang'
}
model {
buildTypes {
debug
release
}
flavors {
free
paid
}
components {
server(JvmLibrarySpec) {
sources {
java {
if (flavor == flavors.paid) {
// do something to your sources
}
if (builtType == buildTypes.debug) {
// do something for debuging
}
dependencies {
library 'core'
}
}
}
}
core(JvmLibrarySpec) {
dependencies {
library 'commons'
}
}
commons(JvmLibrarySpec) {
api {
dependencies {
library 'collections'
}
}
}
collections(JvmLibrarySpec)
}
}