From 769701f99a1aefbc9d385c1938c9c7d3a7b2e38e Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Tue, 1 Nov 2016 02:10:32 +0300 Subject: Total build refactoring, prepare for new development iteration Removed old and useless build helpers Remove old .xml's from .idea and add .idea/shelf to .gitignore build-docs.xml fixed, dokka_version set to 0.9.10 --- .../src/main/kotlin/main.kt | 76 ---------------------- 1 file changed, 76 deletions(-) delete mode 100644 dokka-android-gradle-plugin/src/main/kotlin/main.kt (limited to 'dokka-android-gradle-plugin/src/main/kotlin/main.kt') diff --git a/dokka-android-gradle-plugin/src/main/kotlin/main.kt b/dokka-android-gradle-plugin/src/main/kotlin/main.kt deleted file mode 100644 index 054ed358..00000000 --- a/dokka-android-gradle-plugin/src/main/kotlin/main.kt +++ /dev/null @@ -1,76 +0,0 @@ -package org.jetbrains.dokka.gradle - -import com.android.build.gradle.AppExtension -import com.android.build.gradle.LibraryExtension -import com.android.build.gradle.api.BaseVariant -import org.gradle.api.Plugin -import org.gradle.api.Project -import org.gradle.api.tasks.SourceSet -import java.io.File - -open class DokkaAndroidPlugin : Plugin { - val allVariantsClassPath = mutableSetOf() - - override fun apply(project: Project) { - project.tasks.create("dokka", DokkaAndroidTask::class.java).apply { - moduleName = project.name - outputDirectory = File(project.buildDir, "dokka").absolutePath - } - - if (project.hasAndroidPlugin()) { - project.afterEvaluate { - collectClasspath(project) - } - } - else { - project.plugins.whenPluginAdded { - if (project.hasAndroidPlugin()) { - collectClasspath(project) - } - } - } - } - - private fun collectClasspath(project: Project) { - val variants = project.collectAllVariants() - variants.flatMapTo(allVariantsClassPath) { it.javaCompiler.classpath.files } - } -} - -open class DokkaAndroidTask : DokkaTask() { - override val sdkProvider: SdkProvider? = AndroidSdkProvider(project) -} - -private fun Project.hasAndroidPlugin() = plugins.hasPlugin("com.android.library") || plugins.hasPlugin("com.android.application") - -private fun Project.findDokkaAndroidPlugin() = plugins.findPlugin(DokkaAndroidPlugin::class.java) - -private fun Project.collectAllVariants(): Collection { - extensions.findByType(LibraryExtension::class.java)?.let { - return it.libraryVariants - } - extensions.findByType(AppExtension::class.java)?.let { - return it.applicationVariants - } - return emptyList() -} - -private class AndroidSdkProvider(private val project: Project) : SdkProvider { - private val ext by lazy { - project.extensions.findByType(LibraryExtension::class.java) ?: project.extensions.findByType(AppExtension::class.java) - } - - override val name: String = "android" - - override val isValid: Boolean - get() = project.hasAndroidPlugin() - - override val classpath: List - get() = ext.bootClasspath + (project.findDokkaAndroidPlugin()?.allVariantsClassPath ?: emptyList()) - - override val sourceDirs: Set? - get() { - val sourceSet = ext?.sourceSets?.findByName(SourceSet.MAIN_SOURCE_SET_NAME) - return sourceSet?.java?.srcDirs - } -} -- cgit