mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Refactoring toward mixed mode.
This commit is contained in:
parent
15efe61a74
commit
93415868b0
6 changed files with 17 additions and 11 deletions
|
@ -36,8 +36,9 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
|
|||
|
||||
fun resDirectories(project: Project) : List<File> = sourceDirectories(project, "res")
|
||||
|
||||
fun sourceDirectories(project: Project) : List<File> =
|
||||
sourceDirectories(project, project.projectInfo.sourceDirectory)
|
||||
fun sourceDirectories(project: Project) = project.projectInfo.sourceSuffixes.flatMap {
|
||||
sourceDirectories(project, it)
|
||||
}
|
||||
|
||||
/**
|
||||
* suffix is either "java" (to find source files) or "res" (to find resources)
|
||||
|
|
|
@ -7,12 +7,15 @@ import com.beust.kobalt.api.KobaltContext
|
|||
import com.beust.kobalt.api.Project
|
||||
import java.util.*
|
||||
|
||||
class LanguageInfo(val name: String, val suffix : String = name)
|
||||
|
||||
/**
|
||||
* Data that is useful for projects to have but should not be specified in the DSL.
|
||||
*/
|
||||
interface IProjectInfo {
|
||||
/** Used to determine the last directory segment of the flavored sources, e.g. src/main/JAVA */
|
||||
val sourceDirectory : String
|
||||
val languageInfos: List<LanguageInfo>
|
||||
|
||||
val sourceSuffixes: List<String>
|
||||
|
||||
val defaultSourceDirectories: HashSet<String>
|
||||
val defaultTestDirectories: HashSet<String>
|
||||
|
@ -37,9 +40,11 @@ interface IProjectInfo {
|
|||
fun dependsOnDirtyProjects(project: Project) = project.projectInfo.dependsOn.any { it.projectInfo.isDirty }
|
||||
}
|
||||
|
||||
abstract class BaseProjectInfo : IProjectInfo {
|
||||
abstract class BaseProjectInfo(override val languageInfos: List<LanguageInfo>) : IProjectInfo {
|
||||
abstract fun generate(field: BuildConfigField) : String
|
||||
|
||||
override val sourceSuffixes = languageInfos.map { it.suffix }
|
||||
|
||||
fun generate(type: String, name: String, value: Any) = generate(BuildConfigField(type, name, value))
|
||||
|
||||
fun generateFieldsFromContributors(project: Project, context: KobaltContext)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue