-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbbfc03
commit 2af2d36
Showing
6 changed files
with
65 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 19 additions & 58 deletions
77
buildSrc/src/main/kotlin/com/toolkit/plugin/util/_javadocAndSources.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,32 @@ | ||
package com.toolkit.plugin.util | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.tasks.javadoc.Javadoc | ||
import org.gradle.jvm.tasks.Jar | ||
import org.jetbrains.kotlin.konan.file.File | ||
import org.jetbrains.dokka.gradle.DokkaTask | ||
|
||
internal fun Project.setupJavadocAndSources() { | ||
return | ||
val sourcesJar = setupSources() | ||
val javadocJar = setupJavadoc() | ||
setupArtifacts(javadocJar, sourcesJar) | ||
|
||
tasks.whenTaskAdded { | ||
when (it.name) { | ||
"assembleRelease" -> { | ||
it.finalizedBy(sourcesJar, javadocJar) | ||
} | ||
|
||
"signJvmPublication" -> { | ||
it.finalizedBy(sourcesJar, javadocJar) | ||
} | ||
|
||
"signToolkitPublication" -> { | ||
it.dependsOn(sourcesJar, javadocJar) | ||
} | ||
|
||
"signKotlinMultiplatformPublication" -> { | ||
it.dependsOn(sourcesJar, javadocJar) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun Project.setupJavadoc(): Jar { | ||
configurations.maybeCreate("jacocoDeps") | ||
|
||
val javadoc = tasks.register("javadoc", Javadoc::class.java) { | ||
val list = ArrayList<java.io.File>() | ||
androidLibrary2.sourceSets.forEach { set -> list.addAll(set.java.srcDirs) } | ||
|
||
it.isFailOnError = false | ||
it.setExcludes(listOf("**/*.kt", "**/*.java")) | ||
it.source(list) | ||
it.classpath += files(androidLibrary2.bootClasspath.joinToString(separator = File.separator)) | ||
it.classpath += configurations.named("jacocoDeps").get() | ||
}.get() | ||
|
||
return tasks.register("javadocJar", Jar::class.java) { | ||
it.dependsOn(javadoc) | ||
it.archiveClassifier.set("javadoc") | ||
it.from(javadoc.destinationDir) | ||
}.get() | ||
setupSources() | ||
setupJavadoc() | ||
} | ||
|
||
private fun Project.setupSources() = if (tasks.findByName("sourcesJar") == null) { | ||
tasks.register("sourcesJar", Jar::class.java) { | ||
val mainSource = androidLibrary2.sourceSets.named("main").get().java.srcDirs | ||
it.from(mainSource) | ||
it.archiveClassifier.set("sources") | ||
private fun Project.setupJavadoc() { | ||
applyPlugins("jetbrains-dokka") | ||
tasks.register("javadocJar", Jar::class.java) { task -> | ||
task.group = "documentation" | ||
val dokka = task.project.tasks.named("dokkaHtml", DokkaTask::class.java) | ||
task.dependsOn(dokka) | ||
task.from(dokka.flatMap(DokkaTask::outputDirectory)) | ||
task.archiveClassifier.set("javadoc") | ||
task.archiveFileName.set("${task.project.name}-release-javadoc.jar") | ||
}.get() | ||
} else { | ||
tasks.named("sourcesJar", Jar::class.java).get() | ||
} | ||
|
||
private fun Project.setupArtifacts(javadoc: Jar, sources: Jar) { | ||
artifacts { | ||
it.add("archives", javadoc) | ||
it.add("archives", sources) | ||
private fun Project.setupSources() { | ||
tasks.whenTaskAdded { task -> | ||
if (task !is Jar) return@whenTaskAdded | ||
when (task.name) { | ||
"releaseSourcesJar" -> task.archiveFileName.set("${task.project.name}-release-sources.jar") | ||
"debugSourcesJar" -> task.archiveFileName.set("${task.project.name}-debug-sources.jar") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
plugins { | ||
id("toolkit-android-library") | ||
id("toolkit-publish") | ||
id("toolkit-multiplatform-library") | ||
id("toolkit-multiplatform-publish") | ||
} | ||
|
||
android.namespace = "br.com.arch.toolkit.splinter" | ||
android.buildFeatures.androidResources = false | ||
android.buildFeatures.buildConfig = false | ||
|
||
dependencies { | ||
// Other Modules | ||
implementation(project(":toolkit:multi:event-observer")) | ||
|
||
kotlin { | ||
// Libraries | ||
compileOnly(libs.jetbrains.stdlib.jdk8) | ||
compileOnly(libs.jetbrains.coroutines.core) | ||
compileOnly(libs.jetbrains.coroutines.android) | ||
compileOnly(libs.androidx.lifecycle.livedata) | ||
compileOnly(libs.square.retrofit.main) | ||
compileOnly(libs.square.timber) | ||
sourceSets.commonMain.dependencies { | ||
implementation(project(":toolkit:multi:event-observer")) | ||
|
||
implementation(libs.jetbrains.coroutines.core) | ||
implementation(libs.androidx.lifecycle.runtime) | ||
implementation(libs.androidx.annotation) | ||
} | ||
sourceSets.androidMain.dependencies { | ||
implementation(libs.androidx.lifecycle.livedata) | ||
implementation(libs.jetbrains.coroutines.android) | ||
implementation(libs.square.timber) | ||
compileOnly(libs.square.okhttp.core) | ||
compileOnly(libs.square.retrofit.main) | ||
} | ||
} |