Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buildscript {
- dependencies {
- classpath 'com.android.tools.build:gradle:0.12.+'
- classpath "com.neenbedankt.gradle.plugins:android-apt:1.2"
- classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.+'
- }
- }
- apply plugin: 'android-sdk-manager'
- apply plugin: 'android'
- apply plugin: 'android-apt'
- android {
- compileSdkVersion androidCompileSdkVersion
- buildToolsVersion androidBuildToolsVersion
- defaultConfig {
- versionName "4.1." // + getBuildNumber() + ".phase2" + "-" + commitHash
- minSdkVersion androidMinSdkVersion
- targetSdkVersion androidTargetSdkVersion
- }
- configurations {
- provided
- }
- sourceSets {
- main {
- manifest.srcFile 'src/main/AndroidManifest.xml'
- java.srcDirs = ['src/main/java', greenDaoSourceDir]
- res.srcDirs = ['src/main/res']
- assets.srcDirs = ['src/main/assets']
- }
- mcom {
- manifest.srcFile 'src/mcom/AndroidManifest.xml'
- java.srcDirs = ['src/mcom/java']
- res.srcDirs = ['src/mcom/res']
- assets.srcDirs = ['src/mcom/assets']
- }
- bcom {
- manifest.srcFile 'src/bcom/AndroidManifest.xml'
- java.srcDirs = ['src/bcom/java']
- res.srcDirs = ['src/bcom/res']
- assets.srcDirs = ['src/bcom/assets']
- }
- }
- signingConfigs {
- debug {
- storeFile file("config/longsword.key")
- storePassword "longsword"
- keyAlias "longsword"
- keyPassword "longsword"
- }
- mcomRelease {
- storeFile file("config/macys-prod.keystore")
- storePassword "macys_keystore"
- keyAlias "macys_keystore"
- keyPassword "macys_keystore"
- }
- bcomRelease {
- storeFile file("config/bloomies-prod.keystore")
- storePassword "bloomies_keystore"
- keyAlias "bloomies_keystore"
- keyPassword "bloomies_keystore"
- }
- }
- buildTypes {
- release {
- versionNameSuffix "-release"
- zipAlign true
- debuggable false
- runProguard true
- proguardFile 'config/proguard-android.txt'
- }
- debug {
- versionNameSuffix "-debug"
- signingConfig signingConfigs.debug
- runProguard false
- proguardFile 'config/proguard-android.txt'
- }
- }
- productFlavors {
- mcom {
- applicationId "com.macys.android"
- versionName "mcom-" + defaultConfig.versionName
- signingConfig signingConfigs.mcomRelease
- }
- bcom {
- applicationId "com.bloomies.android"
- versionName "bcom-" + defaultConfig.versionName
- signingConfig signingConfigs.bcomRelease
- }
- }
- lintOptions {
- checkReleaseBuilds true
- abortOnError false
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_7
- targetCompatibility JavaVersion.VERSION_1_7
- }
- packagingOptions {
- exclude 'META-INF/LICENSE'
- exclude 'META-INF/NOTICE'
- exclude 'META-INF/LICENSE.txt'
- exclude 'META-INF/NOTICE.txt'
- }
- android.applicationVariants.all { variant ->
- // renameApk(variant)
- // generateJavadoc(variant)
- generateGreenDaos(variant)
- loadProperties(variant, 'config/config.json')
- // makeBuildConfigNonFinal(variant)
- variant.javaCompile.classpath += configurations.provided
- }
- }
- dependencies {
- compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
- compile 'com.octo.android.robospice:robospice:1.4.11'
- compile 'com.google.android.gms:play-services:4.2.+'
- compile 'com.google.maps.android:android-maps-utils:0.+'
- compile 'com.viewpagerindicator:library:2.4.1@aar'
- compile('com.nhaarman.supertooltips:library:3.0.+') {
- exclude group: 'com.nineoldandroids', module: 'library'
- }
- compile 'de.timroes.android:EnhancedListView:0.3.2@aar'
- compile 'com.mobsandgeeks:android-saripaar:1.0.2'
- /* external dependens for barcodefragment library */
- provided 'com.google.zxing:core:2.2+'
- compile 'com.nhaarman.listviewanimations:lib-core:3.1.0@aar'
- compile 'com.nhaarman.listviewanimations:lib-manipulation:3.1.0@aar'
- compile 'com.nhaarman.listviewanimations:lib-core-slh:3.1.0@aar'
- compile 'com.iangclifton.android:floatlabel:1.0.1'
- compile project(':Libraries:macys-dao')
- compile project(':Libraries:ShoppingModel')
- provided project(':Libraries:barcodefragment')
- compile project(':Libraries:SherlockNavigationDrawer')
- provided project(':Libraries:facebook')
- compile project(':Libraries:ecogallery')
- provided project(':Libraries:photoviewlibrary')
- compile fileTree(dir: 'libs', include: '*.jar')
- /*
- Should be uncommented when library will be updated.
- Issue - https://github.com/keyboardsurfer/Crouton/pull/174
- Now we use jar from libs folder
- compile('de.keyboardsurfer.android.widget:crouton:1.8.3') {
- exclude group: 'com.google.android', module: 'support-v4'
- }
- */
- debugCompile 'com.noveogroup.android:android-logger:1.3.1'
- }
- apt {
- arguments {
- androidManifestFile variant.processResources.manifestFile
- resourcePackageName 'com.macys'
- }
- }
- /**
- * Generates database access classes
- */
- task generateGreenDao(type: JavaExec) {
- description = "Generates GreenDao database management sources"
- classpath configurations.all
- main 'com.macys.main.dao.MacysDaoGenerator'
- args project.greenDaoSourceDir
- }
- /**
- * Get build version number
- */
- def getBuildNumber() {
- def env = System.getenv()
- def buildNumber = env.BUILD_NUMBER?.toInteger()
- buildNumber = buildNumber ?: 0
- return buildNumber.toString()
- }
- /**
- * Rename apk file name according to variant
- */
- def renameApk(variant) {
- //check if staging variant
- if (variant.zipAlign) {
- def file = variant.outputFile
- def fileName = variant.versionName + ".apk"
- variant.outputFile = new File(file.parent, fileName)
- }
- def file = variant.packageApplication.outputFile
- def fileName = file.name.replace(".apk", "-" + variant.versionName + ".apk")
- fileName = fileName.replaceFirst(".+-unaligned", "unaligned")
- variant.packageApplication.outputFile = new File(file.parent, fileName)
- }
- /**
- * Loads properties from file
- * @param sourceFileName file name
- */
- import groovy.json.JsonSlurper
- def loadProperties(variant, String sourceFileName) {
- def config = new JsonSlurper().parseText(new File(project.getProjectDir(), sourceFileName).text)
- def addFields = { configuration ->
- if (configuration) {
- configuration.buildConfig?.each {
- variant.buildType.buildConfigField "String", it.key, "\"${it.value}\""
- }
- configuration.manifestMetadata?.each {
- addManifestMetadata(variant, it.key, it.value)
- }
- }
- }
- def taskName = "add${variant.name.capitalize()}ConfigFields"
- task "$taskName" << {
- addFields(config)
- addFields(config."$variant.buildType.name")
- String flavorName = variant.name.replace(variant.buildType.name.capitalize(), "")
- addFields(config."$flavorName")
- addFields(config."$variant.name")
- }
- tasks["generate${variant.name.capitalize()}BuildConfig"].dependsOn "$taskName"
- }
- def makeBuildConfigNonFinal(variant) {
- if (variant.buildType.name == 'debug') {
- def removeFinalTask = "make${variant.name.capitalize()}BuildConfigNonFinal"
- tasks["generate${variant.name.capitalize()}BuildConfig"].doLast {
- File buildConfigFile = new File(project.getProjectDir(), "build/generated/source/buildConfig/${variant.name.replace(variant.buildType.name.capitalize(), "")}/${variant.buildType.name.toLowerCase()}/com/macys/BuildConfig.java")
- buildConfigFile.text = buildConfigFile.text.replaceAll("static final", "static")
- }
- }
- }
- def getPropertiesForName(name, String sourceFileName) {
- new JsonSlurper().parseText(new File(project.getProjectDir(), sourceFileName).text)."$name".buildConfig
- }
- /**
- * Adds javadoc task to variant
- */
- def generateJavadoc(variant) {
- def name = variant.name
- task "javadoc$name"(type: Javadoc, dependsOn: "generate${name.capitalize()}Sources") {
- title = "$name $version API"
- description "Generates Javadoc for $variant.name."
- source = variant.javaCompile.source
- ext.androidJar =
- "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
- classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
- options.links("http://docs.oracle.com/javase/7/docs/api/");
- options.links("http://d.android.com/reference/");
- exclude '**/BuildConfig.java'
- exclude '**/R.java'
- }
- }
- /**
- * Adds generate Greendao sources task dependency
- * to variant
- */
- def generateGreenDaos(variant) {
- tasks["generate${variant.name.capitalize()}Sources"].dependsOn generateGreenDao
- }
- /**
- * Adds javadoc task to variant
- */
- import groovy.xml.XmlUtil
- def addManifestMetadata(variant, name, value) {
- File manifestFile = variant.processManifest.manifestOutputFile
- variant.processManifest.doLast {
- def manifest = new XmlSlurper(false, false).parseText(manifestFile.text)
- manifest.'application'[0].appendNode {
- 'meta-data'('android:name': name, 'android:value': value)
- }
- manifestFile.text = XmlUtil.serialize(manifest)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement