Skip to content

Commit

Permalink
chore: house keeping refactoring and cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed Mar 19, 2024
1 parent d91a631 commit d15bf86
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ open class CorePlugin : Plugin<Project> {
/**
* Inspecting available extensions
*/
@Suppress("UnstableApiUsage")
internal fun Project.availableExtensions() {
private fun Project.availableExtensions() {
val extensionSchema = project.extensions.extensionsSchema
extensionSchema.forEach {
println("Available extension for module ${project.path}: ${it.name} -> ${it.publicType}")
Expand All @@ -24,8 +23,7 @@ open class CorePlugin : Plugin<Project> {
/**
* Inspecting available components
*/
@Suppress("UnstableApiUsage")
internal fun Project.availableComponents() {
private fun Project.availableComponents() {
val collectionSchema = project.components.asMap
collectionSchema.forEach {
println("Available component for module ${project.path}: ${it.key} -> ${it.value}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package io.wax911.emoji.buildSrc.plugin.components

import com.android.build.gradle.internal.dsl.DefaultConfig
import io.wax911.emoji.buildSrc.plugin.extensions.*
import io.wax911.emoji.buildSrc.plugin.extensions.baseAppExtension
import io.wax911.emoji.buildSrc.plugin.extensions.baseExtension
import io.wax911.emoji.buildSrc.plugin.extensions.isLibraryModule
import io.wax911.emoji.buildSrc.plugin.extensions.isSampleModule
import io.wax911.emoji.buildSrc.plugin.extensions.libs
import io.wax911.emoji.buildSrc.plugin.extensions.props
import io.wax911.emoji.buildSrc.plugin.extensions.spotlessExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
Expand All @@ -13,7 +19,7 @@ internal fun Project.configureSpotless() {
spotlessExtension().run {
kotlin {
target("**/kotlin/**/*.kt")
targetExclude("$buildDir/**/*.kt", "**/test/**/*.kt", "bin/**/*.kt")
targetExclude("${layout.buildDirectory}/**/*.kt", "**/test/**/*.kt", "bin/**/*.kt")
ktlint(libs.versions.ktlint.get())
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
Expand All @@ -28,7 +34,6 @@ private fun Project.configureLint() = baseAppExtension().run {
}
}

@Suppress("UnstableApiUsage")
private fun DefaultConfig.applyAdditionalConfiguration(project: Project) {
if (project.isSampleModule()) {
applicationId = "io.wax911.emoji.sample"
Expand Down Expand Up @@ -106,9 +111,7 @@ internal fun Project.configureAndroid(): Unit = baseExtension().run {
if (isSampleModule()) {
compileArgs.add("-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi")
compileArgs.add("-opt-in=kotlinx.coroutines.FlowPreview")
} else
compileArgs.add("-opt-in=kotlinx.serialization.ExperimentalSerializationApi")
// Filter out modules that won't be using coroutines
}
freeCompilerArgs = compileArgs
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private fun Project.createMavenPublicationUsing(sourcesJar: Jar) {
version = props[PropertyTypes.VERSION]

artifact(sourcesJar)
artifact("${project.buildDir}/outputs/aar/${project.name}-release.aar")
artifact("${project.layout.buildDirectory}/outputs/aar/${project.name}-release.aar")
from(component)

pom {
Expand Down Expand Up @@ -148,7 +148,6 @@ private fun Project.createDokkaTaskProvider() = tasks.named<DokkaTask>("dokkaHtm
}


@Suppress("UnstableApiUsage")
internal fun Project.configureOptions() {
if (isLibraryModule()) {
println("Applying additional tasks options for dokka and javadoc on ${project.path}")
Expand All @@ -161,7 +160,7 @@ internal fun Project.configureOptions() {
}

val classesJar by tasks.register("classesJar", Jar::class.java) {
from("${project.buildDir}/intermediates/classes/release")
from("${project.layout.buildDirectory}/intermediates/classes/release")
}

artifacts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ fun Project.isSampleModule() =
name == Modules.App.Sample.id

fun Project.isLibraryModule() =
name == Modules.Library.Emojify.id
name == "emojify" ||
name == "contract" ||
name == "kotlinx" ||
name == "gson" ||
name == "moshi"

internal val Project.libs: LibrariesForLibs
get() =
extensions.getByType<LibrariesForLibs>()
get() = extensions.getByType<LibrariesForLibs>()

internal val Project.props: PropertiesReader
get() = PropertiesReader(this)
Expand Down
12 changes: 1 addition & 11 deletions contract/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("io.wax911.emojify")
}

android {
namespace = "io.wax911.emojify.contract"
compileSdk = 34

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import java.io.InputStream
class KotlinxDeserializer : IEmojiDeserializer {
private val json = Json { isLenient = true }

@OptIn(kotlinx.serialization.ExperimentalSerializationApi::class)
@Throws(SerializationException::class)
override fun decodeFromStream(inputStream: InputStream): List<AbstractEmoji> {
val deserializer = ListSerializer(KotlinxEmoji.serializer())
Expand Down

0 comments on commit d15bf86

Please sign in to comment.