diff --git a/android/autodispose-android-archcomponents-kotlin/build.gradle b/android/autodispose-android-archcomponents-kotlin/build.gradle index a8b0dbbd1..6753ecc86 100644 --- a/android/autodispose-android-archcomponents-kotlin/build.gradle +++ b/android/autodispose-android-archcomponents-kotlin/build.gradle @@ -22,11 +22,13 @@ buildscript { dependencies { classpath deps.build.gradlePlugins.android classpath deps.build.gradlePlugins.kotlin + classpath deps.build.gradlePlugins.dokkaAndroid } } apply plugin: 'com.android.library' apply plugin: 'org.jetbrains.kotlin.android' +apply plugin: 'org.jetbrains.dokka-android' android { compileSdkVersion deps.build.compileSdkVersion diff --git a/android/autodispose-android-archcomponents-test-kotlin/build.gradle b/android/autodispose-android-archcomponents-test-kotlin/build.gradle index f9dd5aeef..2ac0b488e 100644 --- a/android/autodispose-android-archcomponents-test-kotlin/build.gradle +++ b/android/autodispose-android-archcomponents-test-kotlin/build.gradle @@ -22,11 +22,13 @@ buildscript { dependencies { classpath deps.build.gradlePlugins.android classpath deps.build.gradlePlugins.kotlin + classpath deps.build.gradlePlugins.dokkaAndroid } } apply plugin: 'com.android.library' apply plugin: 'org.jetbrains.kotlin.android' +apply plugin: 'org.jetbrains.dokka-android' android { compileSdkVersion deps.build.compileSdkVersion diff --git a/android/autodispose-android-kotlin/build.gradle b/android/autodispose-android-kotlin/build.gradle index d33ef1318..16fa3dc4a 100644 --- a/android/autodispose-android-kotlin/build.gradle +++ b/android/autodispose-android-kotlin/build.gradle @@ -22,11 +22,13 @@ buildscript { dependencies { classpath deps.build.gradlePlugins.android classpath deps.build.gradlePlugins.kotlin + classpath deps.build.gradlePlugins.dokkaAndroid } } apply plugin: 'com.android.library' apply plugin: 'org.jetbrains.kotlin.android' +apply plugin: 'org.jetbrains.dokka-android' android { compileSdkVersion deps.build.compileSdkVersion diff --git a/autodispose-kotlin/build.gradle b/autodispose-kotlin/build.gradle index b3409147a..19c0dbe39 100644 --- a/autodispose-kotlin/build.gradle +++ b/autodispose-kotlin/build.gradle @@ -1,10 +1,12 @@ buildscript { dependencies { classpath deps.build.gradlePlugins.kotlin + classpath deps.build.gradlePlugins.dokka } } apply plugin: 'org.jetbrains.kotlin.jvm' +apply plugin: 'org.jetbrains.dokka' dependencies { compile deps.kotlin.stdlib diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index c6bec0e6d..9822f49ef 100755 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -17,6 +17,7 @@ def versions = [ androidTest: '0.5', archComponents: '1.0.0-rc1', + dokka: '0.9.15', errorProne: '2.1.1', kotlin: '1.1.51', support: '26.1.0' @@ -40,6 +41,8 @@ def build = [ gradlePlugins: [ android: 'com.android.tools.build:gradle:2.3.0', apt: 'net.ltgt.gradle:gradle-apt-plugin:0.11', + dokka: "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}", + dokkaAndroid: "org.jetbrains.dokka:dokka-android-gradle-plugin:${versions.dokka}", errorProne: 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.11', kotlin: "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" ] diff --git a/gradle/gradle-mvn-push.gradle b/gradle/gradle-mvn-push.gradle index f4087a8d4..0c64a1eb6 100755 --- a/gradle/gradle-mvn-push.gradle +++ b/gradle/gradle-mvn-push.gradle @@ -42,6 +42,101 @@ def getRepositoryPassword() { return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : "" } +def kotlinAndroidArtifactTasks() { + if (!project.plugins.hasPlugin('org.jetbrains.dokka-android')) { + throw new GradleException("Apply the dokka-android plugin in ${project.name}") + } + + dokka { + externalDocumentationLink { + url = new URL("http://reactivex.io/RxJava/2.x/javadoc/") + } + + outputFormat = 'html' + outputDirectory = "$buildDir/docs/kdoc" + sourceDirs = android.sourceSets.main.java.srcDirs + } + + task docJar(type: Jar, dependsOn: dokka) { + classifier = 'javadoc' + from dokka.outputDirectory + } + + task sourceJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs + } +} + +def kotlinArtifactTasks() { + if (!project.plugins.hasPlugin('org.jetbrains.dokka')) { + throw new GradleException("Apply the dokka plugin in ${project.name}") + } + + dokka { + externalDocumentationLink { + url = new URL("http://reactivex.io/RxJava/2.x/javadoc/") + } + + outputFormat = 'html' + outputDirectory = "$buildDir/docs/kdoc" + sourceDirs = sourceSets.main.allSource + } + + task docJar(type: Jar, dependsOn: dokka) { + classifier = 'javadoc' + from dokka.outputDirectory + } + + task sourceJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource + } +} + +def androidArtifactTasks() { + task androidJavadoc(type: Javadoc) { + source = android.sourceSets.main.java.srcDirs + + classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + exclude '**/internal/*' + + if (JavaVersion.current().isJava8Compatible()) { + options.addStringOption('Xdoclint:none', '-quiet') + } + } + + task docJar(type: Jar, dependsOn: androidJavadoc) { + classifier = 'javadoc' + from androidJavadoc.destinationDir + } + + task sourceJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.sourceFiles + } +} + +def javaArtifactTasks() { + task javaJavadoc(type: Javadoc) { + source = sourceSets.main.allSource + + if (JavaVersion.current().isJava8Compatible()) { + options.addStringOption('Xdoclint:none', '-quiet') + } + } + + task docJar(type: Jar, dependsOn: javaJavadoc) { + classifier = 'javadoc' + from javaJavadoc.destinationDir + } + + task sourceJar(type: Jar, dependsOn: classes) { + classifier = 'sources' + from sourceSets.main.allSource.srcDirs + } +} + afterEvaluate { project -> uploadArchives { repositories { @@ -135,26 +230,10 @@ afterEvaluate { project -> } } - task androidJavadocs(type: Javadoc) { - if (!project.plugins.hasPlugin('kotlin-android')) { - source = android.sourceSets.main.java.srcDirs - } - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - exclude '**/internal/*' - - if (JavaVersion.current().isJava8Compatible()) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } - - task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { - classifier = 'javadoc' - from androidJavadocs.destinationDir - } - - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.sourceFiles + if (project.plugins.hasPlugin('kotlin-android')) { + kotlinAndroidArtifactTasks() + } else { + androidArtifactTasks() } } else { install { @@ -193,33 +272,15 @@ afterEvaluate { project -> } } - task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - } - - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - } - - if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } + if (project.plugins.hasPlugin('kotlin')) { + kotlinArtifactTasks() + } else { + javaArtifactTasks() } } artifacts { - if (project.getPlugins().hasPlugin('com.android.application') || - project.getPlugins().hasPlugin('com.android.library')) { - archives androidSourcesJar - archives androidJavadocsJar - } else { - archives sourcesJar - archives javadocJar - } + archives sourceJar + archives docJar } }