Skip to content

Commit

Permalink
hotfix(refactor): remove initialization module and update workflow (#205
Browse files Browse the repository at this point in the history
)

* chore: remove initializer module
* fix: build directory path resolution when using `layout.buildDirectory`
* feat(platform): update workflows (add workflow for publishing to maven local, aid us in catching publication issues sooner)
  • Loading branch information
wax911 authored May 3, 2024
1 parent 171f688 commit 81e9616
Show file tree
Hide file tree
Showing 16 changed files with 80 additions and 125 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/android-publish-artifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: android-publish-artifact

on:
push:
branches: [ develop ]
pull_request:
branches:
- develop
paths-ignore:
- "app/src/main/**"

permissions:
checks: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v3
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Wait for tests to succeed
uses: lewagon/wait-on-check-action@v1.3.3
with:
ref: ${{ github.ref }}
running-workflow-name: android-publish-artifact
check-name: android-unit-test
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 20
- uses: gradle/actions/setup-gradle@v3
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Publish to local maven
run: |
./gradlew build publishMavenPublicationToMavenLocal
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: publications
path: ~/.m2/repository/io/wax911/emoji/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: android-test
name: android-unit-test

on:
push:
Expand All @@ -17,6 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/setup-gradle@v3
- uses: gradle/wrapper-validation-action@v3
- name: set up JDK 17
uses: actions/setup-java@v4
Expand All @@ -35,31 +36,3 @@ jobs:
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/**/TEST-*.xml'

instrumented:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
api-level:
- 23
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v3
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- uses: gradle/gradle-build-action@v3
- name: Run Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
script: ./gradlew connectedCheck
env:
API_LEVEL: ${{ matrix.api-level }}
- name: Publish Integrated Test Report
uses: mikepenz/action-junit-report@v4
if: always() # always run even if the previous step fails
with:
report_paths: '**/build/androidTest-results/**/TEST-*.xml'
1 change: 0 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
dependencies {
implementation(project(Libraries.AniTrend.Emojify.emojify))
implementation(project(Libraries.AniTrend.Emojify.contract))
implementation(project(Libraries.AniTrend.Emojify.initializer))
implementation(project(Libraries.AniTrend.Emojify.serializerKotlinx))

implementation(libs.google.android.material)
Expand Down
24 changes: 21 additions & 3 deletions app/src/main/java/io/wax911/emojifysample/EmojiInitializer.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
package io.wax911.emojifysample

import android.content.Context
import androidx.startup.Initializer
import io.wax911.emojify.EmojiManager
import io.wax911.emojify.contract.serializer.IEmojiDeserializer
import io.wax911.emojify.initializer.AbstractEmojiInitializer
import io.wax911.emojify.serializer.kotlinx.KotlinxDeserializer

class EmojiInitializer : AbstractEmojiInitializer() {
override val serializer: IEmojiDeserializer = KotlinxDeserializer()
class EmojiInitializer : Initializer<EmojiManager> {
private val serializer: IEmojiDeserializer = KotlinxDeserializer()

/**
* Initializes and a component given the application [Context]
*
* @param context The application context.
*/
override fun create(context: Context) = EmojiManager.create(context, serializer)

/**
* @return A list of dependencies that this [Initializer] depends on. This is
* used to determine initialization order of [Initializer]s.
*
* For e.g. if a [Initializer] `B` defines another
* [Initializer] `A` as its dependency, then `A` gets initialized before `B`.
*/
override fun dependencies() = emptyList<Class<out Initializer<*>>>()
}
10 changes: 10 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask

plugins {
id("org.jetbrains.dokka")
}

buildscript {
repositories {
Expand All @@ -18,3 +23,8 @@ allprojects {
mavenCentral()
}
}

tasks.withType(DokkaMultiModuleTask::class.java) {
outputDirectory.set(rootProject.file("dokka-docs"))
failOnWarning.set(false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ object Libraries {
object Emojify {
val emojify = Modules.Library.Emojify.path()
val contract = Modules.Library.Contract.path()
val initializer = Modules.Library.Initializer.path()
val serializerKotlinx = Modules.Library.SerializerKotlinX.path()
val serializerGson = Modules.Library.SerializerGson.path()
val serializerMoshi = Modules.Library.SerializerMoshi.path()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ internal object Modules {
enum class Library(override val id: String) : Module {
Emojify("emojify"),
Contract("contract"),
Initializer("initializer"),
SerializerKotlinX("serializer:kotlinx"),
SerializerGson("serializer:gson"),
SerializerMoshi("serializer:moshi"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal fun Project.configureSpotless() {
spotlessExtension().run {
kotlin {
target("**/kotlin/**/*.kt")
targetExclude("${layout.buildDirectory}/**/*.kt", "**/test/**/*.kt", "bin/**/*.kt")
targetExclude("${layout.buildDirectory.get()}/**/*.kt", "**/test/**/*.kt", "bin/**/*.kt")
ktlint(libs.versions.ktlint.get())
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ import java.net.URL

private fun Project.dependenciesOfProject(): List<Modules.Module> {
return when (project.name) {
Modules.Library.Initializer.id -> listOf(
Modules.Library.Contract,
Modules.Library.Emojify,
)
Modules.Library.Emojify.id -> listOf(
Modules.Library.Contract,
)
Expand All @@ -46,7 +42,7 @@ private fun Project.createMavenPublicationUsing(sourcesJar: Jar) {
version = props[PropertyTypes.VERSION]

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

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


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

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

artifacts {
Expand Down
1 change: 0 additions & 1 deletion initializer/.gitignore

This file was deleted.

15 changes: 0 additions & 15 deletions initializer/build.gradle.kts

This file was deleted.

15 changes: 0 additions & 15 deletions initializer/src/main/AndroidManifest.xml

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
rootProject.name = "android-emojify"
include(":emojify")
include(":contract")
include(":initializer")
include(":serializer:kotlinx")
include(":serializer:gson")
include(":serializer:moshi")
Expand Down

0 comments on commit 81e9616

Please sign in to comment.