fix: improve/update build.gradle

This commit is contained in:
Frieder Bluemle 2019-11-05 14:52:02 -08:00 committed by Dylan Vann
parent df37c4f7b2
commit 1f04c5542c
2 changed files with 43 additions and 44 deletions

View File

@ -1,70 +1,68 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath "com.android.tools.build:gradle:3.4.0"
}
}
apply plugin: "com.android.library"
def safeExtGet(prop, fallback) { def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
} }
def _excludeAppGlideModule = safeExtGet("excludeAppGlideModule", false) buildscript {
def _buildToolsVersion = safeExtGet("buildToolsVersion", "28.0.3") // The Android Gradle plugin is only required when opening the android folder stand-alone.
def _compileSdkVersion = safeExtGet("compileSdkVersion", 28) // This avoids unnecessary downloads and potential conflicts when the library is included as a
def _glideVersion = safeExtGet("glideVersion", "4.11.0") // module dependency in an application project.
def _minSdkVersion = safeExtGet("minSdkVersion", 16) if (project == rootProject) {
def _reactNativeVersion = safeExtGet("reactNative", "+") repositories {
def _targetSdkVersion = safeExtGet("targetSdkVersion", 28) google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
}
}
}
apply plugin: 'com.android.library'
android { android {
compileSdkVersion _compileSdkVersion compileSdkVersion safeExtGet('compileSdkVersion', 28)
buildToolsVersion _buildToolsVersion buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3')
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 28)
versionCode 1
versionName "1.0"
}
sourceSets { sourceSets {
main { main {
java { java {
if (_excludeAppGlideModule) { if (safeExtGet('excludeAppGlideModule', false)) {
srcDir "src" srcDir "src"
exclude "**/FastImageGlideModule.java" exclude "**/FastImageGlideModule.java"
} }
} }
} }
} }
defaultConfig {
minSdkVersion _minSdkVersion
targetSdkVersion _targetSdkVersion
versionCode 1
versionName "1.0"
}
lintOptions { lintOptions {
abortOnError false abortOnError false
} }
} }
repositories { repositories {
mavenCentral() mavenLocal()
google()
maven { maven {
url "https://maven.google.com" // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
} }
maven {
// Android JSC is installed from npm
url "$rootDir/../node_modules/jsc-android/dist"
}
google()
jcenter()
} }
def glideVersion = safeExtGet('glideVersion', '4.11.0')
dependencies { dependencies {
//noinspection GradleDynamicVersion //noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:${_reactNativeVersion}" implementation 'com.facebook.react:react-native:+' // From node_modules
implementation "androidx.core:core:1.0.0" implementation "com.github.bumptech.glide:glide:${glideVersion}"
implementation "androidx.appcompat:appcompat:1.0.0" implementation "com.github.bumptech.glide:okhttp3-integration:${glideVersion}"
implementation "androidx.annotation:annotation:1.0.0" annotationProcessor "com.github.bumptech.glide:compiler:${glideVersion}"
implementation("com.github.bumptech.glide:glide:${_glideVersion}")
implementation("com.github.bumptech.glide:annotations:${_glideVersion}")
annotationProcessor 'com.android.support:support-annotations:28.0.0-alpha3'
annotationProcessor "com.github.bumptech.glide:compiler:${_glideVersion}"
implementation("com.github.bumptech.glide:okhttp3-integration:${_glideVersion}")
} }

View File

@ -1,11 +1,12 @@
package com.dylanvann.fastimage; package com.dylanvann.fastimage;
import android.content.Context; import android.content.Context;
import android.widget.ImageView;
import androidx.appcompat.widget.AppCompatImageView;
import com.bumptech.glide.load.model.GlideUrl; import com.bumptech.glide.load.model.GlideUrl;
class FastImageViewWithUrl extends ImageView { class FastImageViewWithUrl extends AppCompatImageView {
public GlideUrl glideUrl; public GlideUrl glideUrl;
public FastImageViewWithUrl(Context context) { public FastImageViewWithUrl(Context context) {