1 apply plugin: 'com.android.application'
3 if ( !hasProperty( 'sourceDeps' ) ) {
5 logger.info "Setting up *binary* dependencies for F-Droid (if you'd prefer to build from source, pass the -PsourceDeps argument to gradle while building)."
10 // This is here until we sort out all dependencies from mavenCentral/jcenter. Once all of
11 // the dependencies below have been sorted out, this can be removed.
13 dirs 'libs/binaryDeps'
19 compile 'com.android.support:support-v4:22.1.0',
20 'com.android.support:appcompat-v7:22.1.0',
21 'com.android.support:support-annotations:22.1.0',
23 'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0',
24 'com.nostra13.universalimageloader:universal-image-loader:1.9.4',
25 'com.google.zxing:core:3.2.0',
26 'eu.chainfire:libsuperuser:1.0.0.201504231659',
28 // We use a slightly modified spongycastle, see
29 // openkeychain/spongycastle with some changes on top of 1.51.0.0
30 'com.madgag.spongycastle:pkix:1.51.0.0',
31 'com.madgag.spongycastle:prov:1.51.0.0',
32 'com.madgag.spongycastle:core:1.51.0.0'
34 // Upstream doesn't have a binary on mavenCentral/jcenter yet:
35 // https://github.com/kolavar/android-support-v4-preferencefragment/issues/13
36 compile(name: 'support-v4-preferencefragment-release', ext: 'aar')
38 // Fork for F-Droid, including support for https. Not merged into upstream
39 // yet (seems to be a little unsupported as of late), so not using mavenCentral/jcenter.
40 compile(name: 'nanohttpd-2.1.0')
42 // Upstream doesn't have a binary on mavenCentral.
43 compile(name: 'zipsigner')
45 // Project semi-abandoned, 3.4.1 is from 2011 and we use trunk from 2013
46 compile(name: 'jmdns')
48 androidTestCompile 'commons-io:commons-io:2.2'
53 logger.info "Setting up *source* dependencies for F-Droid (because you passed in the -PsourceDeps argument to gradle while building)."
60 compile project(':extern:AndroidPinning')
61 compile project(':extern:UniversalImageLoader:library')
62 compile project(':extern:libsuperuser:libsuperuser')
63 compile project(':extern:nanohttpd:core')
64 compile project(':extern:jmdns')
65 compile project(':extern:zipsigner')
66 compile project(':extern:zxing-core')
67 compile( project(':extern:support-v4-preferencefragment') ) {
68 exclude module: 'support-v4'
71 // Until the android team updates the gradle plugin version from 0.10.0 to
72 // a newer version, we can't build this from source with our gradle version
73 // of 1.0.0. They use API's which have been moved in the newer plugin.
74 // So yes, this is a little annoying that our "source dependencies" include
75 // a bunch of binaries from jcenter - but the ant build file (which is the
76 // one used to build F-Droid which is distributed on https://f-droid.org
77 // builds these from source - well - not support-v4).
79 // If the android team gets the build script working with the newer plugin,
80 // then you can find the relevant portions of the ../build.gradle file that
81 // include magic required to make it work at around about the v0.78 git tag.
82 // They have since been removed to clean up the build file.
83 compile 'com.android.support:support-v4:22.1.0',
84 'com.android.support:appcompat-v7:22.1.0',
85 'com.android.support:support-annotations:22.1.0'
87 androidTestCompile 'commons-io:commons-io:2.2'
92 task cleanBinaryDeps(type: Delete) {
94 enabled = project.hasProperty('sourceDeps')
95 description = "Removes all .jar and .aar files from F-Droid/libs/. Requires the sourceDeps property to be set (\"gradle -PsourceDeps cleanBinaryDeps\")"
97 delete fileTree('libs/binaryDeps') {
103 task binaryDeps(type: Copy, dependsOn: ':F-Droid:prepareReleaseDependencies') {
105 enabled = project.hasProperty('sourceDeps')
106 description = "Copies .jar and .aar files from subproject dependencies in extern/ to F-Droid/libs. Requires the sourceDeps property to be set (\"gradle -PsourceDeps binaryDeps\")"
108 from ('../extern/' ) {
109 include 'support-v4-preferencefragment/build/outputs/aar/support-v4-preferencefragment-release.aar',
110 'nanohttpd/core/build/libs/nanohttpd-2.1.0.jar',
111 'zipsigner/build/libs/zipsigner.jar',
112 'jmdns/build/libs/jmdns.jar',
113 'Support/v4/build/libs/support-v4.jar'
116 into 'libs/binaryDeps'
118 includeEmptyDirs false
120 eachFile { FileCopyDetails details ->
121 // Don't copy to a sub folder such as libs/binaryDeps/Project/build/outputs/aar/project.aar, but
122 // rather libs/binaryDeps/project.aar.
123 details.path = details.name
130 buildToolsVersion '22.0.1'
134 manifest.srcFile 'AndroidManifest.xml'
135 java.srcDirs = ['src']
136 resources.srcDirs = ['src']
137 aidl.srcDirs = ['src']
138 renderscript.srcDirs = ['src']
139 res.srcDirs = ['res']
140 assets.srcDirs = ['assets']
143 androidTest.setRoot('test')
145 manifest.srcFile 'test/AndroidManifest.xml'
146 java.srcDirs = ['test/src']
147 resources.srcDirs = ['test/src']
148 aidl.srcDirs = ['test/src']
149 renderscript.srcDirs = ['test/src']
150 res.srcDirs = ['test/res']
151 assets.srcDirs = ['test/assets']
167 compileOptions.encoding = "UTF-8"
169 // Use Java 1.7, requires minSdk 8
170 sourceCompatibility JavaVersion.VERSION_1_7
171 targetCompatibility JavaVersion.VERSION_1_7
175 checkReleaseBuilds false
179 // Enable all Android lint warnings
180 gradle.projectsEvaluated {
181 tasks.withType(JavaCompile) {
182 options.compilerArgs << "-Xlint:all"
188 // This person took the example code below from another blogpost online, however
189 // I lost the reference to it:
190 // http://stackoverflow.com/questions/23297562/gradle-javadoc-and-android-documentation
191 android.applicationVariants.all { variant ->
193 task("generate${variant.name}Javadoc", type: Javadoc) {
194 title = "$name $version API"
195 description "Generates Javadoc for F-Droid."
196 source = variant.javaCompile.source
199 Properties properties = new Properties()
200 File localProps = project.rootProject.file('local.properties')
201 if (localProps.exists()) {
202 properties.load(localProps.newDataInputStream())
203 sdkDir = properties.getProperty('sdk.dir')
205 sdkDir = System.getenv('ANDROID_HOME')
208 throw new ProjectConfigurationException("Cannot find android sdk. Make sure sdk.dir is defined in local.properties or the environment variable ANDROID_HOME is set.", null)
211 ext.androidJar = "${sdkDir}/platforms/${android.compileSdkVersion}/android.jar"
212 classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar)
213 options.links("http://docs.oracle.com/javase/7/docs/api/");
214 options.links("http://d.android.com/reference/");
215 exclude '**/BuildConfig.java'