Skip to content

Commit

Permalink
Migrate to new plugins {} format in buildscripts and rename flavors…
Browse files Browse the repository at this point in the history
… to `demo` and `full` instead of `flavor1` (#131)

Fixes #131
  • Loading branch information
arunkumar9t2 committed Apr 8, 2024
1 parent 4d271a8 commit ecbe062
Show file tree
Hide file tree
Showing 53 changed files with 238 additions and 340 deletions.
2 changes: 1 addition & 1 deletion .bazel/.ci.bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
common:ci --noshow_progress
common:ci --color=no
common:ci --color=yes
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
find "$(pwd -P)" -type f \
\( -name "*.bazel" -o -name "WORKSPACE" \) \
-not -path "*/buildsystem/*" \
-exec bazelisk run //:buildifier -- --mode=check -v {} +
-exec bazelisk run //:buildifier --config=ci -- --mode=check -v {} +
bazel-build:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Bazel Android Lint
uses: ./.github/actions/bazel
with:
bazel-command: test //sample-android:sample-android-flavor1-free-debug.lint_test
bazel-command: test //sample-android:sample-android-demo-free-debug.lint_test
cache-key: bazel-lint

grazel-build:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
!.idea/runConfigurations.xml
!.idea/.name

/.aswb
/.ijwb

.DS_Store
/captures
.externalNativeBuild
Expand Down
7 changes: 0 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ A full test suite can be executed via the following command and will be tested o
./gradlew check
```

- `sample-android`
- `sample-android-flavor`
- `sample-android-lib`
- `sample-kotlin-lib`
- `sample-lib-flavor1`
- `sample-lib-flavor2`

In order to test your changes and see if the `BUILD.bazel` is being generated as intended, execute
the following command in the project root directory

Expand Down
File renamed without changes.
23 changes: 9 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,21 @@ import com.android.build.gradle.BaseExtension

buildscript {
apply from: "constants.gradle"
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath libs.kotlin.gradle.plugin
classpath libs.android.gradle.plugin
classpath libs.google.firebase.crashlytics
classpath libs.google.mobile.services
classpath "com.grab:grazel:$versionName"
}
}

plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.google.mobile.services) apply false
alias(libs.plugins.firebase.crashlytics) apply false
id "idea"
id "com.grab.grazel"
}
apply plugin: "com.grab.grazel"

allprojects {
// TODO(arun) Add support for repository in settings.gradle and then remove this
repositories {
google()
mavenCentral()
Expand Down
10 changes: 0 additions & 10 deletions buildsystem/BUILD.bazel

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
load("@grab_bazel_common//rules:defs.bzl", "android_library")

android_library(
name = "sample-android-flavor-flavor1-free-debug",
name = "sample-android-flavor-demo-free-debug",
srcs = glob([
"src/main/java/com/grab/grazel/android/flavor/**/*.kt",
"src/flavor1/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt",
"src/demo/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt",
]),
custom_package = "com.grab.grazel.android.flavor",
enable_compose = True,
Expand All @@ -19,7 +19,9 @@ android_library(
},
},
resources = {
"src/flavor1/res": {
"src/demo/res": {
},
"src/free/res": {
},
"src/main/res": {
},
Expand All @@ -29,7 +31,7 @@ android_library(
],
deps = [
"//:parcelize",
"//flavor-libs/sample-library-flavor1",
"//flavors/sample-library-demo",
"@debug_maven//:androidx_core_core",
"@maven//:androidx_appcompat_appcompat",
"@maven//:androidx_compose_ui_ui",
Expand All @@ -39,10 +41,10 @@ android_library(
)

android_library(
name = "sample-android-flavor-flavor1-paid-debug",
name = "sample-android-flavor-demo-paid-debug",
srcs = glob([
"src/main/java/com/grab/grazel/android/flavor/**/*.kt",
"src/flavor1/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt",
"src/demo/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt",
]),
custom_package = "com.grab.grazel.android.flavor",
enable_compose = True,
Expand All @@ -57,7 +59,7 @@ android_library(
},
},
resources = {
"src/flavor1/res": {
"src/demo/res": {
},
"src/main/res": {
},
Expand All @@ -67,7 +69,7 @@ android_library(
],
deps = [
"//:parcelize",
"//flavor-libs/sample-library-flavor1",
"//flavors/sample-library-demo",
"@debug_maven//:androidx_core_core",
"@maven//:androidx_appcompat_appcompat",
"@maven//:androidx_compose_ui_ui",
Expand All @@ -77,10 +79,10 @@ android_library(
)

android_library(
name = "sample-android-flavor-flavor2-free-debug",
name = "sample-android-flavor-full-free-debug",
srcs = glob([
"src/main/java/com/grab/grazel/android/flavor/**/*.kt",
"src/flavor2/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt",
"src/full/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt",
]),
custom_package = "com.grab.grazel.android.flavor",
enable_compose = True,
Expand All @@ -95,7 +97,9 @@ android_library(
},
},
resources = {
"src/flavor2/res": {
"src/full/res": {
},
"src/free/res": {
},
"src/main/res": {
},
Expand All @@ -105,7 +109,7 @@ android_library(
],
deps = [
"//:parcelize",
"//flavor-libs/sample-library-flavor2",
"//flavors/sample-library-full",
"@debug_maven//:androidx_core_core",
"@maven//:androidx_appcompat_appcompat",
"@maven//:androidx_compose_ui_ui",
Expand All @@ -115,10 +119,10 @@ android_library(
)

android_library(
name = "sample-android-flavor-flavor2-paid-debug",
name = "sample-android-flavor-full-paid-debug",
srcs = glob([
"src/main/java/com/grab/grazel/android/flavor/**/*.kt",
"src/flavor2/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt",
"src/full/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt",
]),
custom_package = "com.grab.grazel.android.flavor",
enable_compose = True,
Expand All @@ -133,7 +137,7 @@ android_library(
},
},
resources = {
"src/flavor2/res": {
"src/full/res": {
},
"src/main/res": {
},
Expand All @@ -143,7 +147,7 @@ android_library(
],
deps = [
"//:parcelize",
"//flavor-libs/sample-library-flavor2",
"//flavors/sample-library-full",
"@debug_maven//:androidx_core_core",
"@maven//:androidx_appcompat_appcompat",
"@maven//:androidx_compose_ui_ui",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "kotlin-kapt"
apply plugin: "kotlin-parcelize"
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.kotlin.parcelize)
}

android {
compileSdkVersion 33
buildToolsVersion "33.0.1"

defaultConfig {
minSdkVersion 21
resValue "string", "generated_value", "generated"
}

flavorDimensions "service", "release"
productFlavors {
flavor1 {
demo {
dimension "service"
}
flavor2 {
full {
dimension "service"
}
free {
Expand Down Expand Up @@ -65,8 +67,8 @@ android {
}

dependencies {
flavor1Implementation project(path: ':flavor-libs:sample-library-flavor1')
flavor2Implementation project(path: ":flavor-libs:sample-library-flavor2")
demoImplementation project(path: ":flavors:sample-library-demo")
fullImplementation project(path: ":flavors:sample-library-full")

implementation libs.androidx.appcompat
implementation libs.androidx.core
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@grab_bazel_common//rules:defs.bzl", "kotlin_library", "kotlin_test")

kotlin_library(
name = "sample-library-flavor1",
name = "sample-library-demo",
srcs = glob([
"src/main/java/com/grab/grazel/android/flavor/ModuleName.kt",
]),
Expand All @@ -14,12 +14,12 @@ kotlin_library(
)

kotlin_test(
name = "sample-library-flavor1-test",
name = "sample-library-demo-test",
srcs = glob([
"src/test/java/com/grab/grazel/flavor1/ModuleNameTest.kt",
]),
associates = [
"//flavor-libs/sample-library-flavor1:sample-library-flavor1",
"//flavors/sample-library-demo:sample-library-demo",
],
visibility = [
"//visibility:public",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: "java-library"
apply plugin: "kotlin"
plugins {
id("kotlin")
}

dependencies {
testImplementation libs.junit
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@grab_bazel_common//rules:defs.bzl", "kotlin_library", "kotlin_test")

kotlin_library(
name = "sample-library-flavor2",
name = "sample-library-full",
srcs = glob([
"src/main/java/com/grab/grazel/android/flavor/ModuleName.kt",
]),
Expand All @@ -14,12 +14,12 @@ kotlin_library(
)

kotlin_test(
name = "sample-library-flavor2-test",
name = "sample-library-full-test",
srcs = glob([
"src/test/java/com/grab/grazel/flavor2/ModuleNameTest.kt",
]),
associates = [
"//flavor-libs/sample-library-flavor2:sample-library-flavor2",
"//flavors/sample-library-full:sample-library-full",
],
visibility = [
"//visibility:public",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

apply plugin: "java-library"
apply plugin: "kotlin"
plugins {
id("kotlin")
}

dependencies {
testImplementation libs.junit
Expand Down
14 changes: 10 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ androidx-monitor = "1.6.1"
androidx-compose = "1.4.3"
activity-compose = "1.7.2"
annotation-jvm = "1.6.0"
crashlytics = "2.9.5"
crashlytics = "2.9.9"
dagger = "2.47"
dokka = "1.4.32"
emoji2 = "1.3.0"
Expand All @@ -38,7 +38,6 @@ sceneform-ux = "1.15.0"
timber = "5.0.1"
auto-service = "1.1.1"
truth = "1.1.3"
jetbrains-kotlin-jvm = "1.8.10"

[libraries]
android-gradle-plugin = { module = "com.android.tools.build:gradle", version.ref = "android-gradle-plugin" }
Expand Down Expand Up @@ -75,9 +74,7 @@ databinding-runtime = { module = "androidx.databinding:databinding-runtime", ver
dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka" }
google-dagger = { module = "com.google.dagger:dagger", version.ref = "dagger" }
google-dagger-compiler = { module = "com.google.dagger:dagger-compiler", version.ref = "dagger" }
google-firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics-gradle", version.ref = "crashlytics" }
google-guava = { module = "com.google.guava:guava", version.ref = "guava" }
google-mobile-services = { module = "com.google.gms:google-services", version.ref = "google-services" }
google-truth = { module = "com.google.truth:truth", version.ref = "truth" }
javapoet = { module = "com.squareup:javapoet", version.ref = "javapoet" }
junit = { module = "junit:junit", version.ref = "junit" }
Expand All @@ -97,6 +94,15 @@ timber = { module = "com.jakewharton.timber:timber", version.ref = "timber" }
auto-service = { module = "com.google.auto.service:auto-service", version.ref = "auto-service" }

[plugins]
android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" }
android-lint = { id = "com.android.lint", version.ref = "android-gradle-plugin" }
google-mobile-services = { id = "com.google.gms.google-services", version.ref = "google-services" }
firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "crashlytics" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
kotlin-dsl = { id = "org.gradle.kotlin.kotlin-dsl", version.ref = "kotlin-dsl" }
gradle-publish = { id = "com.gradle.plugin-publish", version.ref = "gradle-plugin-publish" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit ecbe062

Please sign in to comment.