Skip to content

Commit

Permalink
Add dokka artifacts #122 (#126)
Browse files Browse the repository at this point in the history
* Add dokka documentation artifacts

* Fix issue with empty android-kotlin sources jar

* Add license

* Alphabetize dependencies.gradle

* Consolidate artifacts.gradle files
  • Loading branch information
charlesdurham authored and ZacSweers committed Nov 9, 2017
1 parent 304fdff commit f697749
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions android/autodispose-android-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions autodispose-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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}"
]
Expand Down
149 changes: 105 additions & 44 deletions gradle/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}

0 comments on commit f697749

Please sign in to comment.