mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Clean up the dependent project API.
This commit is contained in:
parent
df7f3a70ed
commit
71e2852963
6 changed files with 8 additions and 29 deletions
|
@ -2,7 +2,6 @@ package com.beust.kobalt.api
|
||||||
|
|
||||||
import com.beust.kobalt.TestConfig
|
import com.beust.kobalt.TestConfig
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
|
||||||
import com.beust.kobalt.maven.DependencyManager
|
import com.beust.kobalt.maven.DependencyManager
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -22,6 +21,7 @@ open class Project(
|
||||||
@Directive open var scm : Scm? = null,
|
@Directive open var scm : Scm? = null,
|
||||||
@Directive open var url: String? = null,
|
@Directive open var url: String? = null,
|
||||||
@Directive open var licenses: List<License> = arrayListOf<License>(),
|
@Directive open var licenses: List<License> = arrayListOf<License>(),
|
||||||
|
@Directive open var dependsOn: ArrayList<Project> = arrayListOf<Project>(),
|
||||||
@Directive open var packageName: String? = group)
|
@Directive open var packageName: String? = group)
|
||||||
: IBuildConfig, IDependencyHolder by DependencyHolder() {
|
: IBuildConfig, IDependencyHolder by DependencyHolder() {
|
||||||
|
|
||||||
|
@ -30,14 +30,12 @@ open class Project(
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProjectExtra(project: Project) {
|
class ProjectExtra(project: Project) {
|
||||||
val dependsOn = arrayListOf<Project>()
|
|
||||||
|
|
||||||
var isDirty = false
|
var isDirty = false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if any of the projects we depend on is dirty.
|
* @return true if any of the projects we depend on is dirty.
|
||||||
*/
|
*/
|
||||||
fun dependsOnDirtyProjects(project: Project) = project.projectExtra.dependsOn.any { it.projectExtra.isDirty }
|
fun dependsOnDirtyProjects(project: Project) = project.dependsOn.any { it.projectExtra.isDirty }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,10 +54,6 @@ open class Project(
|
||||||
override fun equals(other: Any?) = name == (other as Project).name
|
override fun equals(other: Any?) = name == (other as Project).name
|
||||||
override fun hashCode() = name.hashCode()
|
override fun hashCode() = name.hashCode()
|
||||||
|
|
||||||
/** Can be used by plug-ins */
|
|
||||||
val dependentProjects : List<ProjectDescription>
|
|
||||||
get() = projectProperties.get(JvmCompilerPlugin.DEPENDENT_PROJECTS) as List<ProjectDescription>
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val DEFAULT_SOURCE_DIRECTORIES = setOf("src/main/java", "src/main/kotlin", "src/main/resources")
|
val DEFAULT_SOURCE_DIRECTORIES = setOf("src/main/java", "src/main/kotlin", "src/main/resources")
|
||||||
val DEFAULT_SOURCE_DIRECTORIES_TEST = setOf("src/test/java", "src/test/kotlin", "src/test/resources")
|
val DEFAULT_SOURCE_DIRECTORIES_TEST = setOf("src/test/java", "src/test/kotlin", "src/test/resources")
|
||||||
|
|
|
@ -34,9 +34,6 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
companion object {
|
companion object {
|
||||||
val PLUGIN_NAME = "JvmCompiler"
|
val PLUGIN_NAME = "JvmCompiler"
|
||||||
|
|
||||||
@ExportedProjectProperty(doc = "Projects this project depends on", type = "List<ProjectDescription>")
|
|
||||||
const val DEPENDENT_PROJECTS = "dependentProjects"
|
|
||||||
|
|
||||||
@ExportedProjectProperty(doc = "Compiler args", type = "List<String>")
|
@ExportedProjectProperty(doc = "Compiler args", type = "List<String>")
|
||||||
const val COMPILER_ARGS = "compilerArgs"
|
const val COMPILER_ARGS = "compilerArgs"
|
||||||
|
|
||||||
|
@ -208,12 +205,10 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addDependentProjects(project: Project, dependents: List<Project>) {
|
fun addDependentProjects(project: Project, dependents: List<Project>) {
|
||||||
project.projectExtra.dependsOn.addAll(dependents)
|
project.dependsOn.addAll(dependents)
|
||||||
with(ProjectDescription(project, dependents)) {
|
with(ProjectDescription(project, dependents)) {
|
||||||
allProjects.add(this)
|
allProjects.add(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
project.projectProperties.put(DEPENDENT_PROJECTS, allProjects)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Task(name = "doc", description = "Generate the documentation for the project", group = GROUP_DOCUMENTATION)
|
@Task(name = "doc", description = "Generate the documentation for the project", group = GROUP_DOCUMENTATION)
|
||||||
|
|
|
@ -132,7 +132,7 @@ class TaskManager @Inject constructor(val args: Args,
|
||||||
AsciiArt.logBox("Building ${project.name}")
|
AsciiArt.logBox("Building ${project.name}")
|
||||||
|
|
||||||
// Does the current project depend on any failed projects?
|
// Does the current project depend on any failed projects?
|
||||||
val fp = project.projectExtra.dependsOn.filter {
|
val fp = project.dependsOn.filter {
|
||||||
failedProjects.contains(it.name)
|
failedProjects.contains(it.name)
|
||||||
}.map {
|
}.map {
|
||||||
it.name
|
it.name
|
||||||
|
@ -211,7 +211,7 @@ class TaskManager @Inject constructor(val args: Args,
|
||||||
toProcess.forEach { ti ->
|
toProcess.forEach { ti ->
|
||||||
val project = projectMap[ti.project]
|
val project = projectMap[ti.project]
|
||||||
if (project != null) {
|
if (project != null) {
|
||||||
val dependents = project.projectExtra.dependsOn
|
val dependents = project.dependsOn
|
||||||
if (dependents.any()) {
|
if (dependents.any()) {
|
||||||
dependents.forEach { depProject ->
|
dependents.forEach { depProject ->
|
||||||
val tiDep = TaskInfo(depProject.name, ti.taskName)
|
val tiDep = TaskInfo(depProject.name, ti.taskName)
|
||||||
|
|
|
@ -174,7 +174,7 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
|
||||||
return emptyList()
|
return emptyList()
|
||||||
} else {
|
} else {
|
||||||
val result = arrayListOf<IClasspathDependency>()
|
val result = arrayListOf<IClasspathDependency>()
|
||||||
project.projectExtra.dependsOn.forEach { p ->
|
project.dependsOn.forEach { p ->
|
||||||
result.add(FileDependency(KFiles.joinDir(p.directory, p.classesDir(context))))
|
result.add(FileDependency(KFiles.joinDir(p.directory, p.classesDir(context))))
|
||||||
val otherDependencies = calculateDependencies(p, context, p.compileDependencies)
|
val otherDependencies = calculateDependencies(p, context, p.compileDependencies)
|
||||||
result.addAll(otherDependencies)
|
result.addAll(otherDependencies)
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class PomGenerator @Inject constructor(@Assisted val project: Project) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Project dependencies
|
// 2. Project dependencies
|
||||||
project.dependentProjects.filter { it.project.name == project.name }.first().dependsOn.forEach {
|
project.dependsOn.forEach {
|
||||||
m.dependencies.add(org.apache.maven.model.Dependency().apply {
|
m.dependencies.add(org.apache.maven.model.Dependency().apply {
|
||||||
version = it.version
|
version = it.version
|
||||||
groupId = it.group
|
groupId = it.group
|
||||||
|
|
|
@ -2,9 +2,7 @@ package com.beust.kobalt.app.remote
|
||||||
|
|
||||||
import com.beust.kobalt.Args
|
import com.beust.kobalt.Args
|
||||||
import com.beust.kobalt.api.IClasspathDependency
|
import com.beust.kobalt.api.IClasspathDependency
|
||||||
import com.beust.kobalt.api.ProjectDescription
|
|
||||||
import com.beust.kobalt.app.BuildFileCompiler
|
import com.beust.kobalt.app.BuildFileCompiler
|
||||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
|
||||||
import com.beust.kobalt.internal.PluginInfo
|
import com.beust.kobalt.internal.PluginInfo
|
||||||
import com.beust.kobalt.internal.TaskManager
|
import com.beust.kobalt.internal.TaskManager
|
||||||
import com.beust.kobalt.internal.build.BuildFile
|
import com.beust.kobalt.internal.build.BuildFile
|
||||||
|
@ -55,15 +53,7 @@ class DependencyData @Inject constructor(val executors: KobaltExecutors, val dep
|
||||||
allDeps(project.compileProvidedDependencies).map { toDependencyData(it, "compile") }
|
allDeps(project.compileProvidedDependencies).map { toDependencyData(it, "compile") }
|
||||||
val testDependencies = allDeps(project.testDependencies).map { toDependencyData(it, "testCompile") }
|
val testDependencies = allDeps(project.testDependencies).map { toDependencyData(it, "testCompile") }
|
||||||
|
|
||||||
val pd = project.projectProperties.get(JvmCompilerPlugin.DEPENDENT_PROJECTS)
|
val dependentProjects = project.dependsOn.map { it.name }
|
||||||
val dependentProjects = if (pd != null) {
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
|
||||||
(pd as List<ProjectDescription>).filter { it.project.name == project.name }.flatMap {
|
|
||||||
it.dependsOn.map { it.name }
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
emptyList()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Separate resource from source directories
|
// Separate resource from source directories
|
||||||
val sources = project.sourceDirectories.partition { KFiles.isResource(it) }
|
val sources = project.sourceDirectories.partition { KFiles.isResource(it) }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue