mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Clean up ProjectInfo.
This commit is contained in:
parent
638d16588e
commit
ff23b223cc
8 changed files with 26 additions and 34 deletions
|
@ -25,30 +25,41 @@ open class Project(
|
|||
val projectInfo: IProjectInfo) : IBuildConfig {
|
||||
|
||||
class ProjectExtra(project: Project) {
|
||||
val suffixesFound = hashSetOf<String>()
|
||||
|
||||
init {
|
||||
val suffixesFound : Set<String> by lazy {
|
||||
val sf = hashSetOf<String>()
|
||||
Kobalt.context?.let {
|
||||
project.sourceDirectories.forEach { source ->
|
||||
val sourceDir = File(KFiles.joinDir(project.directory, source))
|
||||
KFiles.findRecursively(sourceDir, { file ->
|
||||
val ind = file.lastIndexOf(".")
|
||||
if (ind >= 0) {
|
||||
suffixesFound.add(file.substring(ind + 1))
|
||||
sf.add(file.substring(ind + 1))
|
||||
}
|
||||
false
|
||||
})
|
||||
}
|
||||
println("Suffixes: " + suffixesFound)
|
||||
}
|
||||
sf
|
||||
}
|
||||
|
||||
val dependsOn = arrayListOf<Project>()
|
||||
|
||||
var isDirty = false
|
||||
|
||||
/**
|
||||
* @return true if any of the projects we depend on is dirty.
|
||||
*/
|
||||
fun dependsOnDirtyProjects(project: Project) = project.projectExtra.dependsOn.any { it.projectExtra.isDirty }
|
||||
|
||||
init {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialized as soon as all the projects are parsed. This field caches a bunch of things we don't
|
||||
* want to recalculate all the time, such as the list of suffixes found in this project.
|
||||
* This field caches a bunch of things we don't want to recalculate all the time, such as the list of suffixes
|
||||
* found in this project.
|
||||
*/
|
||||
lateinit var projectExtra : ProjectExtra
|
||||
val projectExtra = ProjectExtra(this)
|
||||
|
||||
val testConfigs = arrayListOf(TestConfig(this))
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ abstract class BaseJvmPlugin<T>: ConfigPlugin<T>(), IProjectContributor, ICompil
|
|||
private val allProjects = arrayListOf<ProjectDescription>()
|
||||
|
||||
fun addDependentProjects(project: Project, dependents: List<Project>) {
|
||||
project.projectInfo.dependsOn.addAll(dependents)
|
||||
project.projectExtra.dependsOn.addAll(dependents)
|
||||
with(ProjectDescription(project, dependents)) {
|
||||
allProjects.add(this)
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class IncrementalManager(val fileName: String = IncrementalManager.BUILD_INFO_FI
|
|||
var upToDate = false
|
||||
var taskOutputChecksum : String? = null
|
||||
inputChecksumFor(taskName)?.let { inputChecksum ->
|
||||
val dependsOnDirtyProjects = project.projectInfo.dependsOnDirtyProjects(project)
|
||||
val dependsOnDirtyProjects = project.projectExtra.dependsOnDirtyProjects(project)
|
||||
if (inputChecksum == iit.inputChecksum && ! dependsOnDirtyProjects) {
|
||||
outputChecksumFor(taskName)?.let { outputChecksum ->
|
||||
taskOutputChecksum = iit.outputChecksum()
|
||||
|
@ -99,7 +99,7 @@ class IncrementalManager(val fileName: String = IncrementalManager.BUILD_INFO_FI
|
|||
logIncremental(2, "Incremental task $taskName input is out of date, running it"
|
||||
+ " old: $inputChecksum new: ${iit.inputChecksum}")
|
||||
}
|
||||
project.projectInfo.isDirty = true
|
||||
project.projectExtra.isDirty = true
|
||||
}
|
||||
}
|
||||
if (! upToDate) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.beust.kobalt.api.BuildConfig
|
|||
import com.beust.kobalt.api.BuildConfigField
|
||||
import com.beust.kobalt.api.KobaltContext
|
||||
import com.beust.kobalt.api.Project
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Data that is useful for projects to have but should not be specified in the DSL.
|
||||
|
@ -18,17 +17,6 @@ interface IProjectInfo {
|
|||
fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String, variant: Variant,
|
||||
buildConfigs: List<BuildConfig>) : String
|
||||
|
||||
/**
|
||||
* The list of projects that this project depends on
|
||||
*/
|
||||
val dependsOn: ArrayList<Project>
|
||||
|
||||
var isDirty: Boolean
|
||||
|
||||
/**
|
||||
* @return true if any of the projects we depend on is dirty.
|
||||
*/
|
||||
fun dependsOnDirtyProjects(project: Project) = project.projectInfo.dependsOn.any { it.projectInfo.isDirty }
|
||||
}
|
||||
|
||||
abstract class BaseProjectInfo : IProjectInfo {
|
||||
|
@ -42,8 +30,4 @@ abstract class BaseProjectInfo : IProjectInfo {
|
|||
}.map {
|
||||
generate(it)
|
||||
}
|
||||
|
||||
override val dependsOn = arrayListOf<Project>()
|
||||
|
||||
override var isDirty = false
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class TaskManager @Inject constructor(val args: Args, val incrementalMana
|
|||
AsciiArt.logBox("Building ${project.name}")
|
||||
|
||||
// Does the current project depend on any failed projects?
|
||||
val fp = project.projectInfo.dependsOn.filter {
|
||||
val fp = project.projectExtra.dependsOn.filter {
|
||||
failedProjects.contains(it.name)
|
||||
}.map {
|
||||
it.name
|
||||
|
|
|
@ -117,7 +117,7 @@ public class DependencyManager @Inject constructor(val executors: KobaltExecutor
|
|||
*/
|
||||
fun dependencies(project: Project, context: KobaltContext) : List<IClasspathDependency> {
|
||||
val result = arrayListOf<IClasspathDependency>()
|
||||
val projects = listOf(ProjectDescription(project, project.projectInfo.dependsOn))
|
||||
val projects = listOf(ProjectDescription(project, project.projectExtra.dependsOn))
|
||||
result.add(FileDependency(KFiles.makeOutputDir(project).absolutePath))
|
||||
result.add(FileDependency(KFiles.makeOutputTestDir(project).absolutePath))
|
||||
with(project) {
|
||||
|
@ -134,7 +134,7 @@ public class DependencyManager @Inject constructor(val executors: KobaltExecutor
|
|||
*/
|
||||
fun testDependencies(project: Project, context: KobaltContext) : List<IClasspathDependency> {
|
||||
val result = arrayListOf<IClasspathDependency>()
|
||||
val projects = listOf(ProjectDescription(project, project.projectInfo.dependsOn))
|
||||
val projects = listOf(ProjectDescription(project, project.projectExtra.dependsOn))
|
||||
result.add(FileDependency(KFiles.makeOutputDir(project).absolutePath))
|
||||
result.add(FileDependency(KFiles.makeOutputTestDir(project).absolutePath))
|
||||
with(project) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue