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

Update AGP to 8.1.4, upgrade 8.1.1 and update both Gradle/Bazel to use Java 17 #139

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .bazel/.default.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/bazel/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
45 changes: 32 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -14,12 +18,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install JDK 11
uses: actions/setup-java@v2
uses: actions/checkout@v4
- name: Install JDK 17
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "11"
java-version: "17"
- name: Lint
run: |
find "$(pwd -P)" -type f \
Expand All @@ -29,7 +33,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:
Expand All @@ -38,7 +42,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
Expand All @@ -51,7 +55,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:
Expand All @@ -61,7 +65,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/[email protected]
name: grazel-build
with:
Expand All @@ -75,7 +84,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/[email protected]
name: grazel-test
with:
Expand All @@ -89,7 +103,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/[email protected]
name: grazel-gradle-plugin-test
with:
Expand All @@ -104,14 +123,14 @@ 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 11
- name: Install JDK 17
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "11"
java-version: "17"
- uses: burrunan/[email protected]
name: migrate-to-bazel-validation
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,6 +42,7 @@ bin/
gen/
out/
build/
!**/src/**/build/
/build
.ART
# Project files
Expand Down
4 changes: 0 additions & 4 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down
12 changes: 6 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
)

Expand Down
1 change: 1 addition & 0 deletions build-logic/gradle
1 change: 1 addition & 0 deletions build-logic/gradle.properties
1 change: 1 addition & 0 deletions build-logic/gradlew
1 change: 1 addition & 0 deletions build-logic/gradlew.bat
31 changes: 31 additions & 0 deletions build-logic/plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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>("test") {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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

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()
})
Original file line number Diff line number Diff line change
@@ -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<LibraryAndroidComponentsExtension>(builder)
configureIfExist<ApplicationAndroidComponentsExtension>(builder)
configureIfExist<TestAndroidComponentsExtension>(builder)
configureIfExist<DynamicFeatureAndroidComponentsExtension>(builder)
}

internal fun Project.configureAndroid() {
require(this == rootProject) { "Should be only called from root project" }
subprojects {
plugins.withType<AndroidBasePlugin> {
if (this !is LintPlugin) {
androidCommon()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Loading
Loading