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
Changes from 1 commit
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
Next Next commit
chore: update build process
aanorbel committed Jul 30, 2024

Verified

This commit was signed with the committer’s verified signature.
aanorbel Norbel AMBANUMBEN
commit df0def3f43d9f6fab7bb638d9ddb1188fc5dce12
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -8,4 +8,4 @@ plugins {
alias(libs.plugins.kotlinMultiplatform) apply false
alias(libs.plugins.cocoapods) apply false
alias(libs.plugins.ktlint) apply false
}
}
26 changes: 12 additions & 14 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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()
@@ -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)
}
@@ -173,9 +166,10 @@ 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 ->
println(file.absoluteFile)
aanorbel marked this conversation as resolved.
Show resolved Hide resolved
if (file.name == ".gitignore") {
file.readText().lines().forEach { line ->
if (line.isNotEmpty()) {
@@ -201,10 +195,6 @@ tasks.named("preBuild").configure {
dependsOn("copyCommonResourcesToFlavor")
}

tasks.named("clean").configure {
dependsOn("copyCommonResourcesToFlavor")
}

tasks.named("clean").configure {
dependsOn("cleanCopiedCommonResourcesToFlavor")
}
@@ -279,3 +269,11 @@ 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
@@ -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]