Skip to content

Commit

Permalink
Revert "Revert "android: Move to new gradle setup""
Browse files Browse the repository at this point in the history
This reverts commit 8a87091.
  • Loading branch information
vHanda committed Sep 6, 2024
1 parent 288c259 commit 3e6c05a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 71 deletions.
53 changes: 16 additions & 37 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,12 @@
//
// SPDX-License-Identifier: Apache-2.0

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
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')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('secrets/key.properties')
if (keystorePropertiesFile.exists()) {
Expand All @@ -42,7 +22,7 @@ if (!keystoreProperties.containsKey('keyAlias')) {
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileSdkVersion flutter.compileSdkVersion

lintOptions {
disable 'InvalidPackage'
Expand All @@ -51,11 +31,11 @@ android {

defaultConfig {
applicationId "io.gitjournal.gitjournal"
minSdkVersion 21
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutter.versionCode
versionName flutter.versionName
// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

flavorDimensions "app"
Expand Down Expand Up @@ -103,10 +83,9 @@ flutter {
source '../..'
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
// Are these required?
// dependencies {
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'androidx.test:runner:1.1.0'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
// }
28 changes: 5 additions & 23 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,6 @@
//
// SPDX-License-Identifier: Apache-2.0

buildscript {
ext.kotlin_version = '1.8.0'
ext {
compileSdkVersion = 34
targetSdkVersion = 34
appCompatVersion = "1.1.0"
}
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

allprojects {
repositories {
google()
Expand All @@ -39,8 +21,8 @@ tasks.register("clean", Delete) {
delete rootProject.buildDir
}

gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
// gradle.projectsEvaluated {
// tasks.withType(JavaCompile) {
// options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
// }
// }
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
# See https://developer.android.com/studio/releases/gradle-plugin#groovy
30 changes: 20 additions & 10 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@
//
// SPDX-License-Identifier: Apache-2.0

include ':app'
pluginManagement {
def flutterSdkPath = {
def properties = new Properties()
file("local.properties").withInputStream { properties.load(it) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
return flutterSdkPath
}()

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

plugins.each { name, path ->
def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
include ":$name"
project(":$name").projectDir = pluginDirectory
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.2.1" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
}

include ":app"

0 comments on commit 3e6c05a

Please sign in to comment.