1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-16 09:22:08 +01:00
dandelion/build.gradle

113 lines
3.9 KiB
Groovy
Raw Normal View History

/*#######################################################
2018-10-01 21:12:17 +02:00
*
* Maintained by Gregor Santner, 2017-
* https://gsantner.net/
*
* License of this file: Apache 2.0 (Commercial upon request)
* https://www.apache.org/licenses/LICENSE-2.0
*
#########################################################*/
2016-03-03 17:46:31 +01:00
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2019-01-11 02:38:30 +01:00
import java.text.SimpleDateFormat
2016-03-03 17:46:31 +01:00
buildscript {
2019-01-11 02:38:30 +01:00
ext {
2019-08-21 14:22:56 +02:00
version_gradle_tools = "3.5.0"
2019-07-26 03:19:28 +02:00
version_plugin_kotlin = "1.3.41"
2019-01-11 02:38:30 +01:00
enable_plugin_kotlin = false
version_compileSdk = 28
version_buildTools = "28.0.3"
version_minSdk = 17
2017-11-18 20:04:59 +01:00
2019-01-11 02:38:30 +01:00
// https://developer.android.com/topic/libraries/support-library/
version_library_appcompat = "28.0.0" //androidx
// https://github.com/JakeWharton/butterknife/releases
version_library_butterknife = "8.8.1" //9.0.0-rc2
// https://github.com/guardianproject/NetCipher/releases
version_library_netcipher = "2.0.0-alpha1"
}
2017-11-18 20:04:59 +01:00
2016-03-03 17:46:31 +01:00
repositories {
2019-01-11 02:38:30 +01:00
maven { url 'https://maven.google.com' }
2018-07-25 03:30:28 +02:00
jcenter()
2019-01-11 02:38:30 +01:00
maven { url "https://jitpack.io" }
mavenCentral()
2016-03-03 17:46:31 +01:00
}
2019-01-11 02:38:30 +01:00
2016-03-03 17:46:31 +01:00
dependencies {
2019-01-11 02:38:30 +01:00
classpath "com.android.tools.build:gradle:${version_gradle_tools}"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
2017-11-18 20:04:59 +01:00
if (project.enable_plugin_kotlin) {
2019-01-11 02:38:30 +01:00
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${version_plugin_kotlin}"
2017-11-18 20:04:59 +01:00
}
2016-03-03 17:46:31 +01:00
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
2019-01-11 02:38:30 +01:00
maven { url 'https://maven.google.com' }
2018-07-25 03:30:28 +02:00
jcenter()
maven { url "https://jitpack.io" }
2019-01-11 02:38:30 +01:00
mavenCentral()
2016-03-03 17:46:31 +01:00
}
2018-02-06 23:11:18 +01:00
tasks.matching { task -> task.name.matches('.*generate.*Resources') }.all {
task -> task.dependsOn copyRepoFiles
}
2016-03-03 17:46:31 +01:00
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2017-10-29 11:01:27 +01:00
2018-02-06 23:11:18 +01:00
final String[] ROOT_TO_RAW_COPYFILES = ["README.md", "CHANGELOG.md", "CONTRIBUTORS.md", "LICENSE.txt", "LICENSE.md", "LICENSE"]
2017-10-29 11:01:27 +01:00
task copyRepoFiles(type: Copy) {
from rootProject.files(ROOT_TO_RAW_COPYFILES)
into "app/src/main/res/raw"
2017-11-18 20:04:59 +01:00
rename { String fileName -> fileName.replace(fileName, fileName.toLowerCase()) }
2018-02-06 23:11:18 +01:00
}
2017-11-18 20:04:59 +01:00
2017-10-29 11:01:27 +01:00
@SuppressWarnings(["UnnecessaryQualifiedReference", "SpellCheckingInspection", "GroovyUnusedDeclaration"])
2017-11-18 20:04:59 +01:00
// Returns used android languages as a buildConfig array: {'de', 'it', ..}"
2018-03-05 23:37:24 +01:00
static String findUsedAndroidLocales() {
2017-10-29 11:01:27 +01:00
Set<String> langs = new HashSet<>()
new File('.').eachFileRecurse(groovy.io.FileType.DIRECTORIES) {
final foldername = it.name
2019-07-26 03:19:28 +02:00
if (foldername.startsWith('values-') && !it.canonicalPath.contains("build" + File.separator + "intermediates") && !it.canonicalPath.contains("gradle" + File.separator + "daemon")) {
2017-10-29 11:01:27 +01:00
new File(it.toString()).eachFileRecurse(groovy.io.FileType.FILES) {
if (it.name.toLowerCase().endsWith(".xml") && it.getCanonicalFile().getText('UTF-8').contains("<string")) {
langs.add(foldername.replace("values-", ""))
}
}
}
}
2017-11-18 20:04:59 +01:00
return '{' + langs.collect { "\"${it}\"" }.join(",") + '}'
2017-10-29 11:01:27 +01:00
}
ext.getGitHash = { ->
2018-02-06 23:11:18 +01:00
try {
2018-03-05 23:37:24 +01:00
def stdout = new ByteArrayOutputStream()
exec {
2018-02-06 23:11:18 +01:00
commandLine 'git', 'rev-parse', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
2018-03-05 23:37:24 +01:00
} catch (Exception ignored) {
return 'unknown'
2017-10-29 11:01:27 +01:00
}
}
2019-01-11 02:38:30 +01:00
2018-05-09 03:25:23 +02:00
@SuppressWarnings(["UnnecessaryQualifiedReference", "SpellCheckingInspection", "GroovyUnusedDeclaration"])
// Returns the build date in a RFC3339 compatible format. TZ is always converted to UTC
static String getBuildDate() {
final SimpleDateFormat RFC3339_LIKE = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
RFC3339_LIKE.setTimeZone(TimeZone.getTimeZone("UTC"))
return RFC3339_LIKE.format(new Date())
}