diff options
author | Dmitry Jemerov <intelliyole@gmail.com> | 2016-03-31 16:15:35 +0200 |
---|---|---|
committer | Dmitry Jemerov <intelliyole@gmail.com> | 2016-03-31 16:15:35 +0200 |
commit | 3ed824ed77e87b09fc997189b74f1201e6e03b14 (patch) | |
tree | d2ec3d9a0889079bbf82b8ad82ea31dd69f59915 /dokka-android-gradle-plugin | |
parent | 6051ab5051be76d6c830a9996901bfbb9e1f901e (diff) | |
parent | 908aa606ea7c46346b590aaee79dd6cc1851e36d (diff) | |
download | dokka-3ed824ed77e87b09fc997189b74f1201e6e03b14.tar.gz dokka-3ed824ed77e87b09fc997189b74f1201e6e03b14.tar.bz2 dokka-3ed824ed77e87b09fc997189b74f1201e6e03b14.zip |
Merge pull request #64 from porokoro/android-and-custom-sources
Android support and custom sources
Diffstat (limited to 'dokka-android-gradle-plugin')
4 files changed, 127 insertions, 0 deletions
diff --git a/dokka-android-gradle-plugin/build.gradle b/dokka-android-gradle-plugin/build.gradle new file mode 100644 index 00000000..4e4a204f --- /dev/null +++ b/dokka-android-gradle-plugin/build.gradle @@ -0,0 +1,86 @@ +group 'org.jetbrains.dokka' +version dokka_version + +buildscript { + repositories { + mavenCentral() + jcenter() + maven { + url "https://dl.bintray.com/kotlin/kotlin-eap" + } + } + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' + } +} + +apply plugin: 'java' +apply plugin: 'kotlin' +apply plugin: 'maven-publish' +apply plugin: 'com.jfrog.bintray' + +sourceCompatibility = 1.6 + +repositories { + mavenCentral() + jcenter() + maven { + url "https://dl.bintray.com/kotlin/kotlin-eap" + } +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.12' + compile project(':core') + compile project(':dokka-gradle-plugin') + + compile gradleApi() + compile localGroovy() + + compile 'com.android.tools.build:gradle:2.0.0-beta7' +} + +sourceSets { + main.java.srcDirs += 'src/main/kotlin' +} + +task sourceJar(type: Jar) { + from sourceSets.main.allSource +} + +task wrapper(type: Wrapper) { + gradleVersion = '2.5' + distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip" +} + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + + artifact sourceJar { + classifier "sources" + } + } + } +} + +bintray { + user = System.getenv('BINTRAY_USER') + key = System.getenv('BINTRAY_KEY') + + pkg { + repo = dokka_eap.toBoolean() ? 'kotlin-eap' : 'dokka' + name = 'dokka' + userOrg = 'kotlin' + desc = 'Dokka, the Kotlin documentation tool' + vcsUrl = 'https://github.com/kotlin/dokka.git' + licenses = ['Apache-2.0'] + version { + name = dokka_version + } + } + + publications = ['mavenJava'] +} diff --git a/dokka-android-gradle-plugin/settings.gradle b/dokka-android-gradle-plugin/settings.gradle new file mode 100644 index 00000000..08876dc5 --- /dev/null +++ b/dokka-android-gradle-plugin/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'dokka-android-gradle-plugin' + diff --git a/dokka-android-gradle-plugin/src/main/kotlin/main.kt b/dokka-android-gradle-plugin/src/main/kotlin/main.kt new file mode 100644 index 00000000..9a92e2a2 --- /dev/null +++ b/dokka-android-gradle-plugin/src/main/kotlin/main.kt @@ -0,0 +1,38 @@ +package org.jetbrains.dokka.gradle + +import com.android.build.gradle.LibraryExtension +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.tasks.SourceSet +import java.io.File + +open class DokkaAndroidPlugin : Plugin<Project> { + override fun apply(project: Project) { + project.tasks.create("dokka", DokkaAndroidTask::class.java).apply { + moduleName = project.name + outputDirectory = File(project.buildDir, "dokka").absolutePath + } + } +} + +open class DokkaAndroidTask : DokkaTask() { + override val sdkProvider: SdkProvider? = AndroidSdkProvider(project) +} + +private class AndroidSdkProvider(private val project: Project) : SdkProvider { + private val ext by lazy { project.extensions.getByType(LibraryExtension::class.java) } + + override val name: String = "android" + + override val isValid: Boolean + get() = project.plugins.hasPlugin("com.android.library") + + override val classpath: List<File> + get() = ext.bootClasspath + + override val sourceDirs: Set<File>? + get() { + val sourceSet = ext.sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME) + return sourceSet?.java?.srcDirs + } +} diff --git a/dokka-android-gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.dokka-android.properties b/dokka-android-gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.dokka-android.properties new file mode 100644 index 00000000..03b28d93 --- /dev/null +++ b/dokka-android-gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.dokka-android.properties @@ -0,0 +1 @@ +implementation-class=org.jetbrains.dokka.gradle.DokkaAndroidPlugin
\ No newline at end of file |