diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index e4a8799ed..3ca1b962e 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -18,7 +18,6 @@ jobs: env: PROPERTIES_PATH: "android/key.properties" JAVA_VERSION: "17.x" - FLUTTER_VERSION: "3.13.7" APP_VERSION_PATH: "app_version.txt" PUBSPEC_PATH: "pubspec.yaml" defaults: @@ -106,9 +105,19 @@ jobs: with: java-version: ${{env.JAVA_VERSION}} distribution: "zulu" - - uses: subosito/flutter-action@v2 + + - uses: mikefarah/yq@master + name: Get Flutter version + id: get_flutter_version + with: + cmd: yq '.environment.flutter' uni/pubspec.yaml + + - name: Set up Flutter + uses: subosito/flutter-action@v2 with: - flutter-version: ${{ env.FLUTTER_VERSION }} + channel: stable + flutter-version: ${{ steps.get_flutter_version.outputs.result }} + cache: true - name: Download Android keystore run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > /tmp/key.jks @@ -174,4 +183,4 @@ jobs: if: github.ref == 'refs/heads/master' run: | echo '${{ secrets.NIAEFEUPBOT_PAT }}' | gh auth login --with-token - gh workflow run 'Deploy Action' --ref develop \ No newline at end of file + gh workflow run 'Deploy Action' --ref develop diff --git a/.github/workflows/format_lint_test.yaml b/.github/workflows/format_lint_test.yaml index 6cced7e1f..cd29d4602 100644 --- a/.github/workflows/format_lint_test.yaml +++ b/.github/workflows/format_lint_test.yaml @@ -4,52 +4,67 @@ on: branches: [master, develop] env: - FLUTTER_VERSION: 3.13.7 JAVA_VERSION: 17.x jobs: format: - name: "Format" + name: Format runs-on: ubuntu-latest defaults: run: working-directory: ./uni steps: - - uses: actions/checkout@v4 - - uses: subosito/flutter-action@v2 + - name: Clone repository + uses: actions/checkout@v4 + + - uses: mikefarah/yq@master + name: Get Flutter version + id: get_flutter_version with: - flutter-version: ${{ env.FLUTTER_VERSION }} + cmd: yq '.environment.flutter' uni/pubspec.yaml + + - name: Set up Flutter + uses: subosito/flutter-action@v2 + with: + channel: stable + flutter-version: ${{ steps.get_flutter_version.outputs.result }} + cache: true - run: dart format $(find . -type f -name "*.dart" -a -not -name "*.g.dart" -a -not -name "*.mocks.dart") --set-exit-if-changed lint: - name: "Lint" + name: Lint runs-on: ubuntu-latest needs: format defaults: run: working-directory: ./uni steps: - - uses: actions/checkout@v4 + - name: Clone repository + uses: actions/checkout@v4 + - uses: actions/setup-java@v3 with: java-version: ${{ env.JAVA_VERSION }} - distribution: "zulu" - - uses: subosito/flutter-action@v2 + distribution: zulu + + - uses: mikefarah/yq@master + name: Get Flutter version + id: get_flutter_version with: - flutter-version: ${{ env.FLUTTER_VERSION }} + cmd: yq '.environment.flutter' uni/pubspec.yaml - - name: Cache pub dependencies - uses: actions/cache@v3 + - name: Set up Flutter + uses: subosito/flutter-action@v2 with: - path: ${{ env.FLUTTER_HOME }}/.pub-cache - key: ${{ runner.os }}-pub-${{ github.ref }}-${{ hashFiles('**/pubspec.lock') }} - restore-keys: ${{ runner.os }}-pub-${{ github.ref }}- + channel: stable + flutter-version: ${{ steps.get_flutter_version.outputs.result }} + cache: true - run: flutter analyze . test: - name: "Test" + name: Test runs-on: ubuntu-latest needs: lint defaults: @@ -60,10 +75,20 @@ jobs: - uses: actions/setup-java@v3 with: java-version: ${{ env.JAVA_VERSION }} - distribution: "zulu" - - uses: subosito/flutter-action@v2 + distribution: zulu + + - uses: mikefarah/yq@master + name: Get Flutter version + id: get_flutter_version + with: + cmd: yq '.environment.flutter' uni/pubspec.yaml + + - name: Set up Flutter + uses: subosito/flutter-action@v2 with: - flutter-version: ${{ env.FLUTTER_VERSION }} + channel: stable + flutter-version: ${{ steps.get_flutter_version.outputs.result }} + cache: true - name: Test with coverage run: flutter test --coverage diff --git a/uni/android/app/build.gradle b/uni/android/app/build.gradle index abcdccc32..59ab8fcaa 100644 --- a/uni/android/app/build.gradle +++ b/uni/android/app/build.gradle @@ -1,71 +1,69 @@ +plugins { + id "com.android.application" + id "dev.flutter.flutter-gradle-plugin" + id "org.jetbrains.kotlin.android" +} + def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') +def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> + localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = '1' + flutterVersionCode = "1" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') +def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = '1.0' + flutterVersionName = "1.0" } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - def keystoreProperties = new Properties() -def keystorePropertiesFile = rootProject.file('key.properties') +def keystorePropertiesFile = rootProject.file("key.properties") if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } android { - if (project.android.hasProperty("namespace")) { - namespace "pt.up.fe.ni.uni" - } + namespace "pt.up.fe.ni.uni" - compileSdkVersion 34 // default is flutter.compileSdkVersion + compileSdkVersion 34 ndkVersion flutter.ndkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 + + // This is required by flutter_local_notifications. See its README. + coreLibraryDesugaringEnabled true } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = "1.8" } sourceSets { - main.java.srcDirs += 'src/main/kotlin' + main.java.srcDirs += "src/main/kotlin" } defaultConfig { applicationId "pt.up.fe.ni.uni" - minSdkVersion 21 // default is flutter.minSdkVersion - targetSdkVersion 34 // default is flutter.targetSdkVersion + minSdkVersion 21 + targetSdkVersion 34 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } signingConfigs { release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null - storePassword keystoreProperties['storePassword'] + keyAlias keystoreProperties["keyAlias"] + keyPassword keystoreProperties["keyPassword"] + storeFile keystoreProperties["storeFile"] ? file(keystoreProperties["storeFile"]) : null + storePassword keystoreProperties["storePassword"] } } @@ -77,9 +75,13 @@ android { } flutter { - source '../..' + source "../.." } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + // The following 3 lines are a workaround for the Flutter issue. + // Learn more: https://github.com/flutter/flutter/issues/110658 + implementation "androidx.window:window:1.0.0" + implementation "androidx.window:window-java:1.0.0" + coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.2.2" } diff --git a/uni/android/app/src/debug/AndroidManifest.xml b/uni/android/app/src/debug/AndroidManifest.xml index 205191a23..399f6981d 100644 --- a/uni/android/app/src/debug/AndroidManifest.xml +++ b/uni/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,4 @@ - +