diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-03-23 15:37:14 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-03-23 15:37:14 +0300 |
commit | 8f60abd5d1e0dba659c433a9a37561c4d78c1c12 (patch) | |
tree | 5ca7dd030eda113660dda0aa5bed36b377aaacb4 /runners/gradle-plugin/src/main/kotlin | |
parent | 3693c2f7e75822ad035007f98c8d55006d9eabbd (diff) | |
download | dokka-8f60abd5d1e0dba659c433a9a37561c4d78c1c12.tar.gz dokka-8f60abd5d1e0dba659c433a9a37561c4d78c1c12.tar.bz2 dokka-8f60abd5d1e0dba659c433a9a37561c4d78c1c12.zip |
Fix JVM crash in gradle plugin
#KT-17016 fixed
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin')
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/main.kt | 110 |
1 files changed, 59 insertions, 51 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/main.kt b/runners/gradle-plugin/src/main/kotlin/main.kt index 3a78080c..e7c7b99a 100644 --- a/runners/gradle-plugin/src/main/kotlin/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/main.kt @@ -116,61 +116,69 @@ open class DokkaTask : DefaultTask() { } } + val COLORS_ENABLED_PROPERTY = "kotlin.colors.enabled" @TaskAction fun generate() { - loadFatJar() - - val project = project - val sdkProvider = sdkProvider - val sourceDirectories = getSourceDirectories() - val allConfigurations = project.configurations - - val classpath = - if (sdkProvider != null && sdkProvider.isValid) sdkProvider.classpath else emptyList<File>() + - processConfigurations - .map { allConfigurations?.getByName(it.toString()) ?: throw IllegalArgumentException("No configuration $it found") } - .flatMap { it } - - if (sourceDirectories.isEmpty()) { - logger.warn("No source directories found: skipping dokka generation") - return + val kotlinColorsEnabledBefore = System.getProperty(COLORS_ENABLED_PROPERTY) + System.setProperty(COLORS_ENABLED_PROPERTY, "false") + try { + loadFatJar() + + val project = project + val sdkProvider = sdkProvider + val sourceDirectories = getSourceDirectories() + val allConfigurations = project.configurations + + val classpath = + if (sdkProvider != null && sdkProvider.isValid) sdkProvider.classpath else emptyList<File>() + + processConfigurations + .map { allConfigurations?.getByName(it.toString()) ?: throw IllegalArgumentException("No configuration $it found") } + .flatMap { it } + + if (sourceDirectories.isEmpty()) { + logger.warn("No source directories found: skipping dokka generation") + return + } + + val bootstrapClass = fatJarClassLoader!!.loadClass("org.jetbrains.dokka.DokkaBootstrapImpl") + + val bootstrapInstance = bootstrapClass.constructors.first().newInstance() + + val bootstrapProxy: DokkaBootstrap = automagicTypedProxy(javaClass.classLoader, bootstrapInstance) + + bootstrapProxy.configure( + BiConsumer { level, message -> + when (level) { + "info" -> logger.info(message) + "warn" -> logger.warn(message) + "error" -> logger.error(message) + } + }, + moduleName, + classpath.map { it.absolutePath }, + sourceDirectories.map { it.absolutePath }, + samples.filterNotNull().map { project.file(it).absolutePath }, + includes.filterNotNull().map { project.file(it).absolutePath }, + outputDirectory, + outputFormat, + false, + false, + reportNotDocumented, + skipEmptyPackages, + skipDeprecated, + 6, + true, + linkMappings.map { + val path = project.file(it.dir).absolutePath + "$path=${it.url}${it.suffix}" + }) + + bootstrapProxy.generate() + + } finally { + System.setProperty(COLORS_ENABLED_PROPERTY, kotlinColorsEnabledBefore) } - - val bootstrapClass = fatJarClassLoader!!.loadClass("org.jetbrains.dokka.DokkaBootstrapImpl") - - val bootstrapInstance = bootstrapClass.constructors.first().newInstance() - - val bootstrapProxy: DokkaBootstrap = automagicTypedProxy(javaClass.classLoader, bootstrapInstance) - - bootstrapProxy.configure( - BiConsumer { level, message -> - when (level) { - "info" -> logger.info(message) - "warn" -> logger.warn(message) - "error" -> logger.error(message) - } - }, - moduleName, - classpath.map { it.absolutePath }, - sourceDirectories.map { it.absolutePath }, - samples.filterNotNull().map { project.file(it).absolutePath }, - includes.filterNotNull().map { project.file(it).absolutePath }, - outputDirectory, - outputFormat, - false, - false, - reportNotDocumented, - skipEmptyPackages, - skipDeprecated, - 6, - true, - linkMappings.map { - val path = project.file(it.dir).absolutePath - "$path=${it.url}${it.suffix}" - }) - - bootstrapProxy.generate() } fun getSourceDirectories(): Collection<File> { |