mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 08:38:13 -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 {
|
dependencies {
|
||||||
// Used by the plugins
|
// Used by the plugins
|
||||||
compile("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.0-beta-4584",
|
compile("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.0.0-beta-4584")
|
||||||
"org.jetbrains.dokka:dokka-fatjar:0.9.3")
|
|
||||||
|
|
||||||
// Used by the main app
|
// Used by the main app
|
||||||
compile("com.github.spullara.mustache.java:compiler:0.9.1",
|
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.LocalRepo
|
||||||
import com.beust.kobalt.maven.dependency.FileDependency
|
import com.beust.kobalt.maven.dependency.FileDependency
|
||||||
import com.beust.kobalt.maven.dependency.MavenDependency
|
import com.beust.kobalt.maven.dependency.MavenDependency
|
||||||
import com.beust.kobalt.misc.*
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.google.common.collect.ArrayListMultimap
|
import com.beust.kobalt.misc.KobaltExecutors
|
||||||
import org.jetbrains.dokka.DokkaGenerator
|
import com.beust.kobalt.misc.warn
|
||||||
import org.jetbrains.dokka.DokkaLogger
|
|
||||||
import org.jetbrains.dokka.SourceLinkDefinition
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -42,36 +39,40 @@ class KotlinPlugin @Inject constructor(
|
||||||
override fun accept(project: Project) = project is KotlinProject
|
override fun accept(project: Project) = project is KotlinProject
|
||||||
|
|
||||||
override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult {
|
||||||
val configs = dokkaConfigurations[project.name]
|
return TaskResult()
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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))
|
@Task(name = TASK_COMPILE_TEST, description = "Compile the tests", runAfter = arrayOf(TASK_COMPILE))
|
||||||
fun taskCompileTest(project: Project): TaskResult {
|
fun taskCompileTest(project: Project): TaskResult {
|
||||||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_TEST)
|
copyResources(project, JvmCompilerPlugin.SOURCE_SET_TEST)
|
||||||
|
@ -141,11 +142,11 @@ class KotlinPlugin @Inject constructor(
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
private val dokkaConfigurations = ArrayListMultimap.create<String, DokkaConfig>()
|
// private val dokkaConfigurations = ArrayListMultimap.create<String, DokkaConfig>()
|
||||||
|
//
|
||||||
fun addDokkaConfiguration(project: Project, dokkaConfig: DokkaConfig) {
|
// fun addDokkaConfiguration(project: Project, dokkaConfig: DokkaConfig) {
|
||||||
dokkaConfigurations.put(project.name, dokkaConfig)
|
// dokkaConfigurations.put(project.name, dokkaConfig)
|
||||||
}
|
// }
|
||||||
|
|
||||||
override fun toClassFile(sourceFile: String) = sourceFile + "Kt.class"
|
override fun toClassFile(sourceFile: String) = sourceFile + "Kt.class"
|
||||||
}
|
}
|
||||||
|
@ -172,44 +173,21 @@ fun Project.kotlinCompiler(init: KotlinCompilerConfig.() -> Unit) = let {
|
||||||
KotlinCompilerConfig(it).init()
|
KotlinCompilerConfig(it).init()
|
||||||
}
|
}
|
||||||
|
|
||||||
class KobaltDokkaLogger(val onErrorCallback: () -> Unit = {}) : DokkaLogger {
|
//class SourceLinkMapItem {
|
||||||
override fun error(message: String) {
|
// var dir: String = ""
|
||||||
KobaltLogger.logger.error("Dokka", message)
|
// var url: String = ""
|
||||||
onErrorCallback()
|
// var urlSuffix: String? = null
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
override fun info(message: String) {
|
//class DokkaConfig(
|
||||||
KobaltLogger.logger.log(2, message)
|
// var samplesDirs: List<String> = emptyList(),
|
||||||
}
|
// var includeDirs: List<String> = emptyList(),
|
||||||
|
// var outputDir: String = "",
|
||||||
override fun warn(message: String) {
|
// var outputFormat: String = "html",
|
||||||
KobaltLogger.logger.warn("Dokka", message)
|
// var sourceLinks : ArrayList<SourceLinkMapItem> = arrayListOf<SourceLinkMapItem>(),
|
||||||
}
|
// var moduleName: String = "",
|
||||||
}
|
// var skip: Boolean = false) {
|
||||||
|
//
|
||||||
class SourceLinkMapItem {
|
// fun sourceLinks(init: SourceLinkMapItem.() -> Unit)
|
||||||
var dir: String = ""
|
// = sourceLinks.add(SourceLinkMapItem().apply { init() })
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue