Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#513] [KMM Support] Migrate to Gradle 8 #508

Merged
merged 12 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
timeout-minutes: 30
steps:
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
run: ./gradlew detekt

- name: Archive Detekt reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: DetektReports
path: build/reports/detekt/
Expand All @@ -51,7 +51,7 @@ jobs:
run: ./gradlew koverHtmlReport

- name: Archive code coverage reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: CodeCoverageReports
path: app/build/reports/kover/
Expand Down
2 changes: 1 addition & 1 deletion .cicdtemplate/.github/workflows/review_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
timeout-minutes: 30
steps:
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
timeout-minutes: 30
steps:
- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
run: ./gradlew detekt

- name: Archive Detekt reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: DetektReports
path: build/reports/detekt/
Expand All @@ -54,7 +54,7 @@ jobs:
run: ./gradlew koverHtmlReport

- name: Archive code coverage reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: CodeCoverageReports
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/review_pull_request.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the Cache gems step and set the bundler-cache: true at Set up Ruby step like we did in KMM Templates?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lydiasama Yes, but it's out of this PR's scope. I recommend revising this workflow from this task instead #519.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
environment: template-compose
steps:
- name: Set up JDK 11
doannimble marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
Expand Down Expand Up @@ -47,6 +47,12 @@ jobs:

# template-compose

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Run Detekt on template-compose
working-directory: ./template-compose
run: ./gradlew detekt
Expand Down
72 changes: 39 additions & 33 deletions .github/workflows/run_detekt_and_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'

- name: Checkout source code
uses: actions/[email protected]

Expand All @@ -28,36 +22,20 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-

# template-xml

- name: Run Detekt on template-xml
working-directory: ./template-xml
run: ./gradlew detekt

- name: Archive Detekt reports on template-xml
uses: actions/upload-artifact@v2
with:
name: DetektReportsTemplateXML
path: template-xml/build/reports/detekt/

- name: Run unit tests with Kover on template-xml
working-directory: ./template-xml
run: ./gradlew koverHtmlReport
# template-compose

- name: Archive code coverage reports on template-xml
uses: actions/upload-artifact@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
name: CodeCoverageReportsTemplateXML
path: template-xml/app/build/reports/kover/

# template-compose
distribution: 'temurin'
java-version: '17'

- name: Run Detekt on template-compose
working-directory: ./template-compose
run: ./gradlew detekt

- name: Archive Detekt reports on template-compose
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: DetektReportsTemplateCompose
path: template-compose/build/reports/detekt/
Expand All @@ -67,19 +45,47 @@ jobs:
run: ./gradlew koverHtmlReport

- name: Archive code coverage reports on template-compose
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: CodeCoverageReportsTemplateCompose
path: template-compose/app/build/reports/kover/

# template-xml

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'

- name: Run Detekt on template-xml
working-directory: ./template-xml
run: ./gradlew detekt

- name: Archive Detekt reports on template-xml
uses: actions/upload-artifact@v3
with:
name: DetektReportsTemplateXML
path: template-xml/build/reports/detekt/

- name: Run unit tests with Kover on template-xml
working-directory: ./template-xml
run: ./gradlew koverHtmlReport

- name: Archive code coverage reports on template-xml
uses: actions/upload-artifact@v3
with:
name: CodeCoverageReportsTemplateXML
path: template-xml/app/build/reports/kover/

# sample-xml

- name: Run Detekt on sample-xml
working-directory: ./sample-xml
run: ./gradlew detekt

- name: Archive Detekt reports on sample-xml
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: DetektReportsTemplateXML
path: sample-xml/build/reports/detekt/
Expand All @@ -89,7 +95,7 @@ jobs:
run: ./gradlew koverHtmlReport

- name: Archive code coverage reports on sample-xml
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: CodeCoverageReportsTemplateXML
path: sample-xml/app/build/reports/kover/
Expand All @@ -101,7 +107,7 @@ jobs:
run: ./gradlew detekt

- name: Archive Detekt reports on sample-compose
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: DetektReportsTemplateCompose
path: sample-compose/build/reports/detekt/
Expand All @@ -111,7 +117,7 @@ jobs:
run: ./gradlew koverHtmlReport

- name: Archive code coverage reports on sample-compose
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: CodeCoverageReportsTemplateCompose
path: sample-compose/app/build/reports/kover/
8 changes: 7 additions & 1 deletion .github/workflows/verify_newproject_script.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
timeout-minutes: 30
steps:
- name: Set up JDK 11
doannimble marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
Expand Down Expand Up @@ -44,6 +44,12 @@ jobs:
working-directory: scripts
run: kscript new_project.kts package-name=co.myxmlproject.example app-name="My XML Project" template=xml

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Verify generating new project from template-compose
working-directory: scripts
run: kscript new_project.kts package-name=co.mycomposeproject.example app-name="My Compose Project" template=compose
Expand Down
10 changes: 10 additions & 0 deletions scripts/new_project.kts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,16 @@ object NewProject {
newValue = appName
)
}
File(projectPath)
.walk()
.filter { it.name == "settings.gradle.kts" }
.forEach { filePath ->
rename(
sourcePath = filePath.toString(),
oldValue = templateAppName,
newValue = appName
)
}
kaungkhantsoe marked this conversation as resolved.
Show resolved Hide resolved
}

private fun rename(sourcePath: String, oldValue: String, newValue: String) {
Expand Down
57 changes: 36 additions & 21 deletions template-compose/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.konan.properties.loadProperties

plugins {
id(Plugins.ANDROID_APPLICATION)
id(Plugins.KOTLIN_ANDROID)
Expand All @@ -7,7 +9,7 @@ plugins {
id(Plugins.KOVER)
}

val keystoreProperties = rootDir.loadGradleProperties("signing.properties")
val signingProperties = loadProperties("$rootDir/signing.properties")
luongvo marked this conversation as resolved.
Show resolved Hide resolved
val getVersionCode: () -> Int = {
if (project.hasProperty("versionCode")) {
(project.property("versionCode") as String).toInt()
Expand All @@ -17,13 +19,29 @@ val getVersionCode: () -> Int = {
}

android {
namespace = "co.nimblehq.template.compose"
compileSdk = Versions.ANDROID_COMPILE_SDK

defaultConfig {
applicationId = "co.nimblehq.template.compose"
minSdk = Versions.ANDROID_MIN_SDK
targetSdk = Versions.ANDROID_TARGET_SDK
versionCode = getVersionCode()
versionName = Versions.ANDROID_VERSION_NAME

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

signingConfigs {
create(BuildTypes.RELEASE) {
// Remember to edit signing.properties to have the correct info for release build.
storeFile = file("../config/release.keystore")
storePassword = keystoreProperties.getProperty("KEYSTORE_PASSWORD") as String
keyPassword = keystoreProperties.getProperty("KEY_PASSWORD") as String
keyAlias = keystoreProperties.getProperty("KEY_ALIAS") as String
storePassword = signingProperties.getProperty("KEYSTORE_PASSWORD") as String
keyPassword = signingProperties.getProperty("KEY_PASSWORD") as String
keyAlias = signingProperties.getProperty("KEY_ALIAS") as String
}

getByName(BuildTypes.DEBUG) {
Expand All @@ -34,18 +52,8 @@ android {
}
}

compileSdk = Versions.ANDROID_COMPILE_SDK
defaultConfig {
applicationId = "co.nimblehq.template.compose"
minSdk = Versions.ANDROID_MIN_SDK
targetSdk = Versions.ANDROID_TARGET_SDK
versionCode = getVersionCode()
versionName = Versions.ANDROID_VERSION_NAME
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
getByName(BuildTypes.RELEASE) {
release {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to update this? πŸ€”

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lydiasama release { is a new supported block from Gradle 8's DSL. We should use any built-in features instead of manual configurations πŸ€“

isMinifyEnabled = true
isDebuggable = false
isShrinkResources = true
Expand All @@ -54,7 +62,7 @@ android {
buildConfigField("String", "BASE_API_URL", "\"https://jsonplaceholder.typicode.com/\"")
}

getByName(BuildTypes.DEBUG) {
debug {
// For quickly testing build with proguard, enable this
isMinifyEnabled = false
signingConfig = signingConfigs[BuildTypes.DEBUG]
Expand All @@ -76,20 +84,27 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
jvmTarget = JavaVersion.VERSION_17.toString()
}

buildFeatures {
compose = true
buildConfig = true
}

composeOptions {
kotlinCompilerExtensionVersion = Versions.COMPOSE_COMPILER
}

buildFeatures {
compose = true
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}

lint {
Expand Down
3 changes: 1 addition & 2 deletions template-compose/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="co.nimblehq.template.compose">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!--For Chucker in debug build only-->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
Expand Down
Loading
Loading