From fab60f2ddb4917515570f7c60a1be22670cd836e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 2 Mar 2015 15:46:41 +0100 Subject: Gradle hack to always use same build tools in subprojects --- .travis.yml | 2 +- build.gradle | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index af67b2333..68fa978dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_install: # Install required Android components. #- echo "y" | android update sdk -a --filter build-tools-19.1.0,android-19,platform-tools,extra-android-support,extra-android-m2repository --no-ui --force - - ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --force --filter build-tools-21.1.2,build-tools-21.1.1,build-tools-19.1.0,android-21,android-19,platform-tools,extra-android-support,extra-android-m2repository + - ( sleep 5 && while [ 1 ]; do sleep 1; echo y; done ) | android update sdk --no-ui --all --force --filter build-tools-21.1.2,android-21,android-19,platform-tools,extra-android-support,extra-android-m2repository install: echo "Installation done" script: - ./gradlew assemble -S -q diff --git a/build.gradle b/build.gradle index f8e6afc27..9b6363e93 100644 --- a/build.gradle +++ b/build.gradle @@ -38,3 +38,34 @@ project(':extern:spongycastle') { test.enabled = false } } + +// Copied from https://gitlab.com/fdroid/fdroidclient/blob/master/build.gradle#L144 +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") + } + + // don't abort build on lint errors + // http://stackoverflow.com/a/25149514 + configure(android.lintOptions) { + abortOnError false + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3