Bump support libraries to v20. Gradle doesn't build them by source for now.

The support libraries expect to be using the gradle plugin version 0.10.0.
We are currently on version 1.0.0. They use APIs in their build script which
have moved or been removed, and so the build just breaks when we run it with
the 1.0.0 plugin. I tried some magic to make it work in various ways, but
kept failing. As such, I've reverted the `gradle -PsourceDeps` build to not
build the support libraries from source. In the future, we should be able to
change this if they change the plugin version to a more recent one.

Note that the ant build script still hasn't been modified, and so will be
using the binary support-v4 library, but should build appcompat-v7 from source.

Was going to bump to Support v21, however there is some behaviour change which
causes a crash. They have removed the progress view from the toolbar/actionbar.
This breaks the AppDetails activity. As such, I'll leave that for the future.

For now, there will be a slight difference between building with
ant (which uses support v-almost-21) and gradle (which uses v20).
This will stay the case until we get around to completely porting
the app to v21, and fixing any bugs or UI sadness that arises.
This commit is contained in:
Peter Serwylo 2015-02-20 00:34:16 +11:00
parent eec57945c0
commit aa38418c91
10 changed files with 31 additions and 109 deletions

@ -41,7 +41,7 @@ android update lib-project --path $EXTERN/zxing-core
android update lib-project --path $EXTERN/android-support-v4-preferencefragment
place_support_v4 $EXTERN/android-support-v4-preferencefragment
android update lib-project --path $EXTERN/Support/v7/appcompat --target android-19
android update lib-project --path $EXTERN/Support/v7/appcompat --target android-21
place_support_v4 $EXTERN/Support/v7/appcompat
android update project --path . --name F-Droid

@ -10,24 +10,21 @@ if ( !hasProperty( 'sourceDeps' ) ) {
// 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'
dirs 'libs/binaryDeps'
}
}
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.+',
compile 'com.android.support:support-v4:20.0.+',
'com.android.support:appcompat-v7:20.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.+',
'eu.chainfire:libsuperuser:1.0.0.201501121001',
'com.madgag.spongycastle:pkix:1.51.0.0',
'com.madgag.spongycastle:prov:1.51.0.0',
'com.madgag.spongycastle:core:1.51.0.0'
@ -52,9 +49,11 @@ if ( !hasProperty( 'sourceDeps' ) ) {
logger.info "Setting up *source* dependencies for F-Droid (because you passed in the -PsourceDeps argument to gradle while building)."
repositories {
jcenter()
}
dependencies {
compile project(':support-v4')
compile project(':support-appcompat-v7')
compile project(':extern:AndroidPinning')
compile project(':extern:UniversalImageLoader:library')
compile project(':extern:libsuperuser:libsuperuser')
@ -66,6 +65,22 @@ if ( !hasProperty( 'sourceDeps' ) ) {
exclude module: 'support-v4'
}
// Until the android team updates the gradle plugin version from 0.10.0 to
// a newer version, we can't build this from source with our gradle version
// of 1.0.0. They use API's which have been moved in the newer plugin.
// So yes, this is a little annoying that our "source dependencies" include
// a bunch of binaries from jcenter - but the ant build file (which is the
// one used to build F-Droid which is distributed on https://f-droid.org
// builds these from source - well - not support-v4).
//
// If the android team gets the build script working with the newer plugin,
// then you can find the relevant portions of the ../build.gradle file that
// include magic required to make it work at around about the v0.78 git tag.
// They have since been removed to clean up the build file.
compile 'com.android.support:support-v4:20.0.+',
'com.android.support:appcompat-v7:20.0.+',
'com.android.support:support-annotations:20.0.+'
// Removed for now, until it is reimplemented.
// compile project(':extern:MemorizingTrustManager')
}

@ -22,23 +22,23 @@ 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/ elsewhere.
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/, making sure that the latest versions of the libraries are available
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/ 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/ directory.
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/. This will get deleted
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.
@ -47,4 +47,4 @@ the F-Droid/build.gradle file, adding both the source dependency on the project
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/ directory.
F-Droid/libs/binaryDeps directory.

Binary file not shown.

Binary file not shown.

@ -55,15 +55,6 @@ project(':extern:UniversalImageLoader:library') {
}
}
// 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'
@ -75,81 +66,6 @@ project(':extern:zipsigner') {
}
}
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 {

@ -14,13 +14,4 @@ if ( hasProperty( 'sourceDeps' ) ) {
include ':extern:spongycastle:prov'
include ':extern:zxing-core'
include ':extern:android-support-v4-preferencefragment'
include ':support-v4'
project(':support-v4').projectDir = new File('extern/Support/v4')
include ':support-appcompat-v7'
project(':support-appcompat-v7').projectDir = new File('extern/Support/v7/appcompat')
include ':support-annotations'
project(':support-annotations').projectDir = new File('extern/Support/annotations')
}