mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Remove dokka from KotlinPlugin.
This commit is contained in:
parent
ec398e0c8a
commit
5dc1953ea8
2 changed files with 59 additions and 82 deletions
|
@ -111,8 +111,7 @@ val kobaltApp = kotlinProject(kobaltPluginApi, wrapper) {
|
|||
|
||||
dependencies {
|
||||
// Used by the plugins
|
||||
compile("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.0-beta-4584",
|
||||
"org.jetbrains.dokka:dokka-fatjar:0.9.3")
|
||||
compile("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.0-beta-4584")
|
||||
|
||||
// Used by the main app
|
||||
compile("com.github.spullara.mustache.java:compiler:0.9.1",
|
||||
|
|
|
@ -11,13 +11,10 @@ import com.beust.kobalt.maven.DependencyManager
|
|||
import com.beust.kobalt.maven.LocalRepo
|
||||
import com.beust.kobalt.maven.dependency.FileDependency
|
||||
import com.beust.kobalt.maven.dependency.MavenDependency
|
||||
import com.beust.kobalt.misc.*
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import org.jetbrains.dokka.DokkaGenerator
|
||||
import org.jetbrains.dokka.DokkaLogger
|
||||
import org.jetbrains.dokka.SourceLinkDefinition
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.KobaltExecutors
|
||||
import com.beust.kobalt.misc.warn
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
@ -42,36 +39,40 @@ class KotlinPlugin @Inject constructor(
|
|||
override fun accept(project: Project) = project is KotlinProject
|
||||
|
||||
override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||
val configs = dokkaConfigurations[project.name]
|
||||
val classpath = context.dependencyManager.calculateDependencies(project, context)
|
||||
val buildDir = project.buildDirectory
|
||||
val classpathList = classpath.map { it.jarFile.get().absolutePath } + listOf(buildDir)
|
||||
var success = true
|
||||
configs.forEach { config ->
|
||||
if (!config.skip) {
|
||||
val outputDir = buildDir + "/" +
|
||||
if (config.outputDir.isBlank()) "doc" else config.outputDir
|
||||
|
||||
val gen = DokkaGenerator(
|
||||
KobaltDokkaLogger { success = false },
|
||||
classpathList,
|
||||
project.sourceDirectories.filter { File(it).exists() }.toList(),
|
||||
config.samplesDirs,
|
||||
config.includeDirs,
|
||||
config.moduleName,
|
||||
outputDir,
|
||||
config.outputFormat,
|
||||
config.sourceLinks.map { SourceLinkDefinition(it.dir, it.url, it.urlSuffix) }
|
||||
)
|
||||
gen.generate()
|
||||
log(2, "Documentation generated in $outputDir")
|
||||
} else {
|
||||
log(2, "skip is true, not generating the documentation")
|
||||
}
|
||||
}
|
||||
return TaskResult(success)
|
||||
return TaskResult()
|
||||
}
|
||||
|
||||
// override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||
// val configs = dokkaConfigurations[project.name]
|
||||
// val classpath = context.dependencyManager.calculateDependencies(project, context)
|
||||
// val buildDir = project.buildDirectory
|
||||
// val classpathList = classpath.map { it.jarFile.get().absolutePath } + listOf(buildDir)
|
||||
// var success = true
|
||||
// configs.forEach { config ->
|
||||
// if (!config.skip) {
|
||||
// val outputDir = buildDir + "/" +
|
||||
// if (config.outputDir.isBlank()) "doc" else config.outputDir
|
||||
//
|
||||
// val gen = DokkaGenerator(
|
||||
// KobaltDokkaLogger { success = false },
|
||||
// classpathList,
|
||||
// project.sourceDirectories.filter { File(it).exists() }.toList(),
|
||||
// config.samplesDirs,
|
||||
// config.includeDirs,
|
||||
// config.moduleName,
|
||||
// outputDir,
|
||||
// config.outputFormat,
|
||||
// config.sourceLinks.map { SourceLinkDefinition(it.dir, it.url, it.urlSuffix) }
|
||||
// )
|
||||
// gen.generate()
|
||||
// log(2, "Documentation generated in $outputDir")
|
||||
// } else {
|
||||
// log(2, "skip is true, not generating the documentation")
|
||||
// }
|
||||
// }
|
||||
// return TaskResult(success)
|
||||
// }
|
||||
|
||||
@Task(name = TASK_COMPILE_TEST, description = "Compile the tests", runAfter = arrayOf(TASK_COMPILE))
|
||||
fun taskCompileTest(project: Project): TaskResult {
|
||||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_TEST)
|
||||
|
@ -141,11 +142,11 @@ class KotlinPlugin @Inject constructor(
|
|||
return result
|
||||
}
|
||||
|
||||
private val dokkaConfigurations = ArrayListMultimap.create<String, DokkaConfig>()
|
||||
|
||||
fun addDokkaConfiguration(project: Project, dokkaConfig: DokkaConfig) {
|
||||
dokkaConfigurations.put(project.name, dokkaConfig)
|
||||
}
|
||||
// private val dokkaConfigurations = ArrayListMultimap.create<String, DokkaConfig>()
|
||||
//
|
||||
// fun addDokkaConfiguration(project: Project, dokkaConfig: DokkaConfig) {
|
||||
// dokkaConfigurations.put(project.name, dokkaConfig)
|
||||
// }
|
||||
|
||||
override fun toClassFile(sourceFile: String) = sourceFile + "Kt.class"
|
||||
}
|
||||
|
@ -172,44 +173,21 @@ fun Project.kotlinCompiler(init: KotlinCompilerConfig.() -> Unit) = let {
|
|||
KotlinCompilerConfig(it).init()
|
||||
}
|
||||
|
||||
class KobaltDokkaLogger(val onErrorCallback: () -> Unit = {}) : DokkaLogger {
|
||||
override fun error(message: String) {
|
||||
KobaltLogger.logger.error("Dokka", message)
|
||||
onErrorCallback()
|
||||
}
|
||||
|
||||
override fun info(message: String) {
|
||||
KobaltLogger.logger.log(2, message)
|
||||
}
|
||||
|
||||
override fun warn(message: String) {
|
||||
KobaltLogger.logger.warn("Dokka", message)
|
||||
}
|
||||
}
|
||||
|
||||
class SourceLinkMapItem {
|
||||
var dir: String = ""
|
||||
var url: String = ""
|
||||
var urlSuffix: String? = null
|
||||
}
|
||||
|
||||
class DokkaConfig(
|
||||
var samplesDirs: List<String> = emptyList(),
|
||||
var includeDirs: List<String> = emptyList(),
|
||||
var outputDir: String = "",
|
||||
var outputFormat: String = "html",
|
||||
var sourceLinks : ArrayList<SourceLinkMapItem> = arrayListOf<SourceLinkMapItem>(),
|
||||
var moduleName: String = "",
|
||||
var skip: Boolean = false) {
|
||||
|
||||
fun sourceLinks(init: SourceLinkMapItem.() -> Unit)
|
||||
= sourceLinks.add(SourceLinkMapItem().apply { init() })
|
||||
}
|
||||
|
||||
@Directive
|
||||
public fun Project.dokka(init: DokkaConfig.() -> Unit) = let { project ->
|
||||
with(DokkaConfig()) {
|
||||
init()
|
||||
(Kobalt.findPlugin(KotlinPlugin.PLUGIN_NAME) as KotlinPlugin).addDokkaConfiguration(project, this)
|
||||
}
|
||||
}
|
||||
//class SourceLinkMapItem {
|
||||
// var dir: String = ""
|
||||
// var url: String = ""
|
||||
// var urlSuffix: String? = null
|
||||
//}
|
||||
//
|
||||
//class DokkaConfig(
|
||||
// var samplesDirs: List<String> = emptyList(),
|
||||
// var includeDirs: List<String> = emptyList(),
|
||||
// var outputDir: String = "",
|
||||
// var outputFormat: String = "html",
|
||||
// var sourceLinks : ArrayList<SourceLinkMapItem> = arrayListOf<SourceLinkMapItem>(),
|
||||
// var moduleName: String = "",
|
||||
// var skip: Boolean = false) {
|
||||
//
|
||||
// fun sourceLinks(init: SourceLinkMapItem.() -> Unit)
|
||||
// = sourceLinks.add(SourceLinkMapItem().apply { init() })
|
||||
//}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue