2014-12-10 10:53:37 +01:00
apply plugin: 'com.android.application'
2014-11-15 22:14:14 +01:00
Default to binary dependencies, with option for source builds.
NOTE: This commit does not touch the ant build system at all,
only gradle.
There are currently 23 gradle projects which require configuration,
let alone building, in order to build F-Droid. This takes a non-trivial
amount of time/memory/cpu. Additionally, it also provides difficulties
when importing the project into Android Studio - which is the IDE that
many potential contributors will be using. Finally, I have over 100mb
of data in the extern/ folder, and the support libraries require almost
every single Android SDK to be installed, which is several GB. This is
not a friendly environment to encourage people to submit merge requests.
However, I'm very mindful of the need for an open source project such
as F-Droid to be able to be built from source. So to make sure we have
the best of both worlds, I've ensured that building all dependencies
from source is still possible.
The F-Droid/libs/README.md file explains in greater detail how to
do this (i.e. "gradle -PsourceDeps build").
As much as possible, I've tried to make the binary dependencies fetched
from jcenter. However there are still libraries which either haven't
integrated required changes for F-Droid back upstream, or don't have
mavenCentral/jcenter binaries available.
Android preference fragment has been changed to the original
upstream repository. The one we had before was because upstream
hadn't merged a MR for gradfle support yet. However, that has
now been merged. This version still doesn't exist in jcenter though.
In order for libsuperuser to build from upstream, using
`gradle -PsourceDeps`, we need to include a few gradle plugins
from jcenter which are never actually used (used by upstream to
release to jcenter).
Even though support-v4 is included through jcenter, it is kept in
the libs directory, so that ./ant-prepare.sh can use it.
Update support preference fragment to newer version. There has been
bugfixes commited, so lets include them in the version we are using.
2015-03-01 10:20:19 +11:00
if ( ! hasProperty ( 'sourceDeps' ) ) {
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)."
repositories {
jcenter ( )
// This is here until we sort out all dependencies from mavenCentral/jcenter. Once all of
// the dependencies below have been sorted out, this can be removed.
flatDir {
dirs 'libs'
}
}
dependencies {
// TODO: A little hazy as to what commit in the source repo these support libraries
// correspond to. As a result, I'm not sure that developers using source dependencies
// and those using binary dependencies are even using the same API.
compile 'com.android.support:support-v4:18.0.+' ,
'com.android.support:appcompat-v7:18.0.+' ,
'com.android.support:support-annotations:20.0.+' ,
'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0' ,
'javax.jmdns:jmdns:3.4.1' ,
'com.nostra13.universalimageloader:universal-image-loader:1.9.3' ,
'com.google.zxing:core:3.1.0' ,
'eu.chainfire:libsuperuser:1.0.0.+' ,
'com.madgag.spongycastle:pkix:1.51.0.0' ,
'com.madgag.spongycastle:prov:1.51.0.0' ,
'com.madgag.spongycastle:core:1.51.0.0'
// Upstream doesn't have a binary on mavenCentral/jcenter yet:
// https://github.com/kolavar/android-support-v4-preferencefragment/issues/13
compile ( name: 'android-support-v4-preferencefragment-release' , ext: 'aar' )
// Fork for F-Droid, including support for https. Not merged into upstream
// yet (seems to be a little unsupported as of late), so not using mavenCentral/jcenter.
compile ( name: 'nanohttpd-2.1.0' )
// Upstream doesn't have a binary on mavenCentral.
compile ( name: 'zipsigner' )
// Upstream doesn't have a binary on mavenCentral, but we are currently not using this
// library due to bugs anyway. In the future, it will likely get included again though.
// compile(name: 'MemorizingTrustManager-release', ext: 'aar')
}
} else {
logger . info "Setting up *source* dependencies for F-Droid (because you passed in the -PsourceDeps argument to gradle while building)."
dependencies {
compile project ( ':support-v4' )
compile project ( ':support-appcompat-v7' )
compile project ( ':extern:AndroidPinning' )
compile project ( ':extern:UniversalImageLoader:library' )
compile project ( ':extern:libsuperuser:libsuperuser' )
compile project ( ':extern:nanohttpd:core' )
compile project ( ':extern:jmdns' )
compile project ( ':extern:zipsigner' )
compile project ( ':extern:zxing-core' )
compile ( project ( ':extern:android-support-v4-preferencefragment' ) ) {
exclude module: 'support-v4'
}
// Removed for now, until it is reimplemented.
// compile project(':extern:MemorizingTrustManager')
2014-11-15 22:14:14 +01:00
}
Default to binary dependencies, with option for source builds.
NOTE: This commit does not touch the ant build system at all,
only gradle.
There are currently 23 gradle projects which require configuration,
let alone building, in order to build F-Droid. This takes a non-trivial
amount of time/memory/cpu. Additionally, it also provides difficulties
when importing the project into Android Studio - which is the IDE that
many potential contributors will be using. Finally, I have over 100mb
of data in the extern/ folder, and the support libraries require almost
every single Android SDK to be installed, which is several GB. This is
not a friendly environment to encourage people to submit merge requests.
However, I'm very mindful of the need for an open source project such
as F-Droid to be able to be built from source. So to make sure we have
the best of both worlds, I've ensured that building all dependencies
from source is still possible.
The F-Droid/libs/README.md file explains in greater detail how to
do this (i.e. "gradle -PsourceDeps build").
As much as possible, I've tried to make the binary dependencies fetched
from jcenter. However there are still libraries which either haven't
integrated required changes for F-Droid back upstream, or don't have
mavenCentral/jcenter binaries available.
Android preference fragment has been changed to the original
upstream repository. The one we had before was because upstream
hadn't merged a MR for gradfle support yet. However, that has
now been merged. This version still doesn't exist in jcenter though.
In order for libsuperuser to build from upstream, using
`gradle -PsourceDeps`, we need to include a few gradle plugins
from jcenter which are never actually used (used by upstream to
release to jcenter).
Even though support-v4 is included through jcenter, it is kept in
the libs directory, so that ./ant-prepare.sh can use it.
Update support preference fragment to newer version. There has been
bugfixes commited, so lets include them in the version we are using.
2015-03-01 10:20:19 +11:00
}
task cleanBinaryDeps ( type: Delete ) {
enabled = project . hasProperty ( 'sourceDeps' )
description = "Removes all .jar and .aar files from F-Droid/libs/. Requires the sourceDeps property to be set (\"gradle -PsourceDeps cleanBinaryDeps\")"
delete fileTree ( 'libs' ) {
include '*.aar'
include '*.jar'
}
}
task binaryDeps ( type: Copy , dependsOn: ':F-Droid:prepareReleaseDependencies' ) {
enabled = project . hasProperty ( 'sourceDeps' )
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\")"
from ( '../extern/' ) {
include 'android-support-v4-preferencefragment/build/outputs/aar/android-support-v4-preferencefragment-release.aar' ,
'nanohttpd/core/build/libs/nanohttpd-2.1.0.jar' ,
'zipsigner/build/libs/zipsigner.jar' ,
'Support/v4/build/libs/support-v4.jar'
// Removed for now, until it is reimplemented.
// 'MemorizingTrustManager/build/outputs/aar/MemorizingTrustManager-release.aar'
}
into 'libs'
includeEmptyDirs false
eachFile { FileCopyDetails details - >
// Don't copy to a sub folder such as libs/Project/build/outputs/aar/project.aar, but
// rather libs/project.aar.
details . path = details . name
}
2014-11-15 22:14:14 +01:00
}
android {
compileSdkVersion 21
Clean up build scripts to make it harder to fail.
* Don't apply android plugin in root project
This results in the root project being treated like and Android project.
That is, gradle will expect an AndroidManifest, a targetSdk property, and
all sorts of stuff that is not relevant to the root project.
Perhaps more importantly, this breaks integration with Android Studio,
which is the tool that many potential contributors will be using.
Finally, it also allows runing gradle tasks in the root project, rather
than having to cd into the F-Droid directory, which is a minor nicety.
The reason it was there in the first place was to make it so that we could
find the location of the Android SDK using the same mechanism that the
plugin used. To deal with this, this commit adapts the SDK finding code
from the gradle plugin.
* Make gradle error out when missing depenencies.
The support v4 library requires some obsolte SDKs that are likely
not installed. It caused non-intuitive errors to come up for me,
so I've made gradle tell the user when this occurs.
* Documented the main build.gradle file
This is primarily to explain the hacks we use in order to build the
Android support libraries.
2014-12-27 21:53:30 +11:00
buildToolsVersion '21.1.2'
2014-11-15 22:14:14 +01:00
compileOptions {
sourceCompatibility JavaVersion . VERSION_1_7
targetCompatibility JavaVersion . VERSION_1_7
}
sourceSets {
main {
manifest . srcFile 'AndroidManifest.xml'
java . srcDirs = [ 'src' ]
resources . srcDirs = [ 'src' ]
aidl . srcDirs = [ 'src' ]
renderscript . srcDirs = [ 'src' ]
res . srcDirs = [ 'res' ]
assets . srcDirs = [ 'assets' ]
}
instrumentTest . setRoot ( 'test' )
}
buildTypes {
release {
minifyEnabled false
}
}
compileOptions . encoding = "UTF-8"
2014-12-21 14:00:00 +01:00
// Enable all Android lint warnings
2014-12-10 10:50:08 +01:00
gradle . projectsEvaluated {
tasks . withType ( JavaCompile ) {
options . compilerArgs < < "-Xlint:all"
}
}
2014-12-21 14:00:00 +01:00
lintOptions {
abortOnError false
2014-12-31 00:04:45 +01:00
textReport true
textOutput file ( "build/outputs/lint-results.txt" )
2014-12-21 14:00:00 +01:00
}
2014-11-15 22:14:14 +01:00
}
Default to binary dependencies, with option for source builds.
NOTE: This commit does not touch the ant build system at all,
only gradle.
There are currently 23 gradle projects which require configuration,
let alone building, in order to build F-Droid. This takes a non-trivial
amount of time/memory/cpu. Additionally, it also provides difficulties
when importing the project into Android Studio - which is the IDE that
many potential contributors will be using. Finally, I have over 100mb
of data in the extern/ folder, and the support libraries require almost
every single Android SDK to be installed, which is several GB. This is
not a friendly environment to encourage people to submit merge requests.
However, I'm very mindful of the need for an open source project such
as F-Droid to be able to be built from source. So to make sure we have
the best of both worlds, I've ensured that building all dependencies
from source is still possible.
The F-Droid/libs/README.md file explains in greater detail how to
do this (i.e. "gradle -PsourceDeps build").
As much as possible, I've tried to make the binary dependencies fetched
from jcenter. However there are still libraries which either haven't
integrated required changes for F-Droid back upstream, or don't have
mavenCentral/jcenter binaries available.
Android preference fragment has been changed to the original
upstream repository. The one we had before was because upstream
hadn't merged a MR for gradfle support yet. However, that has
now been merged. This version still doesn't exist in jcenter though.
In order for libsuperuser to build from upstream, using
`gradle -PsourceDeps`, we need to include a few gradle plugins
from jcenter which are never actually used (used by upstream to
release to jcenter).
Even though support-v4 is included through jcenter, it is kept in
the libs directory, so that ./ant-prepare.sh can use it.
Update support preference fragment to newer version. There has been
bugfixes commited, so lets include them in the version we are using.
2015-03-01 10:20:19 +11:00
// This person took the example code below from another blogpost online, however
2014-11-15 22:14:14 +01:00
// I lost the reference to it:
// http://stackoverflow.com/questions/23297562/gradle-javadoc-and-android-documentation
android . applicationVariants . all { variant - >
task ( "generate${variant.name}Javadoc" , type: Javadoc ) {
title = "$name $version API"
description "Generates Javadoc for F-Droid."
source = variant . javaCompile . source
Clean up build scripts to make it harder to fail.
* Don't apply android plugin in root project
This results in the root project being treated like and Android project.
That is, gradle will expect an AndroidManifest, a targetSdk property, and
all sorts of stuff that is not relevant to the root project.
Perhaps more importantly, this breaks integration with Android Studio,
which is the tool that many potential contributors will be using.
Finally, it also allows runing gradle tasks in the root project, rather
than having to cd into the F-Droid directory, which is a minor nicety.
The reason it was there in the first place was to make it so that we could
find the location of the Android SDK using the same mechanism that the
plugin used. To deal with this, this commit adapts the SDK finding code
from the gradle plugin.
* Make gradle error out when missing depenencies.
The support v4 library requires some obsolte SDKs that are likely
not installed. It caused non-intuitive errors to come up for me,
so I've made gradle tell the user when this occurs.
* Documented the main build.gradle file
This is primarily to explain the hacks we use in order to build the
Android support libraries.
2014-12-27 21:53:30 +11:00
ext . androidJar = "${android.plugin.sdkFolder}/platforms/${android.compileSdkVersion}/android.jar"
2014-11-15 22:14:14 +01:00
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'
}
}