Skip to content

Commit

Permalink
Merge pull request #2 from SeanZoR/feature/maven-publish
Browse files Browse the repository at this point in the history
Complete Maven Publish
  • Loading branch information
SeanZoR authored Sep 4, 2024
2 parents 10d01a2 + e057d6f commit 4045d5c
Show file tree
Hide file tree
Showing 15 changed files with 287 additions and 155 deletions.
48 changes: 47 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache Gradle
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
Expand All @@ -29,4 +37,42 @@ jobs:
files: |
hiltcoroutines/build/outputs/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
environment:
name: "maven_publish"

needs: build

runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v4

- name: Cache Gradle
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-${{ runner.os }}-
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

- name: Make Gradle executable
run: chmod +x ./gradlew

- name: Upload library
run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache

env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKey }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKeyPassword }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralUsername }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralPassword }}
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
Add the following dependency to your `build.gradle` file:

```kotlin
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}

dependencies {
implementation("com.github.seanzor:hiltcoroutines:x.x.x")
implementation("com.sean8:hiltcoroutines:0.0.7")
}
```

Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.jetbrains.kotlin.android) apply false
Expand Down
24 changes: 4 additions & 20 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonTransitiveRClass=true

SONATYPE_HOST=CENTRAL_PORTAL
RELEASE_SIGNING_ENABLED=true
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ appcompat = "1.7.0"
kotlinxCoroutinesCore = "1.6.0"
ksp = "2.0.0-1.0.21"
robolectric = "4.12.2"
custom-maven-publish = "0.29.0"

[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
Expand All @@ -24,3 +25,4 @@ robolectric = { group = "org.robolectric", name = "robolectric", version.ref = "
jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
android-library = { id = "com.android.library", version.ref = "agp" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
custom-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "custom-maven-publish" }
45 changes: 27 additions & 18 deletions hiltcoroutines/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.ksp)
`maven-publish`
alias(libs.plugins.custom.maven.publish)
}

android {
namespace = "com.github.seanzor.hiltcoroutines"
namespace = "com.sean8.hiltcoroutines"
compileSdk = 34

defaultConfig {
minSdk = 24
minSdk = 21

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -27,26 +27,35 @@ android {
kotlinOptions {
jvmTarget = "1.8"
}

publishing {
singleVariant("release") {
withSourcesJar()
}
}
}

project.afterEvaluate {
publishing {
publications {
create<MavenPublication>("release") {
from(components["release"])
mavenPublishing {
coordinates("com.sean8", "hiltcoroutines", "0.0.7")

// values used for local maven repo, jitpack uses github release:
groupId = "com.github.seanzor"
artifactId = "hiltcoroutines"
version = "0.0.4"
pom {
name.set("HiltCoroutines")
description.set("A library for integrating Hilt with Coroutines.")
inceptionYear.set("2023")
url.set("https://github.com/seanzor/hiltcoroutines/")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("Sean8")
name.set("Sean Katz")
url.set("https://sean8.com")
}
}
scm {
url.set("https://github.com/seanzor/hiltcoroutines/")
connection.set("scm:git:git://github.com/seanzor/hiltcoroutines.git")
developerConnection.set("scm:git:ssh://[email protected]/seanzor/hiltcoroutines.git")
}
}
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.sean8.hiltcoroutines

import javax.inject.Qualifier
import kotlin.annotation.AnnotationRetention.RUNTIME

/**
* Qualifier annotation for specifying different Coroutine Dispatchers.
*
* This is used to distinguish between the different [AppDispatchers] provided
* by the dependency injection framework using Hilt.
*
* @property appDispatcher The dispatcher type from [AppDispatchers].
*/
@Suppress("unused")
@Qualifier
@Retention(RUNTIME)
annotation class Dispatcher(val appDispatcher: AppDispatchers)

/**
* Enum representing the available coroutine dispatchers in the application.
*
* - [Default] corresponds to [Dispatchers.Default].
* - [IO] corresponds to [Dispatchers.IO].
* - [Main] corresponds to [Dispatchers.Main].
*/
enum class AppDispatchers {
Default,
IO,
Main,
}
Loading

0 comments on commit 4045d5c

Please sign in to comment.