|
| 1 | +// Top-level build file where you can add configuration options common to all sub-projects/modules. |
| 2 | +buildscript { |
| 3 | + repositories { |
| 4 | + google() |
| 5 | + mavenCentral() |
| 6 | + maven { |
| 7 | + url "https://plugins.gradle.org/m2/" |
| 8 | + } |
| 9 | + } |
| 10 | + dependencies { |
| 11 | + classpath 'com.android.tools.build:gradle:7.3.1' |
| 12 | + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10' |
| 13 | + classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.8.10" |
| 14 | + classpath 'org.jlleitschuh.gradle:ktlint-gradle:11.0.0' |
| 15 | + |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +plugins { |
| 20 | + id 'com.android.application' version '7.3.1' apply false |
| 21 | + id 'com.android.library' version '7.3.1' apply false |
| 22 | + id 'org.jetbrains.kotlin.android' version '1.8.10' apply false |
| 23 | + id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.10' apply false |
| 24 | +} |
| 25 | + |
| 26 | +def optInAnnotations = [ |
| 27 | + "com.amplifyframework.annotations.InternalApiWarning", |
| 28 | + "com.amplifyframework.annotations.InternalAmplifyApi" |
| 29 | +] |
| 30 | + |
| 31 | +allprojects { |
| 32 | + repositories { |
| 33 | + google() |
| 34 | + mavenCentral() |
| 35 | + } |
| 36 | + |
| 37 | + gradle.projectsEvaluated { |
| 38 | + tasks.withType(JavaCompile) { |
| 39 | + options.compilerArgs << "-Xlint:all" << "-Werror" |
| 40 | + } |
| 41 | + tasks.withType(Test) { |
| 42 | + minHeapSize = '128m' |
| 43 | + maxHeapSize = '4g' |
| 44 | + } |
| 45 | + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { |
| 46 | + kotlinOptions { |
| 47 | + optInAnnotations.each {annotation -> |
| 48 | + freeCompilerArgs += "-opt-in=" + annotation |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +apply plugin: 'org.jetbrains.dokka' |
| 56 | +dokkaHtmlCollector { |
| 57 | + outputDirectory = rootProject.buildDir |
| 58 | +} |
| 59 | + |
| 60 | +task clean(type: Delete) { |
| 61 | + delete rootProject.buildDir |
| 62 | +} |
| 63 | + |
| 64 | +ext { |
| 65 | + compileSdkVersion = 33 |
| 66 | + minSdkVersion = 24 |
| 67 | + targetSdkVersion = 33 |
| 68 | + amplifyVersion = '2.7.0' |
| 69 | + cameraXVersion = '1.2.0' |
| 70 | + dependency = [ |
| 71 | + amplify: [ |
| 72 | + auth: "com.amplifyframework:aws-api:$amplifyVersion", |
| 73 | + predictions: "com.amplifyframework:aws-predictions:$amplifyVersion", |
| 74 | + ], |
| 75 | + androidx: [ |
| 76 | + camera: [ |
| 77 | + core: "androidx.camera:camera-core:$cameraXVersion", |
| 78 | + camera2: "androidx.camera:camera-camera2:$cameraXVersion", |
| 79 | + lifecycle: "androidx.camera:camera-lifecycle:$cameraXVersion", |
| 80 | + ], |
| 81 | + futures: 'androidx.concurrent:concurrent-futures:1.1.0', |
| 82 | + material: 'androidx.compose.material3:material3:1.0.1', |
| 83 | + uiTooling: 'androidx.compose.ui:ui-tooling:1.3.2', |
| 84 | + lifecycle_ktx: 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0', |
| 85 | + ], |
| 86 | + kotlin: [ |
| 87 | + stdlib: 'org.jetbrains.kotlin:kotlin-stdlib:1.8.10', |
| 88 | + serializationJson: 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3', |
| 89 | + ktlint: 'org.jlleitschuh.gradle:ktlint-gradle:7.1.0', |
| 90 | + ], |
| 91 | + tensorFlow: 'org.tensorflow:tensorflow-lite:2.0.0', |
| 92 | + tensorFlowSupport: 'org.tensorflow:tensorflow-lite-support:0.3.0', |
| 93 | + test: [ |
| 94 | + androidx: [ |
| 95 | + core_ktx: 'androidx.test:core-ktx:1.3.0', |
| 96 | + runner: 'androidx.test:runner:1.3.0', |
| 97 | + junit: 'androidx.test.ext:junit:1.1.4', |
| 98 | + espresso: 'androidx.test.espresso:espresso-core:3.5.0', |
| 99 | + ], |
| 100 | + junit: 'junit:junit:4.13.2', |
| 101 | + robolectric: 'org.robolectric:robolectric:4.7', |
| 102 | + mockk: 'io.mockk:mockk:1.13.4' |
| 103 | + ] |
| 104 | + ] |
| 105 | +} |
| 106 | + |
| 107 | +subprojects { project -> |
| 108 | + project.group = POM_GROUP |
| 109 | + |
| 110 | + apply plugin: 'org.jlleitschuh.gradle.ktlint' |
| 111 | + ktlint { |
| 112 | + android.set(true) |
| 113 | + } |
| 114 | + afterEvaluate { |
| 115 | + configureAndroidLibrary(project) |
| 116 | + } |
| 117 | + if (!project.name.contains("test")) { |
| 118 | + apply plugin: 'org.jetbrains.dokka' |
| 119 | + dokkaHtml { |
| 120 | + dokkaSourceSets { |
| 121 | + configureEach { |
| 122 | + includeNonPublic.set(false) |
| 123 | + skipEmptyPackages.set(true) |
| 124 | + skipDeprecated.set(true) |
| 125 | + reportUndocumented.set(true) |
| 126 | + jdkVersion.set(8) |
| 127 | + } |
| 128 | + } |
| 129 | + } |
| 130 | + } |
| 131 | +} |
| 132 | + |
| 133 | +private void configureAndroidLibrary(Project project) { |
| 134 | + project.ext.VERSION_NAME = project.hasProperty('VERSION_NAME') ? |
| 135 | + project.findProperty('VERSION_NAME') : |
| 136 | + rootProject.findProperty('VERSION_NAME') |
| 137 | + |
| 138 | + if (project.hasProperty('signingKeyId')) { |
| 139 | + System.out.println("Getting signing info from protected source.") |
| 140 | + project.ext.'signing.keyId' = findProperty('signingKeyId') |
| 141 | + project.ext.'signing.password' = findProperty('signingPassword') |
| 142 | + project.ext.'signing.inMemoryKey' = findProperty('signingInMemoryKey') |
| 143 | + } |
| 144 | + |
| 145 | + project.android { |
| 146 | + //buildToolsVersion rootProject.ext.buildToolsVersion |
| 147 | + compileSdkVersion rootProject.ext.compileSdkVersion |
| 148 | + |
| 149 | + defaultConfig { |
| 150 | + multiDexEnabled true |
| 151 | + minSdkVersion project.findProperty('minSdkVersion') |
| 152 | + targetSdkVersion rootProject.ext.targetSdkVersion |
| 153 | + versionName project.ext.VERSION_NAME |
| 154 | + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' |
| 155 | + testInstrumentationRunnerArguments clearPackageData: 'true' |
| 156 | + consumerProguardFiles rootProject.file('configuration/consumer-rules.pro') |
| 157 | + |
| 158 | + testOptions { |
| 159 | + animationsDisabled = true |
| 160 | + unitTests { |
| 161 | + includeAndroidResources = true |
| 162 | + } |
| 163 | + } |
| 164 | + |
| 165 | + buildConfigField "String", "VERSION_NAME", "\"${project.ext.VERSION_NAME}\"" |
| 166 | + } |
| 167 | + |
| 168 | + lintOptions { |
| 169 | + warningsAsErrors true |
| 170 | + abortOnError true |
| 171 | + enable 'UnusedResources' |
| 172 | + enable 'NewerVersionAvailable' |
| 173 | + } |
| 174 | + |
| 175 | + compileOptions { |
| 176 | + sourceCompatibility JavaVersion.VERSION_1_8 |
| 177 | + targetCompatibility JavaVersion.VERSION_1_8 |
| 178 | + } |
| 179 | + |
| 180 | + kotlinOptions { |
| 181 | + jvmTarget = '1.8' |
| 182 | + } |
| 183 | + |
| 184 | + buildFeatures { |
| 185 | + mlModelBinding true |
| 186 | + compose true |
| 187 | + } |
| 188 | + |
| 189 | + composeOptions { |
| 190 | + kotlinCompilerExtensionVersion '1.4.3' |
| 191 | + } |
| 192 | + |
| 193 | + packagingOptions { |
| 194 | + exclude 'META-INF/DEPENDENCIES' |
| 195 | + } |
| 196 | + } |
| 197 | +} |
0 commit comments