Skip to content

Commit 26d153c

Browse files
authored
Migrate build scripts to kts, and version catalogs. (#113)
* Migrate build scripts to kts, and version catalogs. * More migration to kts and version catalogs * Added update deps workflow * More migration to kts and version catalogs * fix compose version * Remove slices example * Fix recomposehighlighter * fix kotlin module * Ignore tests that are meant to fail, and fix broken kotlin tests * Disable bluetoothle building * Load gradle plugins in top level build.gradle.kts, remove fileTree jar loading * Add comma after last module name
1 parent e9e6e1f commit 26d153c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+651
-2785
lines changed

.github/workflows/build.yml

+10-3
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,22 @@ jobs:
3131
steps:
3232
- uses: actions/checkout@v3
3333

34-
- name: set up Java 11
34+
- name: set up Java 17
3535
uses: actions/setup-java@v2
3636
with:
37-
distribution: 'adopt'
38-
java-version: '11'
37+
distribution: 'zulu'
38+
java-version: '17'
3939
- name: Apply formatting if failed
4040
run: ./gradlew :compose:spotlessApply --init-script gradle/init.gradle.kts --no-configuration-cache --stacktrace
4141
- uses: stefanzweifel/git-auto-commit-action@v4
4242
with:
4343
commit_message: Apply Spotless
4444
- name: Build Compose
4545
run: ./gradlew :compose:snippets:build
46+
- name: Build recompose snippets
47+
run: ./gradlew :compose:recomposehighlighter:build
48+
- name: Build kotlin snippets
49+
run: ./gradlew :kotlin:build
50+
# TODO fix bluetoothle snippets (lint is failing) - name: Build bluetoothle snippets
51+
# run: ./gradlew :bluetoothle:build
52+

.github/workflows/update_deps.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Update Versions / Dependencies
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- name: Copy CI gradle.properties
12+
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
13+
- name: set up JDK 17
14+
uses: actions/setup-java@v3
15+
with:
16+
java-version: 17
17+
distribution: 'zulu'
18+
cache: gradle
19+
20+
- name: Update dependencies
21+
run: ./gradlew versionCatalogUpdate
22+
- name: Create pull request
23+
id: cpr
24+
uses: peter-evans/create-pull-request@v4
25+
with:
26+
token: ${{ secrets.PAT }}
27+
commit-message: 🤖 Update Dependencies
28+
committer: compose-devrel-github-bot <[email protected]>
29+
author: compose-devrel-github-bot <[email protected]>
30+
signoff: false
31+
branch: bot-update-deps
32+
delete-branch: true
33+
title: '🤖 Update Dependencies'
34+
body: Updated depedencies

bluetoothle/build.gradle

-35
This file was deleted.

bluetoothle/build.gradle.kts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
plugins {
3+
alias(libs.plugins.android.application)
4+
alias(libs.plugins.kotlin.android)
5+
}
6+
android {
7+
compileSdk = libs.versions.compileSdk.get().toInt()
8+
namespace = "com.sample.android.bluetoothle"
9+
10+
defaultConfig {
11+
applicationId = "com.sample.android.bluetoothle"
12+
minSdk = libs.versions.minSdk.get().toInt()
13+
targetSdk = libs.versions.targetSdk.get().toInt()
14+
versionCode = 1
15+
versionName = "1.0"
16+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
compileOptions {
19+
sourceCompatibility = JavaVersion.VERSION_17
20+
targetCompatibility = JavaVersion.VERSION_17
21+
}
22+
23+
buildTypes {
24+
getByName("debug") {
25+
signingConfig = signingConfigs.getByName("debug")
26+
}
27+
28+
getByName("release") {
29+
isMinifyEnabled = false
30+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"),
31+
"proguard-rules.pro")
32+
}
33+
}
34+
}
35+
dependencies {
36+
implementation(libs.kotlin.stdlib)
37+
implementation(libs.androidx.appcompat)
38+
implementation(libs.androidx.constraintlayout)
39+
testImplementation(libs.junit)
40+
androidTestImplementation(libs.junit)
41+
androidTestImplementation(libs.androidx.test.core)
42+
androidTestImplementation(libs.androidx.test.runner)
43+
androidTestImplementation(libs.androidx.test.espresso.core)
44+
}

bluetoothle/proguard-rules.pro

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Add project specific ProGuard rules here.
22
# You can control the set of applied configuration files using the
3-
# proguardFiles setting in build.gradle.
3+
# proguardFiles setting in build.gradle.kts.
44
#
55
# For more details, see
66
# http://developer.android.com/guide/developing/tools/proguard.html

bluetoothle/src/main/AndroidManifest.xml

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.sample.android.bluetoothle">
44

5+
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
6+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
57
<application>
68
<activity android:name=".kotlin.MainActivity"></activity>
79
<activity android:name=".java.DeviceScanActivity" />

build.gradle

-32
This file was deleted.

build.gradle.kts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
plugins {
3+
alias(libs.plugins.gradle.versions)
4+
alias(libs.plugins.version.catalog.update)
5+
alias(libs.plugins.android.application) apply false
6+
alias(libs.plugins.android.library) apply false
7+
alias(libs.plugins.kotlin.android) apply false
8+
alias(libs.plugins.kapt) apply false
9+
alias(libs.plugins.hilt) apply false
10+
}
11+
12+
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle")
13+
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2023 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
versionCatalogUpdate {
17+
sortByKey.set(true)
18+
19+
keep {
20+
// keep versions without any library or plugin reference
21+
keepUnusedVersions.set(true)
22+
// keep all libraries that aren't used in the project
23+
keepUnusedLibraries.set(true)
24+
// keep all plugins that aren't used in the project
25+
keepUnusedPlugins.set(true)
26+
}
27+
}
28+
29+
def isNonStable = { String version ->
30+
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
31+
def regex = /^[0-9,.v-]+(-r)?$/
32+
return !stableKeyword && !(version ==~ regex)
33+
}
34+
35+
tasks.named("dependencyUpdates").configure {
36+
resolutionStrategy {
37+
componentSelection {
38+
all {
39+
if (isNonStable(it.candidate.version) && !isNonStable(it.currentVersion)) {
40+
reject('Release candidate')
41+
}
42+
}
43+
}
44+
}
45+
}

compose/recomposehighlighter/build.gradle

-57
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
plugins {
2+
alias(libs.plugins.android.application)
3+
alias(libs.plugins.kotlin.android)
4+
}
5+
android {
6+
compileSdk = libs.versions.compileSdk.get().toInt()
7+
namespace = "com.example.recompose"
8+
9+
defaultConfig {
10+
applicationId = "com.example.recompose"
11+
minSdk = libs.versions.minSdk.get().toInt()
12+
targetSdk = libs.versions.targetSdk.get().toInt()
13+
versionCode = 1
14+
versionName = "1.0"
15+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
18+
buildTypes {
19+
getByName("debug") {
20+
signingConfig = signingConfigs.getByName("debug")
21+
}
22+
23+
getByName("release") {
24+
isMinifyEnabled = false
25+
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"),
26+
"proguard-rules.pro")
27+
}
28+
}
29+
compileOptions {
30+
sourceCompatibility = JavaVersion.VERSION_17
31+
targetCompatibility = JavaVersion.VERSION_17
32+
}
33+
buildFeatures {
34+
compose = true
35+
// Disable unused AGP features
36+
viewBinding = true
37+
}
38+
39+
composeOptions {
40+
kotlinCompilerExtensionVersion = libs.versions.compose.compiler.get()
41+
}
42+
}
43+
dependencies {
44+
val composeBom = platform(libs.androidx.compose.bom)
45+
implementation(composeBom)
46+
androidTestImplementation(composeBom)
47+
implementation(libs.androidx.core.ktx)
48+
implementation(libs.androidx.activity.compose)
49+
implementation(libs.androidx.compose.runtime)
50+
implementation(libs.androidx.compose.foundation)
51+
implementation(libs.androidx.compose.foundation.layout)
52+
implementation(libs.androidx.compose.ui.util)
53+
implementation(libs.androidx.compose.material)
54+
55+
implementation(libs.androidx.lifecycle.runtime)
56+
testImplementation(libs.junit)
57+
androidTestImplementation(libs.junit)
58+
androidTestImplementation(libs.androidx.test.core)
59+
androidTestImplementation(libs.androidx.test.runner)
60+
androidTestImplementation(libs.androidx.test.espresso.core)
61+
}

compose/recomposehighlighter/src/main/AndroidManifest.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="com.example.android.compose.recomposehighlighter">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
<application
65
android:label="@string/app_name"
76
android:supportsRtl="true">
87
<activity
9-
android:name=".MainActivity"
8+
android:name="com.example.android.compose.recomposehighlighter.MainActivity"
109
android:theme="@style/Theme.RecomposeHighlighter.NoActionBar"
1110
android:exported="true">
1211
<intent-filter>
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<resources xmlns:tools="http://schemas.android.com/tools">
2-
<style name="Theme.RecomposeHighlighter.NoActionBar" parent="@style/Theme.AppCompat.Light">
3-
<item name="windowActionBar">false</item>
4-
<item name="windowNoTitle">true</item>
2+
<style name="Theme.RecomposeHighlighter.NoActionBar" parent="android:Theme.Material.Light.NoActionBar">
3+
54
</style>
65
</resources>

0 commit comments

Comments
 (0)