-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
166 lines (137 loc) · 5.48 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
/**
* This is *NOT* the main build script for F-Droid. The main build.gradle
* is in F-Droid/build.gradle. Usually multi-project builds don't have a
* build.gradle in the top level directory (http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Dependencies-Android-Libraries-and-Multi-project-setup).
*
* This build script contains miscellaneous hacks to ensure that all of
* F-Droids dependencies can be built from source.
* Each hack should be documented, and in the future, may need to be changed
* in order to ensure that we keep pace with any changes upstream makes to
* their build processes.
*
* - Some subprojects don't have gradle build scripts, so they are setup here.
*
* - The android support libraries make a lot of dependencies about the project
* two folders up from themselves, which we will have to provide for them.
*/
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
project(':extern:UniversalImageLoader:library') {
apply plugin: 'android-library'
android {
compileSdkVersion 16
buildToolsVersion '21.1.2'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
}
// The support-annotations build.gradle uses the mavenDeployer method, which requires
// this plugin. Even though no artifacts are being deployed, this is still required
// for the build script to work.
project(':support-annotations') {
apply plugin: 'maven'
}
project(':extern:zipsigner') {
apply plugin: 'java'
dependencies {
compile project(':extern:spongycastle:core')
compile project(':extern:spongycastle:pkix')
compile project(':extern:spongycastle:prov')
}
}
project(':support-v4') {
apply plugin: 'maven'
// The support-v4 library assumes certain things are defined in the
// root project (which is usually the android-support project, but
// this time it is the F-Droid project.
rootProject.ext.supportRepoOut = ""
}
/**
* Finds a reference to the prefered Android SDK directory.
* Ideally we'd use "android.plugin.sdkFolder" to find this, however this is
* only possible if we apply the android application plugin. This is not ideal,
* because it will add a bunch of tasks to do with building an android app,
* even tnough this build.gradle is not here to build F-Droid, it is here to
* apply hacks to play nicely with various upstream projects.
*
* Adapted from https://android.googlesource.com/platform/tools/base/+/c8b776289ace4189406b59a9a9c8c9de63271cb0/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/SdkHandler.java
* Copyright (C) 2014 The Android Open Source Project
* Licensed under the Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0i
*/
def findSdkPath() {
Properties properties = new Properties()
File propFile = file("local.properties")
if (propFile.exists()) {
propFile.withReader { properties.load(it) }
}
String sdkDirProp = properties.getProperty("sdk.dir");
if (sdkDirProp != null) {
return new File(sdkDirProp)
}
String envVar = System.getenv("ANDROID_HOME");
if (envVar != null) {
return new File(envVar);
}
String property = System.getProperty("android.home");
if (property != null) {
return new File(property);
}
def error = """
Couldn't find Android SDK. Looked for (in order of precedence):
* sdk.dir in $propFile
* ANDROID_HOME environment variable
* android.home Java property
"""
throw new RuntimeException(error)
}
// Used by the support-v4 libraries build script.
FileCollection getAndroidPrebuilt(String apiLevel) {
def file = new File("${findSdkPath()}/platforms/android-$apiLevel/android.jar")
if (!file.exists()) {
def msg = """
Android SDK for android-$apiLevel not found (required for building support library).
Expected to find it at $file.
Do you have that SDK installed?
(If it is not visible in the Android SDK Manager, "Packages -> Show Obsolete Packages")
"""
throw new RuntimeException(msg)
}
return files(file)
}
subprojects {
// This is the hacky way which we force the subprojects to use the same build tools:
// http://stackoverflow.com/a/21032272
afterEvaluate {
if ( it.hasProperty( 'android' ) ) {
android {
// The android build task only lets you configure the buildToolsVersion once, so if
// we execute the closure below to configure our subprojects, it will fail when it
// hits the second subproject. Therefore, we will only do it once, and I guess the
// android plugin will re-use the existing value I set.
// https://android.googlesource.com/platform/tools/build/+/master/gradle/src/main/groovy/com/android/build/gradle/BaseExtension.groovy
try {
buildToolsVersion '21.1.2'
logger.info("Set buildToolsVersion to '21.1.2'")
} catch (GradleException e) {
logger.info("Tried to set the buildToolsVersion, however we were not allowed to: $e.message")
}
}
}
}
}