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

chore: update build process #22

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
6 changes: 3 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: ./.github/actions/setup

- name: Build Android
run: ./gradlew assemble${{ matrix.type }}
run: ./gradlew clean assemble${{ matrix.type }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a shame if we clean every time, because that clears the work we cached and slows things down. Can we run a specific gradle task do clean what we need?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes we can run copyCommonResourcesToFlavor

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also thinking, maybe it can go into the actions/setup?


- name: Build iOS
run: ./gradlew link${{ matrix.type }}FrameworkIosSimulatorArm64
Expand All @@ -38,7 +38,7 @@ jobs:
uses: ./.github/actions/setup

- name: Run lint
run: ./gradlew lint
run: ./gradlew clean lint

- name: Uploads test reports
uses: actions/upload-artifact@v4
Expand All @@ -59,7 +59,7 @@ jobs:
uses: ./.github/actions/setup

- name: Run lint
run: ./gradlew ktlintCheck
run: ./gradlew clean ktlintCheck

- name: Uploads test reports
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ plugins {
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.cocoapods) apply false
alias(libs.plugins.ktlint) apply false
}
}
25 changes: 15 additions & 10 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ kotlin {
}
}

compose.resources {
customDirectory(
sourceSetName = "commonMain",
directoryProvider = provider { layout.projectDirectory.dir(config.resRoot) },
)
}

android {
namespace = "org.ooni.probe"
compileSdk = libs.versions.android.compileSdk.get().toInt()
Expand Down Expand Up @@ -161,9 +154,9 @@ tasks.register("copyCommonResourcesToFlavor") {
doLast {
val projectDir = project.projectDir.absolutePath

val sourceFile = File(projectDir, "src/commonMain/composeResources")
val destinationFile = File(projectDir, "src/commonMain/composeResources")

val destinationFile = File(projectDir, config.resRoot)
val sourceFile = File(projectDir, config.resRoot)

copyRecursive(sourceFile, destinationFile)
}
Expand All @@ -173,7 +166,7 @@ tasks.register("cleanCopiedCommonResourcesToFlavor") {
doLast {
val projectDir = project.projectDir.absolutePath

val destinationFile = File(projectDir, config.resRoot)
val destinationFile = File(projectDir, "src/commonMain/composeResources")
destinationFile.listFiles()?.forEach { folder ->
folder.listFiles()?.forEach { file ->
if (file.name == ".gitignore") {
Expand Down Expand Up @@ -279,3 +272,15 @@ fun copyRecursive(
}
}
}

tasks.register("runDebug", Exec::class) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need this task?

Copy link
Member Author

Choose a reason for hiding this comment

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

This enables us to set up custom gradle tasks with composeApp:runDebug -Porganization=ooni or composeApp:runDebug -Porganization=dw to run the various flavors without needing to edit files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't we add the flag to Android Studio run configuration?

Screenshot 2024-07-30 at 15 18 13

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't tried any option that works

dependsOn("clean", "uninstallDebug", "installDebug")
Copy link
Collaborator

@sdsantos sdsantos Jul 30, 2024

Choose a reason for hiding this comment

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

I feel like instead of relying so much on the clean gradle task to copy the resources as we need every time, we should figure out the right gradle task that runs on every build. Isn't the preBuild setup working?

Because running clean often slows down everything.

Copy link
Member Author

Choose a reason for hiding this comment

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

The pre build works locally but for some reason it fails on the ci

Copy link
Collaborator

Choose a reason for hiding this comment

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

If I run gradlew assemble it works fine locally, it grabs the resources.

Copy link
Member Author

Choose a reason for hiding this comment

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

but you can launch the dw flavor

commandLine(
"adb",
"shell",
"am",
"start",
"-n",
"${config.appId}.debug/org.ooni.probe.MainActivity",
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

logo.xml

This file was deleted.

2 changes: 2 additions & 0 deletions composeApp/src/commonMain/composeResources/values/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

strings-organization.xml
2 changes: 0 additions & 2 deletions composeApp/src/dwMain/resources/drawable/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions composeApp/src/dwMain/resources/values/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions composeApp/src/ooniMain/resources/drawable/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions composeApp/src/ooniMain/resources/values/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android-compileSdk = "34"
android-minSdk = "24"
android-targetSdk = "34"

compose-plugin = "1.7.0-alpha02"
compose-plugin = "1.6.11"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can go back to the stable version? Nice!

kotlin = "2.0.0"

[plugins]
Expand Down