forked from ghosthamlet/frostwire-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
207 lines (172 loc) · 6.12 KB
/
build.gradle
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/*
* Created by Angel Leon (@gubatron), Alden Torres (aldenml)
* Copyright (c) 2011-2015, FrostWire(R). All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import groovy.swing.SwingBuilder
apply plugin: 'com.android.application'
apply from: "$rootDir/frostwire-common/dependencies.gradle"
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
repositories {
mavenCentral()
}
def manifestVersionCode() {
def manifestFile = file(project.projectDir.absolutePath + '/AndroidManifest.xml')
def ns = new groovy.xml.Namespace("http://schemas.android.com/apk/res/android", "android")
def xml = new XmlParser().parse(manifestFile)
return Integer.parseInt(xml.attributes()[ns.versionCode].toString())
}
def manifestVersionName() {
def manifestFile = file(project.projectDir.absolutePath + '/AndroidManifest.xml')
def ns = new groovy.xml.Namespace("http://schemas.android.com/apk/res/android", "android")
def xml = new XmlParser().parse(manifestFile)
return xml.attributes()[ns.versionName].toString()
}
def changeApkOutput(variant) {
def flavor = 'unknown'
if (variant.productFlavors[0].name.equals("basic")) {
flavor = 'basic'
} else if (variant.productFlavors[0].name.equals("plus1")) {
flavor = 'plus'
}
def suffix = project.ext.versionName + '-b' + project.ext.versionCode + '-' + flavor
def name = "$project.buildDir/frostwire-android-" + variant.buildType.name + '-' + suffix
variant.outputs.each { output ->
if (output.zipAlign) {
output.outputFile = file(name + '.apk')
}
//output.packageApplication.outputFile = file(name + '-unaligned.apk')
}
}
project.ext.versionCode = manifestVersionCode()
project.ext.versionName = manifestVersionName()
android {
compileSdkVersion 16
buildToolsVersion '23.0.1'
defaultConfig {
versionName project.ext.versionName
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
res.srcDirs = ['res', 'apollo/res', ]
aidl.srcDirs = ['src', 'apollo/src']
assets.srcDirs = ['assets']
java {
srcDir 'frostwire-common/src/main/java'
srcDir 'apollo/src'
srcDir 'src'
exclude '**/MobileCore*.java'
}
resources {
srcDir 'frostwire-common/src/main/resources'
}
}
plus1.res.srcDirs = ['res-plus1']
}
lintOptions {
abortOnError false
}
dexOptions {
javaMaxHeapSize "2g"
jumboMode = true
}
signingConfigs {
release {
storeFile file("../frostwire-tools/installer_builders/android.keystore/frostwire.keystore")
storePassword ""
keyAlias ""
keyPassword ""
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
productFlavors {
basic {
applicationId 'com.frostwire.android'
versionCode 8100000 + project.ext.versionCode
}
plus1 {
applicationId 'com.frostwire.android'
versionCode 9000000 + project.ext.versionCode
}
}
applicationVariants.all { variant ->
changeApkOutput(variant)
}
}
dependencies {
compile('com.android.support:support-v4:23.1.0') {
exclude group: 'com.android.support', module: 'support-annotations'
}
compile('com.google.android.gms:play-services-ads:8.1.0') {
exclude group: 'com.android.support', module: 'support-annotations'
}
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.frostwire:jlibtorrent-android:1.1.0.9'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(':assembleRelease')) {
def myKeyAlias = ""
def myKeyPassword = ""
if (System.console() == null) {
new SwingBuilder().edt {
dialog(modal: true,
title: 'Enter keystore data',
alwaysOnTop: true,
resizable: true,
locationRelativeTo: null,
show: true,
size: [215, 147]
) {
vbox {
label(text: "Key Alias:")
inputAlias = textField()
label(text: "Key Password:")
inputPassword = passwordField()
button(defaultButton: true, text: 'OK', actionPerformed: {
myKeyAlias = inputAlias.text
myKeyPassword = new String(inputPassword.password)
dispose();
})
}
}
}
} else {
myKeyAlias = System.console().readPassword("\nKey Alias: ")
myKeyAlias = new String(myKeyAlias)
myKeyPassword = System.console().readPassword("\nKey Password: ")
myKeyPassword = new String(myKeyPassword)
}
android.signingConfigs.release.keyAlias = myKeyAlias
android.signingConfigs.release.storePassword = myKeyPassword
android.signingConfigs.release.keyPassword = myKeyPassword
}
}