Skip to content

Commit

Permalink
Add Github actions and Migrate to latest Android SDK, AGP and protobu…
Browse files Browse the repository at this point in the history
…f plugin (PhilipsHue#830)

* chore: Migrate to latest Android SDK, AGP and protobuf plugin

* Remove unused files

* Bumps to Dart 2.17 minimum and upgrades melos to 3.1.0 (PhilipsHue#762)

* Bumps to Dart 2.17 minimum and upgrades melos to 3.1.0

* Update root pubspec.yaml with the correct workspace name

* Add GitHub actions

Co-authored-by: Taym Haddadi <[email protected]>
Co-authored-by: Sebastian Roth <[email protected]>
  • Loading branch information
2 people authored and dballance committed Aug 28, 2024
1 parent 6c4695e commit 210d43c
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 107 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "Build"

on:
pull_request:
push:
branches:
- master

jobs:
build:
name: Build
runs-on: macos-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set Up Java
uses: actions/[email protected]
with:
distribution: 'oracle'
java-version: '19.0.2'

- name: Set Up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.16.3'
channel: 'stable'

- name: Set up debug keystore
run: |
rm -f ~/.android/debug.keystore
keytool -genkeypair \
-alias androiddebugkey \
-keypass android \
-keystore ~/.android/debug.keystore \
-storepass android \
-dname 'CN=Android Debug,O=Android,C=US' \
-keyalg 'RSA' \
-keysize 2048 \
-validity 10000
- name: Quality checks monorepo
run: |
./bin/quality_checks.sh
- name: Android native tests
run: |
#!/bin/bash -ex
cd example/android && ls && ./gradlew detekt && ./gradlew testDebugUnitTest
- name: Build android app
run: |
cd example && flutter build apk --debug
- name: Build iOS app
run: |
find . -name "Podfile" -execdir pod install \;
cd example && flutter build ios --debug --no-codesign
6 changes: 2 additions & 4 deletions bin/quality_checks.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash -ex
#workaround for codemagic CI since melos is not in bash
echo 'export PATH="$PATH":"$FLUTTER_ROOT/.pub-cache/bin"' >>~/.bashrc
echo 'export PATH="$PATH":"$FLUTTER_ROOT/bin"' >>~/.bashrc
source ~/.bashrc
export PATH="$PATH:$FLUTTER_ROOT/.pub-cache/bin"
export PATH="$PATH:$FLUTTER_ROOT/bin"

dart pub global activate melos

Expand Down
58 changes: 0 additions & 58 deletions codemagic.yaml

This file was deleted.

12 changes: 7 additions & 5 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,12 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
compileSdkVersion 33

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

lintOptions {
disable 'InvalidPackage'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -48,7 +45,7 @@ android {
defaultConfig {
applicationId "com.signify.hue.reactivebleexample"
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand All @@ -59,6 +56,11 @@ android {
signingConfig signingConfigs.debug
}
}
namespace 'com.signify.hue.reactivebleexample'

lint {
disable 'InvalidPackage'
}
}

flutter {
Expand Down
3 changes: 1 addition & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.signify.hue.reactivebleexample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<!-- required for API 18 - 30 -->
Expand Down
4 changes: 2 additions & 2 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.8.21'
repositories {
mavenCentral()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath 'com.android.tools.build:gradle:8.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
5 changes: 4 additions & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
android.enableJetifier=true
android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=false
android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
18 changes: 7 additions & 11 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
include ':app'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
}
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
6 changes: 3 additions & 3 deletions example/lib/src/ui/device_detail/device_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class _DeviceDetail extends StatelessWidget {
final DiscoveredDevice device;
final void Function(String deviceId) disconnect;
@override
Widget build(BuildContext context) => WillPopScope(
onWillPop: () async {
Widget build(BuildContext context) => PopScope(
canPop: true,
onPopInvoked: (_) async {
disconnect(device.id);
return true;
},
child: DefaultTabController(
length: 2,
Expand Down
18 changes: 10 additions & 8 deletions packages/reactive_ble_mobile/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version '1.0-SNAPSHOT'

buildscript {
ext.detekt_version = '1.17.1'
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.8.21'
repositories {
google()
mavenCentral()
Expand All @@ -13,8 +13,8 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.17'
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:$detekt_version"
classpath "de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1"
Expand All @@ -38,7 +38,7 @@ apply plugin: "io.gitlab.arturbosch.detekt"
apply plugin: "de.mannodermaus.android-junit5"

android {
compileSdkVersion 31
compileSdkVersion 33
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
Expand All @@ -51,11 +51,13 @@ android {

defaultConfig {
minSdkVersion 21
targetSdkVersion 31
targetSdkVersion 33
consumerProguardFiles 'proguard-rules.txt'
}

lintOptions {
namespace 'com.signify.hue.flutterreactiveble'

lint {
disable 'InvalidPackage'
}

Expand All @@ -79,7 +81,7 @@ detekt {

protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.18.1'
artifact = 'com.google.protobuf:protoc:3.23.0'
}

generateProtoTasks {
Expand All @@ -96,7 +98,7 @@ protobuf {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.polidea.rxandroidble2:rxandroidble:1.16.0'
implementation 'com.google.protobuf:protobuf-javalite:3.18.1'
implementation 'com.google.protobuf:protobuf-javalite:3.23.0'
implementation 'io.reactivex.rxjava2:rxkotlin:2.4.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

Expand Down
4 changes: 0 additions & 4 deletions packages/reactive_ble_mobile/android/gradle.properties

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.signify.hue.flutterreactiveble">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<!-- required for API 18 - 30 -->
<uses-permission
Expand Down

0 comments on commit 210d43c

Please sign in to comment.