Remove support for building entirely from source

* Hard to keep both regular and source builds working and bug-free
* Keep -PsourceDeps to package jars for libs which are not yet in jcenter
* Use the libs packaged in jcenter the same way in both builds
* Remove cleanBinaryDeps, can be done via the shell easily
This commit is contained in:
Daniel Martí 2015-09-08 14:59:30 -07:00
parent 13c90e6c4a
commit 3d749120a7
8 changed files with 28 additions and 101 deletions

View File

@ -1,8 +1,6 @@
apply plugin: 'com.android.application'
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()
@ -25,9 +23,6 @@ if (!hasProperty('sourceDeps')) {
compile 'eu.chainfire:libsuperuser:1.0.0.201504231659'
compile 'cc.mvdan.accesspoint:library:0.1.1'
compile 'info.guardianproject.netcipher:netcipher:1.2'
// We use a slightly modified spongycastle, see
// openkeychain/spongycastle with some changes on top of 1.51.0.0
compile 'com.madgag.spongycastle:pkix:1.51.0.0'
compile 'com.madgag.spongycastle:prov:1.51.0.0'
compile 'com.madgag.spongycastle:core:1.51.0.0'
@ -60,49 +55,41 @@ if (!hasProperty('sourceDeps')) {
}
dependencies {
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 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-annotations:22.2.1'
compile 'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
compile 'com.google.zxing:core:3.2.1'
compile 'eu.chainfire:libsuperuser:1.0.0.201504231659'
compile 'cc.mvdan.accesspoint:library:0.1.1'
compile 'info.guardianproject.netcipher:netcipher:1.2'
compile(project(':extern:support-v4-preferencefragment')) {
exclude module: 'support-v4'
}
compile 'com.android.support:support-v4:22.2.1',
'com.android.support:appcompat-v7:22.1.1',
'com.android.support:support-annotations:22.2.1'
compile project(':extern:nanohttpd:core')
compile project(':extern:zipsigner')
compile project(':extern:jmdns')
androidTestCompile 'commons-io:commons-io:2.2'
}
}
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/binaryDeps') {
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 'support-v4-preferencefragment/build/outputs/aar/support-v4-preferencefragment-release.aar',
'nanohttpd/core/build/libs/nanohttpd-2.1.0.jar',
'zipsigner/build/libs/zipsigner.jar',
'jmdns/build/libs/jmdns.jar'
include 'support-v4-preferencefragment/build/outputs/aar/support-v4-preferencefragment-release.aar'
include 'nanohttpd/core/build/libs/nanohttpd-2.1.0.jar'
include 'zipsigner/build/libs/zipsigner.jar'
include 'jmdns/build/libs/jmdns.jar'
}
into 'libs/binaryDeps'
includeEmptyDirs false
eachFile { FileCopyDetails details ->

View File

@ -1,52 +0,0 @@
# Licenses
To see which license any one of these libraries is under, consult the extern/
directory. If you have checked out the source for all dependencies (`git
submodule update --init` from the root directory if there are any submodules),
then you should be able to find the relevant LICENSE file for each, or else
you can consult upstream.
# Building libraries from source
As a matter of principle, and also to comply with the GPLv3+, F-Droid should always be able to be built
from source, _including all of its dependencies_.
For practical reasons, developers often don't want the overhead of having to fetch the source of each
dependency though. Also, they may not want their build script to have to take the time to configure and
check that each subproject is up-to-date. Building from binary dependencies is _much_ faster, requires
less downloading of external source, and should import into Android Studio and other IDE's more easily.
To deal with these two goals (building dependencies from source, and relying on prebuilt binaries), the
build script can be run in two modes.
## Gradle commands
`gradle build` will build _F-Droid_ from source, but _not the depenencies_ from source. It will instead depend
on binaries from jcenter where possible, and .jar and .aar files in F-Droid/libs/binaryDeps elsewhere.
`gradle -PsourceDeps build` will include all dependencies and build the entire F-Droid binary
and all of its dependencies from source.
`gradle -PsourceDeps binaryDeps` will build all dependencies from source, and then copy the ones which
are not found in jcenter to F-Droid/libs/binaryDeps, making sure that the latest versions of the libraries are available
for developers wishing to build F-Droid from binary dependencies.
`gradle -PsourceDeps cleanBinaryDeps` will remove all binary dependencies. It shouldn't be neccesary,
because the `binaryDeps` will copy fresh .jar and .aar files to the F-Droid/libs/binaryDeps directory when they change.
It may be handy if you are updating the build script though, as a nice way to empty the F-Droid/libs/binaryDeps directory.
# Adding new dependencies
When adding a new dependency, *DON'T* copy the .jar or .aar file into F-Droid/libs/binaryDeps. This will get deleted
when somebody runs `gradle -PsourceDeps cleanBinaryDeps`. Also, the version of F-Droid built for distribution
on https://f-droid.org will be build from source depednencies, so adding a binary is not enough.
Instead, you should add the source repo as a submodule in the extern/ diretory. You will also need to modify
the F-Droid/build.gradle file, adding both the source dependency on the project in the extern/ directory, and
a dependency on its jcenter/mavenCentral artifact. If that artifact is not available, then you should add
the library to those to be copied using `gradler -PsourceDeps binaryDeps`. Then, you can commit that binary so that
anyone who clones the F-Droid repo will have all of the dependencies ready in either jcetner or the
F-Droid/libs/binaryDeps directory.

View File

@ -20,11 +20,6 @@ Once you have checked out the version you wish to build, run:
cd F-Droid
gradle assembleRelease
If you would like to build from source, add `-PsourceDeps`:
cd F-Droid
gradle assembleRelease -PsourceDeps
The resulting apk will be in `build/outputs/apk/`.
Android Studio

View File

@ -12,7 +12,7 @@ apply plugin: 'android-library'
android {
compileSdkVersion 17
buildToolsVersion '22.0.1'
buildToolsVersion '23.0.1'
android {
sourceSets {

View File

@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 5

View File

@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "22.0.1"
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 4

View File

@ -19,7 +19,7 @@ dependencies {
android {
compileSdkVersion 19
buildToolsVersion '22.0.1'
buildToolsVersion '23.0.1'
defaultConfig {
minSdkVersion 7

View File

@ -1,15 +1,12 @@
include ':F-Droid'
if ( hasProperty( 'sourceDeps' ) ) {
include ':extern:AndroidPinning'
include ':extern:UniversalImageLoader:library'
include ':extern:libsuperuser:libsuperuser'
if (hasProperty('sourceDeps')) {
include ':extern:support-v4-preferencefragment'
include ':extern:nanohttpd:core'
include ':extern:jmdns'
include ':extern:zipsigner'
include ':extern:jmdns'
// Needed for zipsigner
include ':extern:spongycastle:core'
include ':extern:spongycastle:pkix'
include ':extern:spongycastle:prov'
include ':extern:zxing-core'
include ':extern:support-v4-preferencefragment'
}