Skip to content

Commit

Permalink
feat: migrate to kotlin 2xx
Browse files Browse the repository at this point in the history
  • Loading branch information
doananhtuan22111996 committed Nov 17, 2024
1 parent f056fd5 commit 39743ba
Show file tree
Hide file tree
Showing 18 changed files with 151 additions and 259 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ jobs:
build:
runs-on: ubuntu-latest
env:
USERNAME: ${{ secrets.USERNAME }}
TOKEN: ${{ secrets.TOKEN }}
GH_USERNAME: ${{ secrets.GH_USERNAME }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_REPO_NAME: ${{ secrets.GH_REPO_NAME }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: gradle

Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ jobs:
build:
runs-on: ubuntu-latest
env:
USERNAME: ${{ secrets.USERNAME }}
TOKEN: ${{ secrets.TOKEN }}
GH_USERNAME: ${{ secrets.GH_USERNAME }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_REPO_NAME: ${{ secrets.GH_REPO_NAME }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Publish vn.core.libx-ui.composex
run: ./gradlew :libx:composex:publish
- name: Publish vn.core.libs.compose
run: ./gradlew :libx:composex:publishComposePublicationToPackagesRepository
continue-on-error: true

- name: Publish vn.core.libx-ui.mdc
run: ./gradlew :libx:mdc:publish
- name: Publish vn.core.libs.mdc
run: ./gradlew :libx:mdc:publishMdcPublicationToPackagesRepository
continue-on-error: true

- name: Sending report to Telegram
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ jobs:
build:
runs-on: ubuntu-latest
env:
USERNAME: ${{ secrets.USERNAME }}
TOKEN: ${{ secrets.TOKEN }}
GH_USERNAME: ${{ secrets.GH_USERNAME }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_REPO_NAME: ${{ secrets.GH_REPO_NAME }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: gradle

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ google-services.json

# Android Profiling
*.hprof
.kotlin
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.android.library) apply false
alias(mobilex.plugins.composeCompiler) apply false
alias(mobilex.plugins.androidHilt) apply false
}
1 change: 1 addition & 0 deletions buildSrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import java.util.Properties

plugins {
`kotlin-dsl`
}

repositories {
google()
mavenCentral()
mavenLocal()
gradlePluginPortal()
maven {
val ghUsername = System.getenv("GH_USERNAME") ?: getLocalProperty("GH_USERNAME")
val ghPassword = System.getenv("GH_TOKEN") ?: getLocalProperty("GH_TOKEN")
url = uri("https://maven.pkg.github.com/${ghUsername}/REPOSITORY")
credentials {
username = ghUsername
password = ghPassword
}
}
}

dependencies {
implementation(libs.corePlugins)
}

fun getLocalProperty(propertyName: String): String {
val localProperties = Properties().apply {
val localPropertiesFile = File(rootDir, "local.properties")
if (localPropertiesFile.exists()) {
load(localPropertiesFile.inputStream())
}
}

return localProperties.getProperty(propertyName) ?: run {
throw NoSuchFieldException("Not defined property: $propertyName")
}
}
7 changes: 7 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
11 changes: 11 additions & 0 deletions buildSrc/src/main/java/vn/core/libx/buildSrc/Configs.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package vn.core.libx.buildSrc

object Configs {

object Artifact {
const val GROUP_ID = "vn.core.libs"
const val ARTIFACT_COMPOSE_ID = "compose"
const val ARTIFACT_MDC_ID = "mdc"
const val VERSION = "1.0.0"
}
}
4 changes: 4 additions & 0 deletions buildSrc/src/main/java/vn/core/libx/buildSrc/MyClass.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package vn.core.libx.buildSrc

class MyClass {
}
56 changes: 3 additions & 53 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,59 +1,9 @@
[versions]
compileSdk = "34"
minSdk = "24"
agp = "8.6.0"
kotlin = "1.9.24"
coreKtx = "1.13.1"
junit = "4.13.2"
junitVersion = "1.2.1"
espressoCore = "3.6.1"
appcompat = "1.7.0"
material = "1.12.0"
uiTextGoogleFonts = "1.6.8"
corePlugins = "1.0.1"
domain = "1.0.0"
constraintlayout = "2.1.4"
lifecycleLivedataKtx = "2.8.4"
lifecycleViewmodelKtx = "2.8.4"
navigationFragmentKtx = "2.7.7"
navigationUiKtx = "2.7.7"
lifecycleRuntimeKtx = "2.8.4"
activityCompose = "1.9.1"
composeBom = "2024.08.00"
pagingComposeAndroid = "3.3.2"
paging = "3.3.2"
splashscreen = "1.0.1"

[libraries]
core-domain = { group = "vn.core.libx", name = "domain", version.ref = "domain" }

androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
androidx-ui-text-google-fonts = { group = "androidx.compose.ui", name = "ui-text-google-fonts", version.ref = "uiTextGoogleFonts" }
androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycleLivedataKtx" }
androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycleViewmodelKtx" }
androidx-navigation-fragment-ktx = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigationFragmentKtx" }
androidx-navigation-ui-ktx = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigationUiKtx" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
androidx-ui = { group = "androidx.compose.ui", name = "ui" }
androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
androidx-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
androidx-material3-icons = { group = "androidx.compose.material", name = "material-icons-extended" }
androidx-paging-compose = { group = "androidx.paging", name = "paging-compose", version.ref = "paging" }
androidx-core-splashscreen = { group = "androidx.core", name = "core-splashscreen", version.ref = "splashscreen" }
corePlugins = { group = "vn.core.libs", name = "plugins", version.ref = "corePlugins" }
domain = { group = "vn.core.libs", name = "domain", version.ref = "domain" }

[plugins]
android-application = { id = "com.android.application", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
android-library = { id = "com.android.library", version.ref = "agp" }

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Sep 01 14:58:09 ICT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
90 changes: 12 additions & 78 deletions libx/composex/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,94 +1,28 @@
import vn.core.libx.buildSrc.Configs

plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
id("maven-publish")
vn.core.plugins.androidLibrary
vn.core.plugins.androidCompose
vn.core.plugins.androidPublishing
}

android {
namespace = "vn.core.libx.composex"
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.14"
}
}

dependencies {
implementation(libs.core.domain)

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
implementation(libs.material)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.androidx.paging.compose)
implementation(libs.androidx.ui.text.google.fonts)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
implementation(libs.domain)
}

publishing {
val ghUsername = System.getenv("USERNAME")
val ghPassword = System.getenv("TOKEN")
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/${ghUsername}/android-components")
credentials {
username = ghUsername
password = ghPassword
}
}
}
publications {
create<MavenPublication>("mavenJava") {
create<MavenPublication>(Configs.Artifact.ARTIFACT_COMPOSE_ID) {
afterEvaluate {
from(components["release"])
from(components["all"])
}
groupId = "vn.core.libx-ui" // Replace with your GitHub username
artifactId = "composex"
version = "1.0.2" // Set your desired version here
groupId = Configs.Artifact.GROUP_ID // Replace with your GitHub username
artifactId = Configs.Artifact.ARTIFACT_COMPOSE_ID
version = Configs.Artifact.VERSION // Set your desired version here
}
}
}
}
Empty file removed libx/composex/consumer-rules.pro
Empty file.
Loading

0 comments on commit 39743ba

Please sign in to comment.