From 462f2437e071a0e636ed9f198990376d2bfbc6e0 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 14:42:51 +0800 Subject: [PATCH 01/13] Update AGP to 8.14, Upgradle and introduce build-logic plugin --- .gitignore | 3 + .idea/kotlinc.xml | 4 -- WORKSPACE | 12 ++-- build-logic/gradle | 1 + build-logic/gradle.properties | 1 + build-logic/gradlew | 1 + build-logic/gradlew.bat | 1 + build-logic/plugin/build.gradle.kts | 31 ++++++++++ .../com/grab/grazel/build/BuildLogicPlugin.kt | 13 ++++ .../com/grab/grazel/build/android/Android.kt | 56 +++++++++++++++++ .../grazel/build/android/AndroidCommon.kt | 60 +++++++++++++++++++ .../com/grab/grazel/build/gradle/Catalog.kt | 35 +++++++++++ .../com/grab/grazel/build/gradle/Gradle.kt | 34 +++++++++++ .../kotlin/com/grab/grazel/build/jvm/Java.kt | 51 ++++++++++++++++ .../build/properties/LocalProperties.kt | 25 ++++++++ build-logic/settings.gradle.kts | 22 +++++++ build.gradle | 35 +---------- flavors/sample-android-flavor/BUILD.bazel | 16 ++--- flavors/sample-android-flavor/build.gradle | 3 +- .../src/main/AndroidManifest.xml | 3 +- gradle.properties | 8 +-- gradle/libs.versions.toml | 12 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- grazel-gradle-plugin/build.gradle | 31 +--------- keystore/BUILD.bazel | 15 ++--- maven_install.json | 28 +++++---- sample-android-library/BUILD.bazel | 16 ++--- sample-android-library/build.gradle | 5 +- .../src/main/AndroidManifest.xml | 2 +- sample-android/BUILD.bazel | 24 ++++---- sample-android/build.gradle | 10 +--- sample-android/src/debug/AndroidManifest.xml | 3 +- sample-android/src/main/AndroidManifest.xml | 3 +- settings.gradle | 13 ++-- 34 files changed, 424 insertions(+), 155 deletions(-) create mode 120000 build-logic/gradle create mode 120000 build-logic/gradle.properties create mode 120000 build-logic/gradlew create mode 120000 build-logic/gradlew.bat create mode 100644 build-logic/plugin/build.gradle.kts create mode 100644 build-logic/plugin/src/main/kotlin/com/grab/grazel/build/BuildLogicPlugin.kt create mode 100644 build-logic/plugin/src/main/kotlin/com/grab/grazel/build/android/Android.kt create mode 100644 build-logic/plugin/src/main/kotlin/com/grab/grazel/build/android/AndroidCommon.kt create mode 100644 build-logic/plugin/src/main/kotlin/com/grab/grazel/build/gradle/Catalog.kt create mode 100644 build-logic/plugin/src/main/kotlin/com/grab/grazel/build/gradle/Gradle.kt create mode 100644 build-logic/plugin/src/main/kotlin/com/grab/grazel/build/jvm/Java.kt create mode 100644 build-logic/plugin/src/main/kotlin/com/grab/grazel/build/properties/LocalProperties.kt create mode 100644 build-logic/settings.gradle.kts diff --git a/.gitignore b/.gitignore index a26494f4..77f2b29f 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ .idea/google-java-format.xml .idea/shelf .idea/modules/app/ +.idea/deploymentTargetSelector.xml +.idea/other.xml /.idea/git_toolbox_prj.xml /.idea/uiDesigner.xml /.idea/terminal.xml @@ -40,6 +42,7 @@ bin/ gen/ out/ build/ +!**/src/**/build/ /build .ART # Project files diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index ac464705..0fc31131 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,9 +1,5 @@ - - diff --git a/WORKSPACE b/WORKSPACE index f48fbd49..221fa422 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -314,11 +314,11 @@ maven_install( "androidx.core:core:1.10.1", "androidx.cursoradapter:cursoradapter:1.0.0", "androidx.customview:customview:1.0.0", - "androidx.databinding:databinding-adapters:7.2.2", - "androidx.databinding:databinding-common:7.2.2", - "androidx.databinding:databinding-ktx:7.2.2", - "androidx.databinding:databinding-runtime:7.2.2", - "androidx.databinding:viewbinding:7.2.2", + "androidx.databinding:databinding-adapters:8.1.4", + "androidx.databinding:databinding-common:8.1.4", + "androidx.databinding:databinding-ktx:8.1.4", + "androidx.databinding:databinding-runtime:8.1.4", + "androidx.databinding:viewbinding:8.1.4", "androidx.drawerlayout:drawerlayout:1.0.0", "androidx.emoji2:emoji2:1.3.0", "androidx.fragment:fragment:1.3.6", @@ -466,7 +466,7 @@ test_maven_pinned_maven_install() android_sdk_repository( name = "androidsdk", - api_level = 33, + api_level = 34, build_tools_version = "33.0.1", ) diff --git a/build-logic/gradle b/build-logic/gradle new file mode 120000 index 00000000..3337596a --- /dev/null +++ b/build-logic/gradle @@ -0,0 +1 @@ +../gradle \ No newline at end of file diff --git a/build-logic/gradle.properties b/build-logic/gradle.properties new file mode 120000 index 00000000..7677fb73 --- /dev/null +++ b/build-logic/gradle.properties @@ -0,0 +1 @@ +../gradle.properties \ No newline at end of file diff --git a/build-logic/gradlew b/build-logic/gradlew new file mode 120000 index 00000000..502f5a2d --- /dev/null +++ b/build-logic/gradlew @@ -0,0 +1 @@ +../gradlew \ No newline at end of file diff --git a/build-logic/gradlew.bat b/build-logic/gradlew.bat new file mode 120000 index 00000000..28401328 --- /dev/null +++ b/build-logic/gradlew.bat @@ -0,0 +1 @@ +../gradlew.bat \ No newline at end of file diff --git a/build-logic/plugin/build.gradle.kts b/build-logic/plugin/build.gradle.kts new file mode 100644 index 00000000..770b1b29 --- /dev/null +++ b/build-logic/plugin/build.gradle.kts @@ -0,0 +1,31 @@ +plugins { + `java-gradle-plugin` + `kotlin-dsl` + alias(libs.plugins.ksp) // KSP +} + +kotlin { + jvmToolchain(17) + explicitApi() +} + +gradlePlugin { + val build by plugins.creating { + id = "com.grab.grazel.build.common" + implementationClass = "com.grab.grazel.build.BuildLogicPlugin" + } +} + +dependencies { + /* implementation(libs.coroutines) + implementation(libs.coroutines.jvm)*/ + compileOnly(libs.android.gradle.plugin) + compileOnly(libs.kotlin.gradle.plugin) + + testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") +} + +tasks.named("test") { + useJUnitPlatform() +} diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/BuildLogicPlugin.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/BuildLogicPlugin.kt new file mode 100644 index 00000000..0b8e1d35 --- /dev/null +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/BuildLogicPlugin.kt @@ -0,0 +1,13 @@ +/* + * This Kotlin source file was generated by the Gradle 'init' task. + */ +package com.grab.grazel.build + +import com.grab.grazel.build.android.configureAndroid +import com.grab.grazel.build.gradle.ConfigurablePlugin +import com.grab.grazel.build.jvm.configureJvm + +public class BuildLogicPlugin : ConfigurablePlugin({ + configureJvm() + configureAndroid() +}) diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/android/Android.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/android/Android.kt new file mode 100644 index 00000000..ca17eb0f --- /dev/null +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/android/Android.kt @@ -0,0 +1,56 @@ +/* + * Copyright 2024 Grabtaxi Holdings PTE LTD (GRAB) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.grab.grazel.build.android + +import com.android.build.api.variant.AndroidComponentsExtension +import com.android.build.api.variant.ApplicationAndroidComponentsExtension +import com.android.build.api.variant.DynamicFeatureAndroidComponentsExtension +import com.android.build.api.variant.LibraryAndroidComponentsExtension +import com.android.build.api.variant.TestAndroidComponentsExtension +import com.android.build.api.variant.Variant +import com.android.build.api.variant.VariantBuilder +import com.android.build.gradle.BaseExtension +import com.android.build.gradle.LintPlugin +import com.grab.grazel.build.gradle.configureIfExist +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.withType +import com.android.build.gradle.BasePlugin as AndroidBasePlugin + +internal fun Project.android(builder: BaseExtension.() -> Unit) { + configure(builder) +} + +internal fun Project.androidComponents( + builder: AndroidComponentsExtension<*, out VariantBuilder, out Variant>.() -> Unit +) { + configureIfExist(builder) + configureIfExist(builder) + configureIfExist(builder) + configureIfExist(builder) +} + +internal fun Project.configureAndroid() { + require(this == rootProject) { "Should be only called from root project" } + subprojects { + plugins.withType { + if (this !is LintPlugin) { + androidCommon() + } + } + } +} \ No newline at end of file diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/android/AndroidCommon.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/android/AndroidCommon.kt new file mode 100644 index 00000000..47105a9d --- /dev/null +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/android/AndroidCommon.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2024 Grabtaxi Holdings PTE LTD (GRAB) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.grab.grazel.build.android + +import com.grab.grazel.build.gradle.libs +import com.grab.grazel.build.gradle.version +import org.gradle.api.JavaVersion +import org.gradle.api.Project + +internal fun Project.androidCommon() { + android { + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + + defaultConfig { + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + composeOptions { + kotlinCompilerExtensionVersion = libs.version("androidx.compose")!! + } + + packagingOptions { + resources.excludes += listOf( + "META-INF/AL2.0", + "META-INF/LGPL2.1", + "META-INF/licenses/**" + ) + } + + lintOptions { + lintConfig = rootProject.file("lint.xml") + } + } + + androidComponents { + beforeVariants(selector().withBuildType("release")) { + it.enable = false + } + } +} \ No newline at end of file diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/gradle/Catalog.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/gradle/Catalog.kt new file mode 100644 index 00000000..6f743194 --- /dev/null +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/gradle/Catalog.kt @@ -0,0 +1,35 @@ +/* + * Copyright 2024 Grabtaxi Holdings PTE LTD (GRAB) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.grab.grazel.build.gradle + +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalog +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.kotlin.dsl.getByType + + +internal val Project.catalogs get() = extensions.getByType() + +internal val Project.libs: VersionCatalog get() = catalogs.named("libs") + +internal fun VersionCatalog.version(reference: String): String? { + return findVersion(reference).orElse(null)?.toString() +} + +internal fun VersionCatalog.library(reference: String): String? { + return findLibrary(reference).orElse(null)?.toString() +} \ No newline at end of file diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/gradle/Gradle.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/gradle/Gradle.kt new file mode 100644 index 00000000..d90bc9fc --- /dev/null +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/gradle/Gradle.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2024 Grabtaxi Holdings PTE LTD (GRAB) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.grab.grazel.build.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.findByType + +public open class ConfigurablePlugin( + private val configuration: Project.() -> Unit +) : Plugin { + override fun apply(project: Project): Unit = configuration(project) +} + +/** + * Configures a gradle extension if it exists and does nothing otherwise + */ +internal inline fun Project.configureIfExist(builder: T.() -> Unit) { + extensions.findByType()?.apply(builder) +} diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/jvm/Java.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/jvm/Java.kt new file mode 100644 index 00000000..52406f9a --- /dev/null +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/jvm/Java.kt @@ -0,0 +1,51 @@ +/* + * Copyright 2024 Grabtaxi Holdings PTE LTD (GRAB) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.grab.grazel.build.jvm + +import com.grab.grazel.build.gradle.configureIfExist +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.api.tasks.compile.JavaCompile +import org.gradle.jvm.toolchain.JavaLanguageVersion +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin + +internal const val JAVA_VERSION = 17 + +internal fun Project.configureJvm() { + require(this == rootProject) { "Should be only called from root project" } + subprojects { + plugins.withType { + configure { + toolchain { + languageVersion.set(JavaLanguageVersion.of(JAVA_VERSION)) + } + } + } + tasks.withType { + + } + plugins.withType { + configureIfExist { + jvmToolchain(JAVA_VERSION) + } + } + } +} \ No newline at end of file diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/properties/LocalProperties.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/properties/LocalProperties.kt new file mode 100644 index 00000000..cafb7035 --- /dev/null +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/properties/LocalProperties.kt @@ -0,0 +1,25 @@ +package com.grab.grazel.build.properties + +import org.gradle.api.Project +import org.gradle.api.provider.Provider +import java.util.Properties + + +internal const val LOCAL_PROPERTIES = "local.properties" + +public val Project.localProperties: Provider + get() = provider { + rootProject + .file(LOCAL_PROPERTIES) + .inputStream() + .use { stream -> Properties().apply { load(stream) } } + } + +public fun Project.localProperty(key: String): Provider = + localProperties.map { it.getProperty(key) } + +public fun Project.properties(key: String): Provider = providers.gradleProperty(key) +public fun Project.environment(key: String): Provider = providers.environmentVariable(key) + +public fun Project.localOrEnvProperty(key: String): Provider = + localProperty(key).orElse(environment(key)) diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts new file mode 100644 index 00000000..01cee138 --- /dev/null +++ b/build-logic/settings.gradle.kts @@ -0,0 +1,22 @@ +pluginManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } +} + +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} + +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} + +rootProject.name = "build-logic" +include("plugin") diff --git a/build.gradle b/build.gradle index 77a5f286..4fdfc583 100644 --- a/build.gradle +++ b/build.gradle @@ -13,14 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - -import com.android.build.gradle.BaseExtension - buildscript { apply from: "constants.gradle" } plugins { + id "com.grab.grazel.build.common" alias(libs.plugins.android.application) apply false alias(libs.plugins.android.library) apply false alias(libs.plugins.kotlin.android) apply false @@ -48,34 +45,6 @@ allprojects { force "com.google.dagger:dagger-compiler:2.47" } } - - // TODO(arun) Move these to convention plugins - plugins.withType(com.android.build.gradle.BasePlugin).configureEach { plugin -> - (project.extensions.getByName("android") as BaseExtension).with { - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - lint { - lintConfig = rootProject.file("lint.xml") - } - } - } - - tasks.withType(JavaCompile).configureEach { task -> - task.sourceCompatibility = JavaVersion.VERSION_11 - task.targetCompatibility = JavaVersion.VERSION_11 - } - - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask.class).configureEach { - compilerOptions.jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11) - compilerOptions.languageVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_7 - } -} - -tasks.named("wrapper") { - gradleVersion = libs.versions.gradle.wrapper.get() - distributionType = Wrapper.DistributionType.ALL } grazel { @@ -120,7 +89,7 @@ grazel { } } mavenInstall { - httpArchiveRepository { + httpArchiveRepository { sha256 = "d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac" stripPrefix = "rules_jvm_external-5.3" url = String.format("https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz", "5.3", "5.3") diff --git a/flavors/sample-android-flavor/BUILD.bazel b/flavors/sample-android-flavor/BUILD.bazel index 99b1027a..3c7ea17b 100644 --- a/flavors/sample-android-flavor/BUILD.bazel +++ b/flavors/sample-android-flavor/BUILD.bazel @@ -6,7 +6,7 @@ android_library( "src/main/java/com/grab/grazel/android/flavor/**/*.kt", "src/demo/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt", ]), - custom_package = "com.grab.grazel.android.flavor", + custom_package = "", enable_compose = True, enable_data_binding = True, lint_options = { @@ -16,7 +16,7 @@ android_library( manifest = "src/main/AndroidManifest.xml", res_values = { "strings": { - "generated_value": "generated", + "string/generated_value": "generated", }, }, resources = { @@ -47,7 +47,7 @@ android_library( "src/main/java/com/grab/grazel/android/flavor/**/*.kt", "src/demo/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt", ]), - custom_package = "com.grab.grazel.android.flavor", + custom_package = "", enable_compose = True, enable_data_binding = True, lint_options = { @@ -57,7 +57,7 @@ android_library( manifest = "src/main/AndroidManifest.xml", res_values = { "strings": { - "generated_value": "generated", + "string/generated_value": "generated", }, }, resources = { @@ -86,7 +86,7 @@ android_library( "src/main/java/com/grab/grazel/android/flavor/**/*.kt", "src/full/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt", ]), - custom_package = "com.grab.grazel.android.flavor", + custom_package = "", enable_compose = True, enable_data_binding = True, lint_options = { @@ -96,7 +96,7 @@ android_library( manifest = "src/main/AndroidManifest.xml", res_values = { "strings": { - "generated_value": "generated", + "string/generated_value": "generated", }, }, resources = { @@ -127,7 +127,7 @@ android_library( "src/main/java/com/grab/grazel/android/flavor/**/*.kt", "src/full/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt", ]), - custom_package = "com.grab.grazel.android.flavor", + custom_package = "", enable_compose = True, enable_data_binding = True, lint_options = { @@ -137,7 +137,7 @@ android_library( manifest = "src/main/AndroidManifest.xml", res_values = { "strings": { - "generated_value": "generated", + "string/generated_value": "generated", }, }, resources = { diff --git a/flavors/sample-android-flavor/build.gradle b/flavors/sample-android-flavor/build.gradle index 40e95048..6e8f5433 100644 --- a/flavors/sample-android-flavor/build.gradle +++ b/flavors/sample-android-flavor/build.gradle @@ -21,11 +21,9 @@ plugins { } android { - compileSdkVersion 33 buildToolsVersion "33.0.1" defaultConfig { - minSdkVersion 21 resValue "string", "generated_value", "generated" } @@ -64,6 +62,7 @@ android { ] } } + namespace 'com.grab.grazel.android.flavor' } dependencies { diff --git a/flavors/sample-android-flavor/src/main/AndroidManifest.xml b/flavors/sample-android-flavor/src/main/AndroidManifest.xml index 28eef41f..26b49807 100644 --- a/flavors/sample-android-flavor/src/main/AndroidManifest.xml +++ b/flavors/sample-android-flavor/src/main/AndroidManifest.xml @@ -14,8 +14,7 @@ ~ limitations under the License. --> - + - \ No newline at end of file + \ No newline at end of file diff --git a/sample-android/BUILD.bazel b/sample-android/BUILD.bazel index 417730d9..70481d49 100644 --- a/sample-android/BUILD.bazel +++ b/sample-android/BUILD.bazel @@ -56,9 +56,9 @@ android_binary( multidex = "native", res_values = { "strings": { - "generated_value": "This string was generated with resValue", - "type": "debug", - "flavor": "free", + "string/generated_value": "This string was generated with resValue", + "string/type": "debug", + "string/flavor": "free", }, }, resource_configuration_filters = [ @@ -166,9 +166,9 @@ android_binary( multidex = "native", res_values = { "strings": { - "generated_value": "This string was generated with resValue", - "type": "debug", - "flavor": "paid", + "string/generated_value": "This string was generated with resValue", + "string/type": "debug", + "string/flavor": "paid", }, }, resource_configuration_filters = [ @@ -276,9 +276,9 @@ android_binary( multidex = "native", res_values = { "strings": { - "generated_value": "This string was generated with resValue", - "type": "debug", - "flavor": "free", + "string/generated_value": "This string was generated with resValue", + "string/type": "debug", + "string/flavor": "free", }, }, resource_configuration_filters = [ @@ -386,9 +386,9 @@ android_binary( multidex = "native", res_values = { "strings": { - "generated_value": "This string was generated with resValue", - "type": "debug", - "flavor": "paid", + "string/generated_value": "This string was generated with resValue", + "string/type": "debug", + "string/flavor": "paid", }, }, resource_configuration_filters = [ diff --git a/sample-android/build.gradle b/sample-android/build.gradle index 2252cec1..21aa8eb6 100644 --- a/sample-android/build.gradle +++ b/sample-android/build.gradle @@ -25,12 +25,10 @@ plugins { } android { - compileSdkVersion 33 buildToolsVersion "33.0.1" defaultConfig { applicationId "com.grab.grazel.android.sample" - minSdkVersion 21 targetSdkVersion 31 versionCode 1 versionName "1.0" @@ -115,13 +113,6 @@ android { variant.buildConfigFields.put("VARIANT_NAME", new BuildConfigField("String", "\"$variant.name\"", null)) } } - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - kotlinOptions { - jvmTarget = "11" - } packagingOptions { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" @@ -136,6 +127,7 @@ android { lint { baseline = file("lint_baseline.xml") } + namespace 'com.grab.grazel.android.sample' } dependencies { diff --git a/sample-android/src/debug/AndroidManifest.xml b/sample-android/src/debug/AndroidManifest.xml index 1963e17e..001762d3 100644 --- a/sample-android/src/debug/AndroidManifest.xml +++ b/sample-android/src/debug/AndroidManifest.xml @@ -14,8 +14,7 @@ ~ limitations under the License. --> - + - + Date: Thu, 4 Jul 2024 14:56:32 +0800 Subject: [PATCH 02/13] Update build scripts for grazel plugin --- grazel-gradle-plugin/build.gradle | 7 +---- grazel-gradle-plugin/settings.gradle | 26 +++++++++++++------ .../com/grab/grazel/fake/FakeProject.kt | 6 ++++- .../grab/grazel/fake/FakeWorkerExecutor.kt | 11 +------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/grazel-gradle-plugin/build.gradle b/grazel-gradle-plugin/build.gradle index 0fc36e19..6c9870f1 100644 --- a/grazel-gradle-plugin/build.gradle +++ b/grazel-gradle-plugin/build.gradle @@ -27,10 +27,10 @@ plugins { alias(libs.plugins.dokka.gradle.plugin) alias(libs.plugins.gradle.publish) alias(libs.plugins.kotlin.serialization) + alias(libs.plugins.kotlin.kapt) id "maven-publish" id "idea" } -apply plugin: "kotlin-kapt" apply from: "gradle-scripts/functional-test.gradle" apply from: "gradle/publish-root-config.gradle" apply from: "gradle/publishing.gradle" @@ -39,11 +39,6 @@ group = groupId version = versionName description = "A Gradle plugin to automate Bazel migration for Android projects" -repositories { - google() - mavenCentral() -} - idea { module { sourceDirs -= file("src/functionalTest/kotlin") diff --git a/grazel-gradle-plugin/settings.gradle b/grazel-gradle-plugin/settings.gradle index bb011ef4..5d878210 100644 --- a/grazel-gradle-plugin/settings.gradle +++ b/grazel-gradle-plugin/settings.gradle @@ -13,14 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +pluginManagement { + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -/* - * This file was generated by the Gradle "init" task. - * - * The settings file is used to specify which projects to include in your build. - * - * Detailed information about configuring a multi-project build in Gradle can be found - * in the user manual at https://docs.gradle.org/6.4.1/userguide/multi_project_builds.html - */ +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} rootProject.name = "grazel-gradle-plugin" diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/fake/FakeProject.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/fake/FakeProject.kt index b882c67c..2ece4356 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/fake/FakeProject.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/fake/FakeProject.kt @@ -316,7 +316,7 @@ class FakeProject(private val name: String) : Project { TODO("Not yet implemented") } - override fun provider(value: Callable): Provider { + override fun provider(value: Callable): Provider { TODO("Not yet implemented") } @@ -579,6 +579,10 @@ class FakeProject(private val name: String) : Project { TODO("Not yet implemented") } + override fun components(configuration: Action) { + TODO("Not yet implemented") + } + override fun getNormalization(): InputNormalizationHandler { TODO("Not yet implemented") } diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/fake/FakeWorkerExecutor.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/fake/FakeWorkerExecutor.kt index 59b9d246..08bb962c 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/fake/FakeWorkerExecutor.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/fake/FakeWorkerExecutor.kt @@ -6,21 +6,12 @@ import org.gradle.workers.ProcessWorkerSpec import org.gradle.workers.WorkAction import org.gradle.workers.WorkParameters import org.gradle.workers.WorkQueue -import org.gradle.workers.WorkerConfiguration import org.gradle.workers.WorkerExecutor import org.gradle.workers.WorkerSpec -class FakeWorkerExecutor( -) : WorkerExecutor { +class FakeWorkerExecutor : WorkerExecutor { val workQueue = FakeWorkQueue() - override fun submit( - actionClass: Class?, - configAction: Action? - ) { - // no-op - } - override fun noIsolation() = workQueue override fun noIsolation(action: Action?) = workQueue From 37db7e33774974952c0e6d32a92ba9c19b2bebe8 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 15:09:43 +0800 Subject: [PATCH 03/13] Make grazel plugin use the root build logic --- .../plugin/src/main/kotlin/com/grab/grazel/build/jvm/Java.kt | 4 ---- grazel-gradle-plugin/build.gradle | 1 + grazel-gradle-plugin/settings.gradle | 3 +++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/jvm/Java.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/jvm/Java.kt index 52406f9a..d77a5968 100644 --- a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/jvm/Java.kt +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/jvm/Java.kt @@ -20,7 +20,6 @@ import com.grab.grazel.build.gradle.configureIfExist import org.gradle.api.Project import org.gradle.api.plugins.JavaPlugin import org.gradle.api.plugins.JavaPluginExtension -import org.gradle.api.tasks.compile.JavaCompile import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.withType @@ -38,9 +37,6 @@ internal fun Project.configureJvm() { languageVersion.set(JavaLanguageVersion.of(JAVA_VERSION)) } } - } - tasks.withType { - } plugins.withType { configureIfExist { diff --git a/grazel-gradle-plugin/build.gradle b/grazel-gradle-plugin/build.gradle index 6c9870f1..13e364e9 100644 --- a/grazel-gradle-plugin/build.gradle +++ b/grazel-gradle-plugin/build.gradle @@ -23,6 +23,7 @@ buildscript { plugins { id "java-gradle-plugin" + id "com.grab.grazel.build.common" alias(libs.plugins.kotlin.dsl) alias(libs.plugins.dokka.gradle.plugin) alias(libs.plugins.gradle.publish) diff --git a/grazel-gradle-plugin/settings.gradle b/grazel-gradle-plugin/settings.gradle index 5d878210..d7c7f929 100644 --- a/grazel-gradle-plugin/settings.gradle +++ b/grazel-gradle-plugin/settings.gradle @@ -19,6 +19,9 @@ pluginManagement { mavenCentral() gradlePluginPortal() } + includeBuild("../build-logic") { + setName("grazel-build-logic") + } } plugins { From f8a592a131d7f571258c8418720b1d79642aa622 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 15:24:30 +0800 Subject: [PATCH 04/13] Support `namespace` and fix version calculation in res value Signed-off-by: arunkumar9t2 --- flavors/sample-android-flavor/BUILD.bazel | 16 +++++----- .../migrate/android/AndroidManifestParser.kt | 3 +- .../grazel/migrate/android/ResValuesData.kt | 8 ++--- maven_install.json | 32 +++++++++---------- sample-android-library/BUILD.bazel | 16 +++++----- sample-android/BUILD.bazel | 24 +++++++------- 6 files changed, 50 insertions(+), 49 deletions(-) diff --git a/flavors/sample-android-flavor/BUILD.bazel b/flavors/sample-android-flavor/BUILD.bazel index 3c7ea17b..99b1027a 100644 --- a/flavors/sample-android-flavor/BUILD.bazel +++ b/flavors/sample-android-flavor/BUILD.bazel @@ -6,7 +6,7 @@ android_library( "src/main/java/com/grab/grazel/android/flavor/**/*.kt", "src/demo/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt", ]), - custom_package = "", + custom_package = "com.grab.grazel.android.flavor", enable_compose = True, enable_data_binding = True, lint_options = { @@ -16,7 +16,7 @@ android_library( manifest = "src/main/AndroidManifest.xml", res_values = { "strings": { - "string/generated_value": "generated", + "generated_value": "generated", }, }, resources = { @@ -47,7 +47,7 @@ android_library( "src/main/java/com/grab/grazel/android/flavor/**/*.kt", "src/demo/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt", ]), - custom_package = "", + custom_package = "com.grab.grazel.android.flavor", enable_compose = True, enable_data_binding = True, lint_options = { @@ -57,7 +57,7 @@ android_library( manifest = "src/main/AndroidManifest.xml", res_values = { "strings": { - "string/generated_value": "generated", + "generated_value": "generated", }, }, resources = { @@ -86,7 +86,7 @@ android_library( "src/main/java/com/grab/grazel/android/flavor/**/*.kt", "src/full/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt", ]), - custom_package = "", + custom_package = "com.grab.grazel.android.flavor", enable_compose = True, enable_data_binding = True, lint_options = { @@ -96,7 +96,7 @@ android_library( manifest = "src/main/AndroidManifest.xml", res_values = { "strings": { - "string/generated_value": "generated", + "generated_value": "generated", }, }, resources = { @@ -127,7 +127,7 @@ android_library( "src/main/java/com/grab/grazel/android/flavor/**/*.kt", "src/full/java/com/grab/grazel/android/flavor/HelloFlavorMessage.kt", ]), - custom_package = "", + custom_package = "com.grab.grazel.android.flavor", enable_compose = True, enable_data_binding = True, lint_options = { @@ -137,7 +137,7 @@ android_library( manifest = "src/main/AndroidManifest.xml", res_values = { "strings": { - "string/generated_value": "generated", + "generated_value": "generated", }, }, resources = { diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidManifestParser.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidManifestParser.kt index e614ec37..f4922b6b 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidManifestParser.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/AndroidManifestParser.kt @@ -43,12 +43,13 @@ internal class DefaultAndroidManifestParser @Inject constructor() : AndroidManif extension: BaseExtension, androidSourceSets: List ): String? { - val packageName = extension.defaultConfig.applicationId // TODO(arun) Handle suffixes + val packageName = extension.defaultConfig.applicationId ?: extension.namespace return if (packageName == null) { // Try parsing from AndroidManifest.xml val manifestFile = androidManifestFile(androidSourceSets) ?: return null XmlSlurper().parse(manifestFile) .list() + .asSequence() .filterIsInstance() .firstOrNull { it.name() == "manifest" } ?.attributes()?.get("package")?.toString() diff --git a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/ResValuesData.kt b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/ResValuesData.kt index ea24fd83..b6e405b5 100644 --- a/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/ResValuesData.kt +++ b/grazel-gradle-plugin/src/main/kotlin/com/grab/grazel/migrate/android/ResValuesData.kt @@ -20,6 +20,7 @@ import com.android.build.gradle.BaseExtension import com.android.builder.model.Version.ANDROID_GRADLE_PLUGIN_VERSION import com.grab.grazel.gradle.variant.MatchedVariant import com.grab.grazel.util.merge +import org.gradle.util.internal.VersionNumber data class ResValuesData( val stringValues: Map = emptyMap() @@ -60,10 +61,9 @@ internal fun BaseExtension.extractResValue( * output: generated_value */ private fun getKeyValue(key: String): String { - val agpVersion = ANDROID_GRADLE_PLUGIN_VERSION.split(".") - val majorVersion = agpVersion[0].toInt() - val minorVersion = agpVersion[1].toInt() - return if (majorVersion >= 7 && minorVersion >= 2) { + val agpVersion = VersionNumber.parse(ANDROID_GRADLE_PLUGIN_VERSION) + val baseAgpVersion = VersionNumber.parse("7.2.2") + return if (agpVersion >= baseAgpVersion) { key.split("/").last() } else { key diff --git a/maven_install.json b/maven_install.json index d5540863..3dd527af 100755 --- a/maven_install.json +++ b/maven_install.json @@ -1,13 +1,13 @@ { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", - "__INPUT_ARTIFACTS_HASH": -963884179, - "__RESOLVED_ARTIFACTS_HASH": -1204912076, + "__INPUT_ARTIFACTS_HASH": -963884179, + "__RESOLVED_ARTIFACTS_HASH": -1204912076, "conflict_resolution": { "androidx.annotation:annotation:1.5.0": "androidx.annotation:annotation:1.6.0", - "androidx.databinding:databinding-adapters:7.2.2": "androidx.databinding:databinding-adapters:8.1.4", - "androidx.databinding:databinding-common:7.2.2": "androidx.databinding:databinding-common:8.1.4", - "androidx.databinding:databinding-runtime:7.2.2": "androidx.databinding:databinding-runtime:8.1.4", - "androidx.databinding:viewbinding:7.2.2": "androidx.databinding:viewbinding:8.1.4", + "androidx.databinding:databinding-adapters:7.2.2": "androidx.databinding:databinding-adapters:8.1.4", + "androidx.databinding:databinding-common:7.2.2": "androidx.databinding:databinding-common:8.1.4", + "androidx.databinding:databinding-runtime:7.2.2": "androidx.databinding:databinding-runtime:8.1.4", + "androidx.databinding:viewbinding:7.2.2": "androidx.databinding:viewbinding:8.1.4", "org.jetbrains.kotlin:kotlin-reflect:1.8.10": "org.jetbrains.kotlin:kotlin-reflect:1.9.20" }, "artifacts": { @@ -283,33 +283,33 @@ }, "androidx.databinding:databinding-adapters:aar": { "shasums": { - "jar": "7909833618f8628b5afadc764949a5e764906320864730bec124392337585f8e" + "jar": "7909833618f8628b5afadc764949a5e764906320864730bec124392337585f8e" }, - "version": "8.1.4" + "version": "8.1.4" }, "androidx.databinding:databinding-common": { "shasums": { - "jar": "66cab82639dac0f6c2433464c093b074d608c4bb887ec38a9b8bc4ac98126732" + "jar": "66cab82639dac0f6c2433464c093b074d608c4bb887ec38a9b8bc4ac98126732" }, - "version": "8.1.4" + "version": "8.1.4" }, "androidx.databinding:databinding-ktx:aar": { "shasums": { - "jar": "f209c99c1796df3015719600a6cc781bf4095578d1564d949cac2df8d90262cb" + "jar": "f209c99c1796df3015719600a6cc781bf4095578d1564d949cac2df8d90262cb" }, - "version": "8.1.4" + "version": "8.1.4" }, "androidx.databinding:databinding-runtime:aar": { "shasums": { - "jar": "dd2d8598912be8a4fd250f7b302c8341a0eaec389dcc000a8744a0ac5ae83a32" + "jar": "dd2d8598912be8a4fd250f7b302c8341a0eaec389dcc000a8744a0ac5ae83a32" }, - "version": "8.1.4" + "version": "8.1.4" }, "androidx.databinding:viewbinding:aar": { "shasums": { - "jar": "e71da76a17b18be4fc00c539644a46f8e4610764ca94868ee10d3be736f0cc68" + "jar": "e71da76a17b18be4fc00c539644a46f8e4610764ca94868ee10d3be736f0cc68" }, - "version": "8.1.4" + "version": "8.1.4" }, "androidx.drawerlayout:drawerlayout:aar": { "shasums": { diff --git a/sample-android-library/BUILD.bazel b/sample-android-library/BUILD.bazel index ee0296ab..9c04c012 100644 --- a/sample-android-library/BUILD.bazel +++ b/sample-android-library/BUILD.bazel @@ -5,7 +5,7 @@ android_library( srcs = glob([ "src/main/java/com/grab/grazel/android/sample/SampleViewModel.kt", ]), - custom_package = "", + custom_package = "com.grab.grazel.android.sample.lib", enable_data_binding = True, lint_options = { "enabled": True, @@ -25,7 +25,7 @@ android_library( srcs = glob([ "src/main/java/com/grab/grazel/android/sample/SampleViewModel.kt", ]), - custom_package = "", + custom_package = "com.grab.grazel.android.sample.lib", enable_data_binding = True, lint_options = { "enabled": True, @@ -45,7 +45,7 @@ android_library( srcs = glob([ "src/main/java/com/grab/grazel/android/sample/SampleViewModel.kt", ]), - custom_package = "", + custom_package = "com.grab.grazel.android.sample.lib", enable_data_binding = True, lint_options = { "enabled": True, @@ -65,7 +65,7 @@ android_library( srcs = glob([ "src/main/java/com/grab/grazel/android/sample/SampleViewModel.kt", ]), - custom_package = "", + custom_package = "com.grab.grazel.android.sample.lib", enable_data_binding = True, lint_options = { "enabled": True, @@ -88,7 +88,7 @@ android_unit_test( associates = [ "//sample-android-library:sample-android-library-demo-free-debug_kt", ], - custom_package = "", + custom_package = "com.grab.grazel.android.sample.lib", resources = glob([ "src/test/resources/**", ]), @@ -110,7 +110,7 @@ android_unit_test( associates = [ "//sample-android-library:sample-android-library-demo-paid-debug_kt", ], - custom_package = "", + custom_package = "com.grab.grazel.android.sample.lib", resources = glob([ "src/test/resources/**", ]), @@ -132,7 +132,7 @@ android_unit_test( associates = [ "//sample-android-library:sample-android-library-full-free-debug_kt", ], - custom_package = "", + custom_package = "com.grab.grazel.android.sample.lib", resources = glob([ "src/test/resources/**", ]), @@ -154,7 +154,7 @@ android_unit_test( associates = [ "//sample-android-library:sample-android-library-full-paid-debug_kt", ], - custom_package = "", + custom_package = "com.grab.grazel.android.sample.lib", resources = glob([ "src/test/resources/**", ]), diff --git a/sample-android/BUILD.bazel b/sample-android/BUILD.bazel index 70481d49..417730d9 100644 --- a/sample-android/BUILD.bazel +++ b/sample-android/BUILD.bazel @@ -56,9 +56,9 @@ android_binary( multidex = "native", res_values = { "strings": { - "string/generated_value": "This string was generated with resValue", - "string/type": "debug", - "string/flavor": "free", + "generated_value": "This string was generated with resValue", + "type": "debug", + "flavor": "free", }, }, resource_configuration_filters = [ @@ -166,9 +166,9 @@ android_binary( multidex = "native", res_values = { "strings": { - "string/generated_value": "This string was generated with resValue", - "string/type": "debug", - "string/flavor": "paid", + "generated_value": "This string was generated with resValue", + "type": "debug", + "flavor": "paid", }, }, resource_configuration_filters = [ @@ -276,9 +276,9 @@ android_binary( multidex = "native", res_values = { "strings": { - "string/generated_value": "This string was generated with resValue", - "string/type": "debug", - "string/flavor": "free", + "generated_value": "This string was generated with resValue", + "type": "debug", + "flavor": "free", }, }, resource_configuration_filters = [ @@ -386,9 +386,9 @@ android_binary( multidex = "native", res_values = { "strings": { - "string/generated_value": "This string was generated with resValue", - "string/type": "debug", - "string/flavor": "paid", + "generated_value": "This string was generated with resValue", + "type": "debug", + "flavor": "paid", }, }, resource_configuration_filters = [ From 5195ae378d3d51061b84fc819d2dbc213bd71a62 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 15:42:55 +0800 Subject: [PATCH 05/13] Add manifest package names --- flavors/sample-android-flavor/src/main/AndroidManifest.xml | 5 +++-- sample-android-library/src/main/AndroidManifest.xml | 2 +- sample-android/src/debug/AndroidManifest.xml | 3 ++- sample-android/src/main/AndroidManifest.xml | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/flavors/sample-android-flavor/src/main/AndroidManifest.xml b/flavors/sample-android-flavor/src/main/AndroidManifest.xml index 26b49807..94079b26 100644 --- a/flavors/sample-android-flavor/src/main/AndroidManifest.xml +++ b/flavors/sample-android-flavor/src/main/AndroidManifest.xml @@ -14,11 +14,12 @@ ~ limitations under the License. --> - + + android:exported="true" /> \ No newline at end of file diff --git a/sample-android-library/src/main/AndroidManifest.xml b/sample-android-library/src/main/AndroidManifest.xml index b6b50d63..064b1777 100644 --- a/sample-android-library/src/main/AndroidManifest.xml +++ b/sample-android-library/src/main/AndroidManifest.xml @@ -14,4 +14,4 @@ ~ limitations under the License. --> - \ No newline at end of file + \ No newline at end of file diff --git a/sample-android/src/debug/AndroidManifest.xml b/sample-android/src/debug/AndroidManifest.xml index 001762d3..1963e17e 100644 --- a/sample-android/src/debug/AndroidManifest.xml +++ b/sample-android/src/debug/AndroidManifest.xml @@ -14,7 +14,8 @@ ~ limitations under the License. --> - + - + Date: Thu, 4 Jul 2024 15:44:15 +0800 Subject: [PATCH 06/13] Format gradle files --- README.md | 2 +- flavors/sample-android-flavor/build.gradle | 2 +- sample-android-library/build.gradle | 2 +- sample-android/build.gradle | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 21ae64db..af6dcc7d 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ dependencies { } ``` -Grazel's `migrateToBazel` task generates the following build script: +Grazel"s `migrateToBazel` task generates the following build script: ```python load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") diff --git a/flavors/sample-android-flavor/build.gradle b/flavors/sample-android-flavor/build.gradle index 6e8f5433..8e68a417 100644 --- a/flavors/sample-android-flavor/build.gradle +++ b/flavors/sample-android-flavor/build.gradle @@ -62,7 +62,7 @@ android { ] } } - namespace 'com.grab.grazel.android.flavor' + namespace "com.grab.grazel.android.flavor" } dependencies { diff --git a/sample-android-library/build.gradle b/sample-android-library/build.gradle index 4514b4c4..ae35fbcb 100644 --- a/sample-android-library/build.gradle +++ b/sample-android-library/build.gradle @@ -25,7 +25,7 @@ android { buildFeatures { viewBinding true } - namespace 'com.grab.grazel.android.sample.lib' + namespace "com.grab.grazel.android.sample.lib" } dependencies { diff --git a/sample-android/build.gradle b/sample-android/build.gradle index 21aa8eb6..592845d6 100644 --- a/sample-android/build.gradle +++ b/sample-android/build.gradle @@ -127,7 +127,7 @@ android { lint { baseline = file("lint_baseline.xml") } - namespace 'com.grab.grazel.android.sample' + namespace "com.grab.grazel.android.sample" } dependencies { From 0d32135212b42027e13dc14b4f5c3cbc99de0aee Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 15:56:38 +0800 Subject: [PATCH 07/13] Update Bazel to use Java 17 --- .bazel/.default.bazelrc | 9 ++++++--- BUILD.bazel | 2 +- build.gradle | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.bazel/.default.bazelrc b/.bazel/.default.bazelrc index f4b5aee8..ace5e06f 100644 --- a/.bazel/.default.bazelrc +++ b/.bazel/.default.bazelrc @@ -28,9 +28,12 @@ common --experimental_worker_for_repo_fetching=platform # JAVA - START common --experimental_strict_java_deps=off # Turn off strict java deps -common --java_runtime_version=remotejdk_11 # Use inbuilt Java 11 for hermeticity -common --tool_java_runtime_version=remotejdk_11 -common --jvmopt="-Djava.locale.providers=COMPAT,SPI" # Use Java 8 default locale provider +common --java_runtime_version=remotejdk_17 # Use inbuilt Java 17 for hermeticity +common --tool_java_runtime_version=remotejdk_17 +common --tool_java_language_version=17 +common --java_language_version=17 +## See https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Locale.html#legacy_language_codes +build --jvmopt="-Djava.locale.providers=COMPAT,SPI -Djava.locale.useOldISOCodes=true" # Use Java 8 default locale provider common --experimental_java_classpath=bazel common --experimental_java_header_input_pruning # JAVA - END diff --git a/BUILD.bazel b/BUILD.bazel index ce9fc0c2..1ea03605 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -19,7 +19,7 @@ define_kt_toolchain( experimental_strict_kotlin_deps = "off", experimental_use_abi_jars = True, javac_options = "//:kt_javac_options", - jvm_target = "11", + jvm_target = "17", kotlinc_options = "//:kt_kotlinc_options", language_version = "1.7", ) diff --git a/build.gradle b/build.gradle index 4fdfc583..51af8663 100644 --- a/build.gradle +++ b/build.gradle @@ -135,7 +135,7 @@ grazel { abiJars = true multiplexWorkers = true languageVersion = "1.7" - jvmTarget = "11" + jvmTarget = "17" } } dagger { From 29b5eb51c7e0d5dbe487872ed392112273916c27 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 15:59:43 +0800 Subject: [PATCH 08/13] Update Bazel to use Java 17 --- .github/actions/bazel/action.yml | 4 ++-- .github/workflows/ci.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/bazel/action.yml b/.github/actions/bazel/action.yml index 20953cab..66cbe559 100644 --- a/.github/actions/bazel/action.yml +++ b/.github/actions/bazel/action.yml @@ -12,11 +12,11 @@ runs: steps: - name: Setup Bazelisk uses: bazelbuild/setup-bazelisk@v2 - - name: Install JDK 11 + - name: Install JDK 17 uses: actions/setup-java@v3 with: distribution: "zulu" - java-version: "11" + java-version: "17" - name: Mount bazel cache uses: actions/cache@v3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 753247ac..0dd9a717 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,11 +15,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Install JDK 11 + - name: Install JDK 17 uses: actions/setup-java@v2 with: distribution: "zulu" - java-version: "11" + java-version: "17" - name: Lint run: | find "$(pwd -P)" -type f \ @@ -107,11 +107,11 @@ jobs: - uses: actions/checkout@v3 - name: Setup Bazelisk uses: bazelbuild/setup-bazelisk@v2 - - name: Install JDK 11 + - name: Install JDK 17 uses: actions/setup-java@v3 with: distribution: "zulu" - java-version: "11" + java-version: "17" - uses: burrunan/gradle-cache-action@v1.12 name: migrate-to-bazel-validation with: From 99baaf944f406390b700c4568ff3e8f84a4b08fa Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 16:05:51 +0800 Subject: [PATCH 09/13] Ensure gradle jobs on CI use Java 17 --- .github/workflows/ci.yml | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0dd9a717..e3504608 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,9 +14,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install JDK 17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: "zulu" java-version: "17" @@ -29,7 +29,7 @@ jobs: bazel-build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Bazel build uses: ./.github/actions/bazel with: @@ -38,7 +38,7 @@ jobs: bazel-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Query targets run: | bazelisk query 'kind(kt_jvm_test, ...)' --output label > /tmp/targets @@ -51,7 +51,7 @@ jobs: bazel-android-lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Bazel Android Lint uses: ./.github/actions/bazel with: @@ -61,7 +61,12 @@ jobs: grazel-build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Install JDK 17 + uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: "17" - uses: burrunan/gradle-cache-action@v1.12 name: grazel-build with: @@ -75,7 +80,12 @@ jobs: grazel-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Install JDK 17 + uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: "17" - uses: burrunan/gradle-cache-action@v1.12 name: grazel-test with: @@ -89,7 +99,12 @@ jobs: grazel-gradle-plugin-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - name: Install JDK 17 + uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: "17" - uses: burrunan/gradle-cache-action@v1.12 name: grazel-gradle-plugin-test with: @@ -104,7 +119,7 @@ jobs: migrate-to-bazel-validation: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup Bazelisk uses: bazelbuild/setup-bazelisk@v2 - name: Install JDK 17 From 61efb5863835a9f2808e54e3727d96655fcdc2f3 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 16:07:22 +0800 Subject: [PATCH 10/13] Format keystore file --- keystore/BUILD.bazel | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/keystore/BUILD.bazel b/keystore/BUILD.bazel index a44148b1..bb11ee34 100644 --- a/keystore/BUILD.bazel +++ b/keystore/BUILD.bazel @@ -1,10 +1,9 @@ filegroup( - name = "debug-keystore", - srcs = [ - "debug.keystore", - ], - visibility = [ - "//visibility:public", - ] + name = "debug-keystore", + srcs = [ + "debug.keystore", + ], + visibility = [ + "//visibility:public", + ], ) - From eb4721a1118f9177d414b52b4149529872dfb1ff Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 16:10:59 +0800 Subject: [PATCH 11/13] Setup action concurrency --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3504608..02b65d9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,6 +6,10 @@ on: - master pull_request: +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + env: TERM: dumb From 7487a790c84b079caa92dd6ea725f1577df3f9a5 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 18:15:04 +0800 Subject: [PATCH 12/13] Fix tests failing due to missing namespace --- .../grab/grazel/gradle/DefaultDependenciesDataSourceTest.kt | 1 + .../gradle/dependencies/ResolvedComponentsVisitorTest.kt | 1 + .../grab/grazel/gradle/variant/DefaultVariantMatcherTest.kt | 3 +++ .../test/kotlin/com/grab/grazel/gradle/variant/VariantTest.kt | 4 ++-- .../com/grab/grazel/gradle/variant/VariantTestProject.kt | 1 + .../grab/grazel/migrate/AndroidWorkspaceRepositoriesTest.kt | 1 + .../kotlin/com/grab/grazel/migrate/BuildConfigFieldsTest.kt | 3 ++- .../kotlin/com/grab/grazel/migrate/DaggerWorkspaceRuleTest.kt | 1 + .../android/AndroidInstrumentationBinaryDataExtractorTest.kt | 1 + .../grab/grazel/migrate/android/AndroidLibraryDataKtTest.kt | 3 +++ .../migrate/android/DefaultAndroidLibraryDataExtractorTest.kt | 2 ++ .../android/DefaultAndroidUnitTestDataExtractorTest.kt | 1 + .../migrate/android/DefaultManifestValuesBuilderTest.kt | 2 ++ .../grazel/migrate/dependencies/DefaultArtifactPinnerTest.kt | 1 + 14 files changed, 22 insertions(+), 3 deletions(-) diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/DefaultDependenciesDataSourceTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/DefaultDependenciesDataSourceTest.kt index ead9b7f6..d80391d6 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/DefaultDependenciesDataSourceTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/DefaultDependenciesDataSourceTest.kt @@ -72,6 +72,7 @@ class DefaultDependenciesDataSourceTest { mavenCentral() } configure { + namespace = "test" compileSdkVersion(30) } configureProject(this) diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/dependencies/ResolvedComponentsVisitorTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/dependencies/ResolvedComponentsVisitorTest.kt index 9a449110..c3823be2 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/dependencies/ResolvedComponentsVisitorTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/dependencies/ResolvedComponentsVisitorTest.kt @@ -67,6 +67,7 @@ class ResolvedComponentsVisitorTest { mavenCentral() } configure { + namespace = "test" compileSdkVersion(30) } dependencies { diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/DefaultVariantMatcherTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/DefaultVariantMatcherTest.kt index 67d3719d..1379ef02 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/DefaultVariantMatcherTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/DefaultVariantMatcherTest.kt @@ -28,6 +28,7 @@ import com.grab.grazel.util.addGrazelExtension import com.grab.grazel.util.assertErrorMessage import com.grab.grazel.util.createGrazelComponent import com.grab.grazel.util.doEvaluate +import org.codehaus.groovy.runtime.ArrayTypeUtils.dimension import org.gradle.api.Project import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies @@ -57,6 +58,7 @@ internal class DefaultVariantMatcherTest { apply(KOTLIN_KAPT) } configure { + namespace = "test" defaultConfig { compileSdkVersion(32) } @@ -73,6 +75,7 @@ internal class DefaultVariantMatcherTest { apply(KOTLIN_KAPT) } configure { + namespace = "test" defaultConfig { compileSdkVersion(32) } diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/VariantTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/VariantTest.kt index 672fc781..87f4378f 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/VariantTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/VariantTest.kt @@ -50,7 +50,7 @@ class VariantTest { androidVariant(appExtension.applicationVariants.first()).let { buildVariant -> assertEquals( - 28, + 26, buildVariant.variantConfigurations.size, "Variant configuration parsed for build variant" ) @@ -81,7 +81,7 @@ class VariantTest { val allConfigurations = androidProject.configurations.map { it.name } assertEquals( - 254, + 253, (allConfigurations - parsedConfigurations).size, "Remaining unparsed configurations size at 254" ) diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/VariantTestProject.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/VariantTestProject.kt index 52e0a5ba..0c2afcc6 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/VariantTestProject.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/gradle/variant/VariantTestProject.kt @@ -31,6 +31,7 @@ fun setupAndroidVariantProject(androidProject: Project) { mavenCentral() } configure { + namespace = "test" defaultConfig { compileSdkVersion(32) } diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/AndroidWorkspaceRepositoriesTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/AndroidWorkspaceRepositoriesTest.kt index 3baf04ad..4df0c4ff 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/AndroidWorkspaceRepositoriesTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/AndroidWorkspaceRepositoriesTest.kt @@ -116,6 +116,7 @@ class AndroidWorkspaceRepositoriesTest : GrazelPluginTest() { apply(ANDROID_APPLICATION_PLUGIN) } extensions.configure { + namespace = "test" defaultConfig { compileSdkVersion(29) buildToolsVersion("29.0.3") diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/BuildConfigFieldsTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/BuildConfigFieldsTest.kt index 729e0593..7715e359 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/BuildConfigFieldsTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/BuildConfigFieldsTest.kt @@ -55,6 +55,7 @@ class BuildConfigFieldsTest : GrazelPluginTest() { apply(ANDROID_APPLICATION_PLUGIN) } extensions.configure { + namespace = "test" defaultConfig { compileSdkVersion(29) versionCode = 1 @@ -64,7 +65,7 @@ class BuildConfigFieldsTest : GrazelPluginTest() { buildConfigField("boolean", "SOME_BOOLEAN", "false") buildConfigField("String", "SOME_STRING", "\"Something\"") } - + buildFeatures.buildConfig = true } doEvaluate() } diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/DaggerWorkspaceRuleTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/DaggerWorkspaceRuleTest.kt index 506785a7..20035395 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/DaggerWorkspaceRuleTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/DaggerWorkspaceRuleTest.kt @@ -58,6 +58,7 @@ class DaggerWorkspaceRuleTest { apply(KOTLIN_ANDROID_PLUGIN) } extensions.configure { + namespace = "test" defaultConfig { compileSdkVersion(30) } diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/AndroidInstrumentationBinaryDataExtractorTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/AndroidInstrumentationBinaryDataExtractorTest.kt index 97c7e2d5..c6f181aa 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/AndroidInstrumentationBinaryDataExtractorTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/AndroidInstrumentationBinaryDataExtractorTest.kt @@ -112,6 +112,7 @@ class AndroidInstrumentationBinaryDataExtractorTest : GrazelPluginTest() { apply(KOTLIN_ANDROID_PLUGIN) } extensions.configure { + namespace = "test" defaultConfig { applicationId = "com.example.androidlibrary" compileSdkVersion(31) diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/AndroidLibraryDataKtTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/AndroidLibraryDataKtTest.kt index c49ffdff..0e55190e 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/AndroidLibraryDataKtTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/AndroidLibraryDataKtTest.kt @@ -18,12 +18,14 @@ package com.grab.grazel.migrate.android import com.android.build.gradle.AppExtension import com.grab.grazel.GrazelPluginTest +import com.grab.grazel.bazel.rules.resValue import com.grab.grazel.buildProject import com.grab.grazel.gradle.ANDROID_APPLICATION_PLUGIN import com.grab.grazel.gradle.variant.MatchedVariant import com.grab.grazel.util.addGrazelExtension import com.grab.grazel.util.doEvaluate import com.grab.grazel.util.truth +import org.codehaus.groovy.runtime.ArrayTypeUtils.dimension import org.gradle.api.Project import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.the @@ -46,6 +48,7 @@ class AndroidLibraryDataKtTest : GrazelPluginTest() { apply(ANDROID_APPLICATION_PLUGIN) } extensions.configure { + namespace = "test" defaultConfig { compileSdkVersion(compilerSdkVersion) } diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidLibraryDataExtractorTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidLibraryDataExtractorTest.kt index aac1c1df..018f254b 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidLibraryDataExtractorTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidLibraryDataExtractorTest.kt @@ -45,6 +45,7 @@ class DefaultAndroidLibraryDataExtractorTest { apply(KOTLIN_KAPT) } configure { + namespace = "test" defaultConfig { compileSdkVersion(32) } @@ -61,6 +62,7 @@ class DefaultAndroidLibraryDataExtractorTest { apply(KOTLIN_KAPT) } configure { + namespace = "test" defaultConfig { compileSdkVersion(32) } diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidUnitTestDataExtractorTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidUnitTestDataExtractorTest.kt index 20fea1c3..58528cb2 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidUnitTestDataExtractorTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultAndroidUnitTestDataExtractorTest.kt @@ -73,6 +73,7 @@ class DefaultAndroidUnitTestDataExtractorTest : GrazelPluginTest() { apply(KOTLIN_ANDROID_PLUGIN) } extensions.configure { + namespace = "test" defaultConfig { compileSdkVersion(30) } diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultManifestValuesBuilderTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultManifestValuesBuilderTest.kt index 5d7fd1f3..67375b96 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultManifestValuesBuilderTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/android/DefaultManifestValuesBuilderTest.kt @@ -52,6 +52,7 @@ class DefaultManifestValuesBuilderTest : GrazelPluginTest() { apply(ANDROID_LIBRARY_PLUGIN) } extensions.configure { + namespace = "test" defaultConfig { compileSdkVersion(29) manifestPlaceholders.putAll(setOf("libraryPlaceholder" to "true")) @@ -69,6 +70,7 @@ class DefaultManifestValuesBuilderTest : GrazelPluginTest() { apply(ANDROID_APPLICATION_PLUGIN) } extensions.configure { + namespace = "test" defaultConfig { applicationId = "com.test.grazel" compileSdkVersion(29) diff --git a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/dependencies/DefaultArtifactPinnerTest.kt b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/dependencies/DefaultArtifactPinnerTest.kt index 6bee1cfe..332c9174 100644 --- a/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/dependencies/DefaultArtifactPinnerTest.kt +++ b/grazel-gradle-plugin/src/test/kotlin/com/grab/grazel/migrate/dependencies/DefaultArtifactPinnerTest.kt @@ -61,6 +61,7 @@ class DefaultArtifactPinnerTest { apply(ANDROID_APPLICATION_PLUGIN) } extensions.configure { + namespace = "test" defaultConfig { compileSdkVersion(23) } From d023b3c2ddba704781e116dcbc03c65d7c4e5858 Mon Sep 17 00:00:00 2001 From: arunkumar9t2 Date: Thu, 4 Jul 2024 18:21:42 +0800 Subject: [PATCH 13/13] Update copyright --- README.md | 2 +- .../com/grab/grazel/build/BuildLogicPlugin.kt | 14 +++++++++++++- .../grazel/build/properties/LocalProperties.kt | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index af6dcc7d..21ae64db 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ dependencies { } ``` -Grazel"s `migrateToBazel` task generates the following build script: +Grazel's `migrateToBazel` task generates the following build script: ```python load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library") diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/BuildLogicPlugin.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/BuildLogicPlugin.kt index 0b8e1d35..1758a759 100644 --- a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/BuildLogicPlugin.kt +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/BuildLogicPlugin.kt @@ -1,5 +1,17 @@ /* - * This Kotlin source file was generated by the Gradle 'init' task. + * Copyright 2024 Grabtaxi Holdings PTE LTD (GRAB) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.grab.grazel.build diff --git a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/properties/LocalProperties.kt b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/properties/LocalProperties.kt index cafb7035..0b89109d 100644 --- a/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/properties/LocalProperties.kt +++ b/build-logic/plugin/src/main/kotlin/com/grab/grazel/build/properties/LocalProperties.kt @@ -1,3 +1,19 @@ +/* + * Copyright 2024 Grabtaxi Holdings PTE LTD (GRAB) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.grab.grazel.build.properties import org.gradle.api.Project