Skip to content

Commit

Permalink
Upgrade APG to v3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yongce committed Dec 10, 2017
1 parent ddb8b37 commit 5c9256e
Show file tree
Hide file tree
Showing 10 changed files with 367 additions and 65 deletions.
102 changes: 102 additions & 0 deletions android_module_common.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/**
* File: 'android_module_common.gradle'
* Version: 2017.12.10
* Ref: https://gist.github.com/yongce/cef32768dbdfdf32a54d2488afcf1ed3
* All android projects can copy and include this file.
*/

android {
compileSdkVersion versions.compileSdk
buildToolsVersion versions.buildTools

defaultConfig {
manifestPlaceholders = [
MODULE_GIT_COMMIT_SHA1: getModuleProjectLastCommitSha1(),
ROOT_GIT_COMMIT_SHA1: getRootProjectLastCommitSha1()
]

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

if (project.plugins.hasPlugin("com.android.application")) {
signingConfigs {
androidTestKey {
storeFile file("${rootDir}/aosp.keystore")
storePassword "android"
keyAlias "android.testkey"
keyPassword "android"
}

androidPlatformKey {
storeFile file("${rootDir}/aosp.keystore")
storePassword "android"
keyAlias "android.platformkey"
keyPassword "android"
}
}

buildTypes {
debug {
signingConfig signingConfigs.androidTestKey
}

release {
signingConfig signingConfigs.androidTestKey

minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

applicationVariants.all { variant ->
variant.outputs.each { output ->
String buildType = variant.buildType.name
String abi = output.getFilter("ABI")
if (!buildType.equals("debug")) {
String fileName = "${project.name}"
if (variant.flavorName != null && !variant.flavorName.isEmpty()) {
fileName += "-${variant.flavorName}"
}
if (abi != null && !abi.isEmpty()) {
fileName += "-${abi}"
}
fileName += "-${variant.versionName}-${variant.versionCode}"
output.outputFileName = "${fileName}.apk"
}

if (buildType.equals('release')) {
output.assemble.doLast {
copy {
from output.outputFile.getAbsolutePath()
into "${rootProject.ext.appsOutDir}"
}
}
}
}
}
}

lintOptions {
textReport true
textOutput 'stdout'

abortOnError true
ignoreWarnings isIgnoreLintWarnings()
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions {
unitTests.all {
// All the usual Gradle options.
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}
204 changes: 204 additions & 0 deletions android_project_common.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
/**
* File: 'android_project_common.gradle'
* Version: 2017.12.10
* Ref: https://gist.github.com/yongce/8ac047420e0b5cb5427687e701a26fb2
* All android projects can copy and include this file.
*/

allprojects {
configurations.all {
resolutionStrategy {
eachDependency { details ->
if (details.requested.group == 'com.android.support') {
if (details.requested.name == 'multidex'
|| details.requested.name == 'multidex-instrumentation') {
details.useVersion versions.multidexLib
} else {
details.useVersion versions.supportLib
}
}
}
}
}
}

// Define some common closures (methods) for code share
ext.getModuleProjectCommitCount = {
String gitCommitCountCmd = "git rev-list HEAD --count"
String cmdResult = gitCommitCountCmd.execute((String[])null, project.projectDir).text
return cmdResult.trim().toInteger()
}

ext.getModuleProjectLastCommitSha1 = {
String gitCommitCountCmd = "git log --format=\"%H\" -1"
String cmdResult = gitCommitCountCmd.execute((String[])null, project.projectDir).text
return cmdResult.trim().replace('\"', '')
}

ext.getRootProjectLastCommitSha1 = {
String gitCommitCountCmd = "git log --format=\"%H\" -1"
String cmdResult = gitCommitCountCmd.execute((String[])null, rootProject.projectDir).text
return cmdResult.trim().replace('\"', '')
}

ext.getBuildIdSuffix = {
if (project.hasProperty('build_id')) {
return "." + project.property('build_id')
}
return ""
}

ext.isIgnoreLintWarnings = {
if (project.hasProperty('lint_ignore_warnings')) {
return true
}
return false
}

ext.isApkSplitsEnabled = {
return project.hasProperty('enable_apk_splits')
}

ext {
appsOutDir = "${rootProject.rootDir}/apps_out"
calculatedVersionCode = getModuleProjectCommitCount()
buildIdSuffix = getBuildIdSuffix()

versions = [
// compile
'compileSdk' : 26,
'buildTools' : "26.0.3",

// Android official support
'supportLib' : "27.0.0",
'multidexLib' : "1.0.2",
'constraintLayout' : "1.0.2",
'lintLib' : "26.0.0",

// test
'junit' : "4.12",
'runner' : "1.0.1",
'rules' : "1.0.1",
'espresso' : "3.0.1",
'uiautomator' : "2.1.2",
'hamcrest' : "1.3",
'mockito' : "1.10.19",
'powermock' : "1.6.4",
'robolectric' : "3.2.1",

// google
'gms' : "11.4.2",

// infrastructure
'butterknife' : "8.8.1",
'timber' : "4.6.0",
'guava' : "23.5-android",

// debug
'leakcanary' : "1.5",
'stetho' : "1.5.0",

// serializing
'gson' : "2.8.2",
'protobuf' : "3.1.0",

// network & image
'okhttp' : "3.9.0",
'retrofit' : "2.3.0",
'glide' : "4.2.0",
'glideTrans' : "3.0.1",

// rx
'rxjava' : "2.1.6",
'rxandroid' : "2.0.1",

// ycdev
'androidLib' : "1.2.1",

// others
'zxing' : "3.3.1",
]

deps = [
// Android official support
'support': [
'annotations' : "com.android.support:support-annotations:${versions.supportLib}",
'compat' : "com.android.support:support-compat:${versions.supportLib}",
'coreUtils' : "com.android.support:support-core-utils:${versions.supportLib}",
'coreUi' : "com.android.support:support-core-ui:${versions.supportLib}",
'fragment' : "com.android.support:support-fragment:${versions.supportLib}",
'supportV13' : "com.android.support:support-v13:${versions.supportLib}",
'appcompat' : "com.android.support:appcompat-v7:${versions.supportLib}",
'design' : "com.android.support:design:${versions.supportLib}",
'recyclerview' : "com.android.support:recyclerview-v7:${versions.supportLib}",
'percent' : "com.android.support:percent:${versions.supportLib}",
'constraintLayout' : "com.android.support.constraint:constraint-layout:${versions.constraintLayout}",
'multidex' : "com.android.support:multidex:${versions.multidexLib}",
],

// test
'test': [
'junit' : "junit:junit:$versions.junit",
'supportRunner' : "com.android.support.test:runner:${versions.runner}",
'supportRules' : "com.android.support.test:rules:${versions.rules}",
'espressoCore' : "com.android.support.test.espresso:espresso-core:${versions.espresso}",
'espressoContrib' : "com.android.support.test.espresso:espresso-contrib:${versions.espresso}",
'espressoIntents' : "com.android.support.test.espresso:espresso-intents:${versions.espresso}",
'espressoIdling' : "com.android.support.test.espresso:espresso-idling-resource:${versions.espresso}",
'uiautomator' : "com.android.support.test.uiautomator:uiautomator-v18:${versions.uiautomator}",
'hamcrestCore' : "org.hamcrest:hamcrest-core:${versions.hamcrest}",
'hamcrestLibrary' : "org.hamcrest:hamcrest-library:${versions.hamcrest}",
'mockitoCore' : "org.mockito:mockito-core:${versions.mockito}",
'powermockMockito' : "org.powermock:powermock-api-mockito:${versions.powermock}",
'powermockJunit' : "org.powermock:powermock-module-junit4:${versions.powermock}",
'robolectric' : "org.robolectric:robolectric:${versions.robolectric}",
],

// google
'google': [
'gmsAuth' : "com.google.android.gms:play-services-auth:${versions.gms}",
'gmsLocation' : "com.google.android.gms:play-services-location:${versions.gms}",
],

// infrastructure
'butterknife' : "com.jakewharton:butterknife:${versions.butterknife}",
'butterknifeCompiler' : "com.jakewharton:butterknife-compiler:${versions.butterknife}",
'timber' : "com.jakewharton.timber:timber:${versions.timber}",
'guava' : "com.google.guava:guava:${versions.guava}",

// debug
"leakcanaryDebug" : "com.squareup.leakcanary:leakcanary-android:${versions.leakcanary}",
"leakcanaryRelease" : "com.squareup.leakcanary:leakcanary-android-no-op:${versions.leakcanary}",
'stetho' : "com.facebook.stetho:stetho:${versions.stetho}",
'stethoOkhttp' : "com.facebook.stetho:stetho-okhttp3:${versions.stetho}",

// serializing
'gson' : "com.google.code.gson:gson:${versions.gson}",
'protobufNano' : "com.google.protobuf.nano:protobuf-javanano:${versions.protobuf}",

// network & image
'okhttp' : "com.squareup.okhttp3:okhttp:${versions.okhttp}",
'retrofit' : "com.squareup.retrofit2:retrofit:${versions.retrofit}",
'retrofitGson' : "com.squareup.retrofit2:converter-gson:${versions.retrofit}",
'retrofitProtobuf' : "com.squareup.retrofit2:converter-protobuf:${versions.retrofit}",
'retrofitRxjava' : "com.squareup.retrofit2:adapter-rxjava:${versions.retrofit}",
'glide' : "com.github.bumptech.glide:glide:${versions.glide}",
'glideTrans' : "jp.wasabeef:glide-transformations:${versions.glideTrans}",

// rx
'rx': [
'rxjava' : "io.reactivex.rxjava2:rxjava:${versions.rxjava}",
'rxandroid' : "io.reactivex.rxjava2:rxandroid:${versions.rxandroid}",
],

// ycdev
'ycdev': [
'androidBase' : "me.ycdev.android:common-base:${versions.androidLib}",
'androidArch' : "me.ycdev.android:common-arch:${versions.androidLib}",
'androidUi' : "me.ycdev.android:common-ui:${versions.androidLib}",
],

// others
'zxingCore' : "com.google.zxing:core:${versions.zxing}",
]
}
Binary file added aosp.keystore
Binary file not shown.
19 changes: 10 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
apply from: "${rootDir}/android_project_common.gradle"

buildscript {
repositories {
jcenter()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.android.tools.build:gradle:3.0.1'
}
}

ext {
compileSdkVersion = 22
buildToolsVersion = "22.0.1"
}

allprojects {
repositories {
jcenter()
google()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
delete rootProject.ext.appsOutDir
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Sat Apr 16 23:02:01 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Loading

0 comments on commit 5c9256e

Please sign in to comment.