From 4fcd615daf975cbd40b24037cb52b809e1b03e61 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 11 Aug 2022 20:58:52 +0200 Subject: [PATCH 1/2] Bump com.android.tools.build:gradle [7.0.3 -> 7.2.1] --- buildSrc/build.gradle.kts | 1 + buildSrc/src/main/java/io/wax911/emoji/buildSrc/Libraries.kt | 2 +- gradle.properties | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index e2464d30..29ce27c1 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -20,6 +20,7 @@ val buildToolsVersion = "7.0.3" val dokkaVersion = "1.5.31" val manesVersion = "0.33.0" val spotlessVersion = "5.12.1" +val buildToolsVersion = "7.2.1" dependencies { /* Depend on the android gradle plugin, since we want to access it in our plugin */ diff --git a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/Libraries.kt b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/Libraries.kt index d05c4054..3004e4e8 100644 --- a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/Libraries.kt +++ b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/Libraries.kt @@ -12,7 +12,7 @@ object Libraries { object Android { object Tools { - private const val version = "7.0.3" + private const val version = "7.2.1" const val buildGradle = "com.android.tools.build:gradle:$version" } } diff --git a/gradle.properties b/gradle.properties index bb2c7262..f06298e0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,3 +21,4 @@ kotlin.code.style=official # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects org.gradle.parallel=true +android.disableAutomaticComponentCreation=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 29e41345..669386b8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 62f4f8b31db3d6cf0514c0bf0277547fe4d8f5c6 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Thu, 11 Aug 2022 21:00:43 +0200 Subject: [PATCH 2/2] Bump dependencies and resolve deprecation warnings --- buildSrc/build.gradle.kts | 23 +- .../io/wax911/emoji/buildSrc/Libraries.kt | 40 ++-- .../emoji/buildSrc/common/Configuration.kt | 29 +++ .../wax911/emoji/buildSrc/common/Versions.kt | 26 +-- .../plugin/components/AndroidConfiguration.kt | 47 ++-- .../plugin/components/AndroidOptions.kt | 214 ++++++++---------- .../plugin/strategy/DependencyStrategy.kt | 4 +- 7 files changed, 190 insertions(+), 193 deletions(-) create mode 100644 buildSrc/src/main/java/io/wax911/emoji/buildSrc/common/Configuration.kt diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 29ce27c1..5e5d303b 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile + plugins { `kotlin-dsl` `maven-publish` @@ -5,7 +7,6 @@ plugins { repositories { google() - jcenter() mavenCentral() maven { setUrl("https://www.jitpack.io") @@ -15,12 +16,22 @@ repositories { } } -val kotlinVersion = "1.5.31" -val buildToolsVersion = "7.0.3" -val dokkaVersion = "1.5.31" -val manesVersion = "0.33.0" -val spotlessVersion = "5.12.1" +tasks.withType(KotlinJvmCompile::class.java) { + kotlinOptions { + jvmTarget = "11" + } +} + +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + val buildToolsVersion = "7.2.1" +val kotlinVersion = "1.6.21" +val dokkaVersion = "1.6.21" +val manesVersion = "0.38.0" +val spotlessVersion = "6.9.0" dependencies { /* Depend on the android gradle plugin, since we want to access it in our plugin */ diff --git a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/Libraries.kt b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/Libraries.kt index 3004e4e8..19eaf70c 100644 --- a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/Libraries.kt +++ b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/Libraries.kt @@ -7,7 +7,6 @@ object Libraries { const val timber = "com.jakewharton.timber:timber:${Versions.timber}" const val junit = "junit:junit:${Versions.junit}" - const val mockk = "io.mockk:mockk:${Versions.mockk}" object Android { @@ -20,24 +19,26 @@ object Libraries { object AndroidX { object Core { - private const val version = "1.6.0" + private const val version = "1.8.0" const val core = "androidx.core:core:$version" const val coreKtx = "androidx.core:core-ktx:$version" } object ConstraintLayout { - private const val version = "2.1.1" + private const val version = "2.1.4" const val constraintLayout = "androidx.constraintlayout:constraintlayout:$version" - const val constraintLayoutSolver = "androidx.constraintlayout:constraintlayout-solver:$version" } object Emoji { private const val version = "1.1.0" - const val appCompat = "androidx.emoji:emoji-appcompat:$version" + const val emoji = "androidx.emoji2.emoji2:emoji2:$version" + const val bundled = "androidx.emoji2.emoji2:emoji2-bundled:$version" + const val views = "androidx.emoji2.emoji2:emoji2-views:$version" + const val viewsHelper = "androidx.emoji2.emoji2:emoji2-views-helper:$version" } object Lifecycle { - private const val version = "2.3.0" + private const val version = "2.5.0" const val extensions = "androidx.lifecycle:lifecycle-extensions:2.2.0" const val runTimeKtx = "androidx.lifecycle:lifecycle-runtime-ktx:$version" const val liveDataKtx = "androidx.lifecycle:lifecycle-livedata-ktx:$version" @@ -59,18 +60,18 @@ object Libraries { } object StartUp { - private const val version = "1.1.0" + private const val version = "1.1.1" const val startUpRuntime = "androidx.startup:startup-runtime:$version" } object Test { - private const val version = "1.3.0" + private const val version = "1.4.0" const val core = "androidx.test:core:$version" const val runner = "androidx.test:runner:$version" const val rules = "androidx.test:rules:$version" object Extension { - private const val version = "1.1.2" + private const val version = "1.1.3" const val junit = "androidx.test.ext:junit:$version" const val junitKtx = "androidx.test.ext:junit-ktx:$version" } @@ -86,7 +87,7 @@ object Libraries { object CashApp { object Turbine { - private const val version = "0.7.0" + private const val version = "0.8.0" const val turbine = "app.cash.turbine:turbine:$version" } } @@ -94,20 +95,15 @@ object Libraries { object Google { object Material { - private const val version = "1.3.0" + private const val version = "1.6.1" const val material = "com.google.android.material:material:$version" } } object JetBrains { - object Dokka { - private const val version = "1.5.31" - const val gradlePlugin = "org.jetbrains.dokka:dokka-gradle-plugin:$version" - } - object Kotlin { - private const val version = "1.5.31" + private const val version = Versions.kotlin const val stdlib = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$version" const val reflect = "org.jetbrains.kotlin:kotlin-reflect:$version" @@ -126,16 +122,22 @@ object Libraries { object KotlinX { object Coroutines { - private const val version = "1.5.2" + private const val version = "1.6.4" const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version" const val android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version" const val test = "org.jetbrains.kotlinx:kotlinx-coroutines-test:$version" } object Serialization { - private const val version = "1.3.0" + private const val version = "1.3.3" const val json = "org.jetbrains.kotlinx:kotlinx-serialization-json:$version" } } } + + object Mockk { + private const val version = "1.12.4" + const val mockk = "io.mockk:mockk:$version" + const val mockkAndroid = "io.mockk:mockk-android:$version" + } } \ No newline at end of file diff --git a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/common/Configuration.kt b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/common/Configuration.kt new file mode 100644 index 00000000..da8950e2 --- /dev/null +++ b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/common/Configuration.kt @@ -0,0 +1,29 @@ +package io.wax911.emoji.buildSrc.common + +object Configuration { + + private fun Int.toVersion(): String { + return if (this < 9) "0$this" else "$this" + } + + const val compileSdk = 32 + const val targetSdk = 32 + const val minSdk = 21 + + private const val major = 1 + private const val minor = 7 + private const val patch = 0 + private const val revision = 0 + + private const val channel = "rc" + + const val versionCode = major.times(1_000_000_000) + + minor.times(1_000_000) + + patch.times(1_000) + + revision + + val versionName = if (revision > 1) + "$major.$minor.$patch-${channel}${revision.toVersion()}" + else + "$major.$minor.$patch" +} \ No newline at end of file diff --git a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/common/Versions.kt b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/common/Versions.kt index a0f8c4de..152a4292 100644 --- a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/common/Versions.kt +++ b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/common/Versions.kt @@ -2,30 +2,10 @@ package io.wax911.emoji.buildSrc.common object Versions { - private fun Int.toVersion(): String { - return if (this < 9) "0$this" else "$this" - } - - const val compileSdk = 30 - const val targetSdk = 30 - const val minSdk = 21 - - private const val major = 1 - private const val minor = 7 - private const val patch = 0 - private const val revision = 0 - - private const val channel = "rc" - - const val versionCode = major * 100_000 + minor * 10_000 + patch * 1_000 + revision * 100 - val versionName = if (revision > 1) - "$major.$minor.$patch-${channel}${revision.toVersion()}" - else - "$major.$minor.$patch" - - const val mockk = "1.12.0" const val junit = "4.13.2" const val timber = "5.0.1" - const val ktlint = "0.40.0" + const val ktlint = "0.46.1" + + const val kotlin = "1.6.21" } \ No newline at end of file diff --git a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/components/AndroidConfiguration.kt b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/components/AndroidConfiguration.kt index 7e5ea7b1..aae41d61 100644 --- a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/components/AndroidConfiguration.kt +++ b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/components/AndroidConfiguration.kt @@ -1,6 +1,7 @@ package io.wax911.emoji.buildSrc.plugin.components import io.wax911.emoji.buildSrc.common.Versions +import io.wax911.emoji.buildSrc.common.Configuration import com.android.build.gradle.internal.dsl.DefaultConfig import io.wax911.emoji.buildSrc.plugin.extensions.* import io.wax911.emoji.buildSrc.plugin.extensions.baseAppExtension @@ -26,6 +27,14 @@ internal fun Project.configureSpotless() { } } +private fun Project.configureLint() = baseAppExtension().run { + lint { + abortOnError = false + ignoreWarnings = false + ignoreTestSources = true + } +} + @Suppress("UnstableApiUsage") private fun DefaultConfig.applyAdditionalConfiguration(project: Project) { if (project.isSampleModule()) { @@ -41,12 +50,12 @@ private fun DefaultConfig.applyAdditionalConfiguration(project: Project) { } internal fun Project.configureAndroid(): Unit = baseExtension().run { - compileSdkVersion(Versions.compileSdk) + compileSdkVersion(Configuration.compileSdk) defaultConfig { - minSdk = Versions.minSdk - targetSdk = Versions.targetSdk - versionCode = Versions.versionCode - versionName = Versions.versionName + minSdk = Configuration.minSdk + targetSdk = Configuration.targetSdk + versionCode = Configuration.versionCode + versionName = Configuration.versionName testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" applyAdditionalConfiguration(project) } @@ -65,9 +74,9 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run { } packagingOptions { - excludes.add("META-INF/NOTICE.txt") - excludes.add("META-INF/LICENSE") - excludes.add("META-INF/LICENSE.txt") + resources.excludes.add("META-INF/NOTICE.txt") + resources.excludes.add("META-INF/LICENSE") + resources.excludes.add("META-INF/LICENSE.txt") } sourceSets { @@ -82,15 +91,13 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run { unitTests.isReturnDefaultValues = true } - lintOptions { - isAbortOnError = false - isIgnoreWarnings = false - isIgnoreTestSources = true + if (isSampleModule()) { + configureLint() } compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } tasks.withType(KotlinCompile::class.java) { @@ -98,13 +105,13 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run { allWarningsAsErrors = false kotlinOptions { allWarningsAsErrors = false - val compileArgs = mutableListOf("-Xopt-in=kotlin.Experimental") + val compileArgs = mutableListOf("-opt-in=kotlin.Experimental") if (isSampleModule()) { - compileArgs.add("-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi") - compileArgs.add("-Xopt-in=kotlinx.coroutines.FlowPreview") - compileArgs.add("-Xopt-in=kotlin.Experimental") + compileArgs.add("-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi") + compileArgs.add("-opt-in=kotlinx.coroutines.FlowPreview") + compileArgs.add("-opt-in=kotlin.Experimental") } else - compileArgs.add("-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi") + compileArgs.add("-opt-in=kotlinx.serialization.ExperimentalSerializationApi") // Filter out modules that won't be using coroutines freeCompilerArgs = compileArgs } @@ -113,7 +120,7 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run { tasks.withType(KotlinJvmCompile::class.java) { kotlinOptions { - jvmTarget = "1.8" + jvmTarget = "11" } } } \ No newline at end of file diff --git a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/components/AndroidOptions.kt b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/components/AndroidOptions.kt index 76803c94..bf81adfb 100644 --- a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/components/AndroidOptions.kt +++ b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/components/AndroidOptions.kt @@ -6,19 +6,15 @@ import org.gradle.kotlin.dsl.get import org.jetbrains.dokka.gradle.DokkaTask import io.wax911.emoji.buildSrc.plugin.extensions.baseExtension import io.wax911.emoji.buildSrc.plugin.extensions.publishingExtension -import io.wax911.emoji.buildSrc.plugin.extensions.libraryExtension -import io.wax911.emoji.buildSrc.common.Versions +import io.wax911.emoji.buildSrc.common.Configuration import io.wax911.emoji.buildSrc.plugin.extensions.isLibraryModule -import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.publish.maven.MavenPublication -import org.gradle.api.tasks.javadoc.Javadoc import org.gradle.kotlin.dsl.getValue import org.gradle.kotlin.dsl.invoke import org.gradle.kotlin.dsl.named -import java.io.File import java.net.URL -private fun Project.configureMavenPublish(javadocJar: Jar, sourcesJar: Jar) { +private fun Project.createMavenPublicationUsing(sourcesJar: Jar) { println("Applying publication configuration on ${project.path}") publishingExtension().publications { val component = components.findByName("android") @@ -27,9 +23,8 @@ private fun Project.configureMavenPublish(javadocJar: Jar, sourcesJar: Jar) { create("maven", MavenPublication::class.java) { groupId = "io.wax911.emoji" artifactId = project.name - version = Versions.versionName + version = Configuration.versionName - artifact(javadocJar) artifact(sourcesJar) artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar") from(component) @@ -56,153 +51,124 @@ private fun Project.configureMavenPublish(javadocJar: Jar, sourcesJar: Jar) { } } -private fun Project.configureDokka() { - val baseExt = baseExtension() - val mainSourceSet = baseExt.sourceSets["main"].java.srcDirs +private fun Project.createDokkaTaskProvider() = tasks.named("dokkaHtml") { + outputDirectory.set(buildDir.resolve("docs/dokka")) - println("Applying additional tasks options for dokka and javadoc on ${project.path}") + // Set module name displayed in the final output + moduleName.set(project.name) - val dokka = tasks.named("dokkaHtml") { - outputDirectory.set(buildDir.resolve("docs/dokka")) + // Use default or set to custom path to cache directory + // to enable package-list caching + // When this is set to default, caches are stored in $USER_HOME/.cache/dokka + //cacheRoot.set(file("default")) - // Set module name displayed in the final output - moduleName.set(project.name) + dokkaSourceSets { + configureEach { // Or source set name, for single-platform the default source sets are `main` and `test` + // Used when configuring source sets manually for declaring which source sets this one depends on + //dependsOn(dependenciesOfProject().map(Modules.Module::path)) - // Use default or set to custom path to cache directory - // to enable package-list caching - // When this is set to default, caches are stored in $USER_HOME/.cache/dokka - //cacheRoot.set(file("default")) + // Used to remove a source set from documentation, test source sets are suppressed by default + suppress.set(false) - dokkaSourceSets { - configureEach { // Or source set name, for single-platform the default source sets are `main` and `test` + // Used to prevent resolving package-lists online. When this option is set to true, only local files are resolved + offlineMode.set(false) // this is failing in the ci env - // Used to remove a source set from documentation, test source sets are suppressed by default - suppress.set(false) + // Use to include or exclude non public members + includeNonPublic.set(false) - // Used to prevent resolving package-lists online. When this option is set to true, only local files are resolved - offlineMode.set(false) + // Do not output deprecated members. Applies globally, can be overridden by packageOptions + skipDeprecated.set(false) - // Use to include or exclude non public members - includeNonPublic.set(false) - - // Do not output deprecated members. Applies globally, can be overridden by packageOptions - skipDeprecated.set(false) + // Emit warnings about not documented members. Applies globally, also can be overridden by packageOptions + reportUndocumented.set(true) - // Emit warnings about not documented members. Applies globally, also can be overridden by packageOptions - reportUndocumented.set(true) + // Do not create index pages for empty packages + skipEmptyPackages.set(true) - // Do not create index pages for empty packages - skipEmptyPackages.set(true) + // This name will be shown in the final output + //displayName.set("JVM") - // This name will be shown in the final output - displayName.set("JVM") + // Platform used for code analysis. See the "Platforms" section of this readme + platform.set(org.jetbrains.dokka.Platform.jvm) - // Platform used for code analysis. See the "Platforms" section of this readme - platform.set(org.jetbrains.dokka.Platform.jvm) + // Property used for manual addition of files to the classpath + // This property does not override the classpath collected automatically but appends to it + // classpath.from(file("libs/dependency.jar")) - // Property used for manual addition of files to the classpath - // This property does not override the classpath collected automatically but appends to it - // classpath.from(file("libs/dependency.jar")) + // List of files with module and package documentation + // https://kotlinlang.org/docs/reference/kotlin-doc.html#module-and-package-documentation + //includes.from("packages.md", "extra.md") - // List of files with module and package documentation - // https://kotlinlang.org/docs/reference/kotlin-doc.html#module-and-package-documentation - //includes.from("packages.md", "extra.md") + // List of files or directories containing sample code (referenced with @sample tags) + //samples.from("samples/basic.kt", "samples/advanced.kt") - // List of files or directories containing sample code (referenced with @sample tags) - //samples.from("samples/basic.kt", "samples/advanced.kt") + // By default, sourceRoots are taken from Kotlin Plugin and kotlinTasks, following roots will be appended to them + // Repeat for multiple sourceRoots + sourceRoot(file("src")) - // By default, sourceRoots are taken from Kotlin Plugin and kotlinTasks, following roots will be appended to them - // Repeat for multiple sourceRoots - sourceRoot(file("src")) + // Used for linking to JDK documentation + jdkVersion.set(8) - // Specifies the location of the project source code on the Web. - // If provided, Dokka generates "source" links for each declaration. - // Repeat for multiple mappings - sourceLink { - // Unix based directory relative path to the root of the project (where you execute gradle respectively). - localDirectory.set(file("src/main/kotlin")) + // Disable linking to online kotlin-stdlib documentation + noStdlibLink.set(false) - val repository = "https://github.com/anitrend/android-emojify/tree/develop" - // URL showing where the source code can be accessed through the web browser - remoteUrl.set(URL("$repository/${project.name}/src/main/kotlin")) - // Suffix which is used to append the line number to the URL. Use #L for GitHub - remoteLineSuffix.set("#L") - } + // Disable linking to online JDK documentation + noJdkLink.set(false) - // Used for linking to JDK documentation - jdkVersion.set(8) + // Disable linking to online Android documentation (only applicable for Android projects) + noAndroidSdkLink.set(false) - // Disable linking to online kotlin-stdlib documentation - noStdlibLink.set(false) + // Allows linking to documentation of the project"s dependencies (generated with Javadoc or Dokka) + // Repeat for multiple links + externalDocumentationLink { + // Root URL of the generated documentation to link with. The trailing slash is required! + url.set(URL("https://developer.android.com/reference/kotlin/")) - // Disable linking to online JDK documentation - noJdkLink.set(false) - - // Disable linking to online Android documentation (only applicable for Android projects) - noAndroidSdkLink.set(false) + // If package-list file is located in non-standard location + packageListUrl.set(URL("https://developer.android.com/reference/androidx/package-list")) + } - // Allows to customize documentation generation options on a per-package basis - // Repeat for multiple packageOptions - // If multiple packages match the same matchingRegex, the longuest matchingRegex will be used - perPackageOption { - matchingRegex.set("kotlin($|\\.).*") // will match kotlin and all sub-packages of it - // All options are optional, default values are below: - skipDeprecated.set(false) - reportUndocumented.set(true) // Emit warnings about not documented members - includeNonPublic.set(false) - } - // Suppress a package - perPackageOption { - matchingRegex.set(".*\\.internal.*") // will match all .internal packages and sub-packages - suppress.set(true) - } + // Allows to customize documentation generation options on a per-package basis + // Repeat for multiple packageOptions + // If multiple packages match the same matchingRegex, the longuest matchingRegex will be used + perPackageOption { + matchingRegex.set("kotlin($|\\.).*") // will match kotlin and all sub-packages of it + // All options are optional, default values are below: + skipDeprecated.set(false) + reportUndocumented.set(true) // Emit warnings about not documented members + includeNonPublic.set(false) + } + // Suppress a package + perPackageOption { + matchingRegex.set(".*\\.internal.*") // will match all .internal packages and sub-packages + suppress.set(true) } } } +} - val dokkaJar by tasks.register("dokkaJar", Jar::class.java) { - archiveClassifier.set("javadoc") - from(dokka) - } - val sourcesJar by tasks.register("sourcesJar", Jar::class.java) { - archiveClassifier.set("sources") - from(mainSourceSet) - } +@Suppress("UnstableApiUsage") +internal fun Project.configureOptions() { + if (isLibraryModule()) { + println("Applying additional tasks options for dokka and javadoc on ${project.path}") - val classesJar by tasks.register("classesJar", Jar::class.java) { - from("${project.buildDir}/intermediates/classes/release") - } + createDokkaTaskProvider() - val javadoc = tasks.create("javadoc", Javadoc::class.java) { - classpath += project.files(baseExt.bootClasspath.joinToString(File.pathSeparator)) - libraryExtension().libraryVariants.forEach { variant -> - if (variant.name == "release") { - classpath += variant.javaCompileProvider.get().classpath - } + val sourcesJar by tasks.register("sourcesJar", Jar::class.java) { + archiveClassifier.set("sources") + from(baseExtension().sourceSets["main"].java.srcDirs) } - exclude("**/R.html", "**/R.*.html", "**/index.html") - } - - val javadocJar = tasks.create("javadocJar", Jar::class.java) { - dependsOn(javadoc, dokka) - archiveClassifier.set("javadoc") - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - includeEmptyDirs = false - from(javadoc.destinationDir, dokka.flatMap { it.outputDirectory }) - } - artifacts { - add("archives", dokkaJar) - add("archives", classesJar) - add("archives", sourcesJar) - } + val classesJar by tasks.register("classesJar", Jar::class.java) { + from("${project.buildDir}/intermediates/classes/release") + } - configureMavenPublish(javadocJar, sourcesJar) -} + artifacts { + add("archives", classesJar) + add("archives", sourcesJar) + } -@Suppress("UnstableApiUsage") -internal fun Project.configureOptions() { - if (isLibraryModule()) - configureDokka() + createMavenPublicationUsing(sourcesJar) + } } \ No newline at end of file diff --git a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/strategy/DependencyStrategy.kt b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/strategy/DependencyStrategy.kt index 51da1712..b1a1fb10 100644 --- a/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/strategy/DependencyStrategy.kt +++ b/buildSrc/src/main/java/io/wax911/emoji/buildSrc/plugin/strategy/DependencyStrategy.kt @@ -16,15 +16,17 @@ internal class DependencyStrategy(private val project: Project) { private fun DependencyHandler.applyDefaultDependencies() { implementation(Libraries.JetBrains.Kotlin.stdlib) + implementation(Libraries.JetBrains.Kotlin.reflect) // Testing libraries testImplementation(Libraries.junit) - testImplementation(Libraries.mockk) + testImplementation(Libraries.Mockk.mockk) } private fun DependencyHandler.applyTestDependencies() { androidTestImplementation(Libraries.AndroidX.Test.core) androidTestImplementation(Libraries.AndroidX.Test.rules) androidTestImplementation(Libraries.AndroidX.Test.runner) + androidTestImplementation(Libraries.Mockk.mockkAndroid) testImplementation(Libraries.AndroidX.Test.Extension.junitKtx) }