aboutsummaryrefslogtreecommitdiff
path: root/WordPress/build.gradle
blob: c5221ddaa3773097f05060e40e7fc59eb8832c77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.3'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

repositories {
    jcenter()
    maven { url 'http://wordpress-mobile.github.io/WordPress-Android' }
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://jitpack.io" }
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    useLibrary 'org.apache.http.legacy'

    dexOptions {
        jumboMode = true
        javaMaxHeapSize = "6g"
        dexInProcess = true
    }

    compileSdkVersion 24
    buildToolsVersion "24.0.2"

    defaultConfig {
        applicationId "org.wordpress.android"
        versionName "5.9-rc-2"
        versionCode 305
        minSdkVersion 16
        targetSdkVersion 24

        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }

    productFlavors {
        vanilla {} // used for release and beta

        zalpha { // alpha version - enable experimental features
            applicationId "org.wordpress.android"
        }

        wasabi { // "hot" version, can be installed along release, alpha or beta versions
            applicationId "org.wordpress.android.beta"
            minSdkVersion 21 // to take advantage of "fast" multi dex (pre-dex each module)
        }
    }

    buildTypes {
        release {
            // Proguard is used to shrink our apk, and reduce the number of methods in our final apk,
            // but we don't obfuscate the bytecode.
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
        }

        debug {
            minifyEnabled false
            buildConfigField "String", "APP_PN_KEY", "\"org.wordpress.android.debug.build\""
            ext.enableCrashlytics = false
        }
    }
}

dependencies {
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }

    // Provided by maven central
    compile ('org.wordpress:mediapicker:1.2.4') {
        exclude group:'com.android.support'
    }
    compile 'com.google.code.gson:gson:2.6.+'
    compile 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'

    compile 'com.android.support:support-compat:24.2.0'
    compile 'com.android.support:support-core-ui:24.2.0'
    compile 'com.android.support:support-fragment:24.2.0'

    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:cardview-v7:24.2.0'
    compile 'com.android.support:recyclerview-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:percent:24.2.0'

    compile 'com.google.android.gms:play-services-gcm:9.0.2'
    compile 'com.google.android.gms:play-services-auth:9.0.2'
    compile 'com.github.chrisbanes.photoview:library:1.2.4'
    compile 'com.helpshift:android-helpshift-aar:4.4.0'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.automattic:rest:1.0.7'
    compile 'org.wordpress:graphview:3.4.0'
    compile 'org.wordpress:persistentedittext:1.0.1'
    compile 'org.wordpress:emailchecker2:1.1.0'

    compile 'com.yalantis:ucrop:1.5.0'
    compile 'com.github.xizzhu:simple-tool-tip:0.5.0'

    androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
    androidTestCompile 'org.objenesis:objenesis:2.1'
    androidTestCompile 'org.mockito:mockito-core:+'
    androidTestCompile 'com.squareup.okhttp:mockwebserver:2.7.5'

    // Provided by the WordPress-Android Repository
    compile 'org.wordpress:drag-sort-listview:0.6.1' // not found in maven central
    compile 'org.wordpress:slidinguppanel:1.0.0' // not found in maven central
    compile 'org.wordpress:passcodelock:1.3.0'

    // Simperium
    compile 'com.simperium.android:simperium:0.6.8'

    releaseCompile project(path:':libs:utils:WordPressUtils', configuration: 'release')
    debugCompile project(path:':libs:utils:WordPressUtils', configuration: 'debug')
    releaseCompile project(path:':libs:networking:WordPressNetworking', configuration: 'release')
    debugCompile project(path:':libs:networking:WordPressNetworking', configuration: 'debug')
    releaseCompile project(path:':libs:analytics:WordPressAnalytics', configuration: 'release')
    debugCompile project(path:':libs:analytics:WordPressAnalytics', configuration: 'debug')
    releaseCompile project(path:':libs:editor:WordPressEditor', configuration: 'release')
    debugCompile project(path:':libs:editor:WordPressEditor', configuration: 'debug')
}

configurations.all {
    // Exclude packaged wordpress sub projects, force the use of the source project
    // (eg. use :libs:utils:WordPressUtils instead of 'org.wordpress:utils')
    exclude group: 'org.wordpress', module: 'utils'
    exclude group: 'org.wordpress', module: 'analytics'
}

task generateCrashlyticsConfig(group: "generate", description: "Generate Crashlytics config") {
    def outputFile = new File("${rootDir}/WordPress/crashlytics.properties")
    def inputFile = file("${rootDir}/WordPress/gradle.properties")
    if (!inputFile.exists()) {
        throw new StopActionException("Build configuration file:" + inputFile
                + " doesn't exist, follow README instructions")
    }
    outputs.file outputFile
    inputs.file inputFile
    doLast {
        def properties = new Properties()
        inputFile.withInputStream { stream ->
            properties.load(stream)
        }
        def crashlyticsApiKey = properties.getProperty('wp.crashlytics.apikey', '0')
        def writer = new FileWriter(outputFile)
        writer.write("""// auto-generated file from ${rootDir}/gradle.properties do not modify
apiKey=${crashlyticsApiKey}""")
        writer.close()
    }
}

// Add generateCrashlyticsConfig to all generateBuildConfig tasks (all variants)
android.applicationVariants.all { variant ->
    variant.generateBuildConfig.dependsOn(generateCrashlyticsConfig)
}

// Add properties named "wp.xxx" to our BuildConfig
android.buildTypes.all { buildType ->
    project.properties.any { property ->
        if (property.key.toLowerCase().startsWith("wp.")) {
            buildType.buildConfigField "String", property.key.replace("wp.", "").replace(".", "_").toUpperCase(),
                    "\"${property.value}\""
        }
    }
}

// For app signing
if (["storeFile", "storePassword", "keyAlias", "keyPassword"].count { !project.hasProperty(it) } == 0) {
    android {
        signingConfigs {
            release {
                storeFile = file(project.storeFile)
                storePassword = project.storePassword
                keyAlias = project.keyAlias
                keyPassword = project.keyPassword
            }
        }
    }
    android.buildTypes.release.signingConfig = android.signingConfigs.release
}