2022-10-19 23:00:32 +02:00
|
|
|
plugins {
|
|
|
|
id 'com.android.application'
|
2023-05-12 23:24:11 +02:00
|
|
|
id 'com.github.triplet.play' version '3.8.3'
|
2022-10-19 23:00:32 +02:00
|
|
|
}
|
2020-07-12 11:53:24 +02:00
|
|
|
|
|
|
|
android {
|
2022-09-18 11:16:36 +02:00
|
|
|
namespace 'com.trianguloy.urlchecker'
|
2020-07-12 11:53:24 +02:00
|
|
|
defaultConfig {
|
|
|
|
applicationId "com.trianguloy.urlchecker"
|
2023-11-12 13:34:05 +01:00
|
|
|
compileSdk 33
|
2024-02-02 20:27:23 +01:00
|
|
|
minSdkVersion 19
|
2024-07-15 10:09:22 +02:00
|
|
|
targetSdkVersion 34
|
2024-06-12 22:34:07 +02:00
|
|
|
versionCode 34
|
2024-05-26 17:07:24 +02:00
|
|
|
versionName "2.16"
|
2022-12-18 19:17:28 +01:00
|
|
|
|
|
|
|
|
2022-12-19 00:41:14 +01:00
|
|
|
// generate buildconfig field with all locales
|
2022-12-18 19:17:28 +01:00
|
|
|
def folder = file("src/main/res") // from this folder
|
|
|
|
def prefix = "values-" // with this prefix
|
2022-12-19 00:41:14 +01:00
|
|
|
def translations = folder.list().toList().stream() // from all files in the folder
|
2022-12-18 19:17:28 +01:00
|
|
|
.filter { it.startsWith(prefix) } // keep those starting with the prefix
|
|
|
|
.filter { file("$folder.path/$it/strings.xml").exists() } // and containing a strings translation
|
2022-12-19 00:41:14 +01:00
|
|
|
.collect { it }
|
|
|
|
def constructor = translations.stream()
|
2022-12-18 19:17:28 +01:00
|
|
|
.map { it.substring(prefix.length()).replace('-r', '-') } // extract the locale code
|
|
|
|
.collect { '"' + it + '"' } // convert as 'string'
|
|
|
|
.join(',') // and concatenate with commas
|
2022-12-19 00:41:14 +01:00
|
|
|
buildConfigField "java.util.List<String>", 'LOCALES', "java.util.List.of(\"en\",$constructor)" // create field
|
2022-12-18 19:17:28 +01:00
|
|
|
|
2022-12-19 00:41:14 +01:00
|
|
|
// generate string resource with all translators
|
2023-03-13 00:03:09 +01:00
|
|
|
def translators = translations.stream() // for all translations
|
|
|
|
.map { file("$folder.path/$it/strings.xml") } // get the xml file
|
|
|
|
.map { new XmlParser().parse(it).find { it.@name == "translators" }?.text() ?: "" } // extract translators
|
|
|
|
.filter { it != "" } // filter empty
|
|
|
|
.flatMap { it.split(';').stream() } // split multiple
|
|
|
|
.map { it.strip() } // trim
|
|
|
|
.filter { it != "TrianguloY" } // remove myself
|
2022-12-19 00:41:14 +01:00
|
|
|
.distinct().sorted() // keep distinct and sort them
|
2023-03-13 00:03:09 +01:00
|
|
|
.collect { it }.join(', ') // join with commas
|
|
|
|
print "Extracted translators: $translators"
|
|
|
|
resValue "string", "all_translators", translators // create resource
|
2020-07-12 11:53:24 +02:00
|
|
|
}
|
2022-08-22 19:18:42 +02:00
|
|
|
|
2020-07-12 11:53:24 +02:00
|
|
|
buildTypes {
|
|
|
|
release {
|
|
|
|
minifyEnabled true
|
2020-09-29 09:50:27 +02:00
|
|
|
shrinkResources true
|
2020-07-12 11:53:24 +02:00
|
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
|
|
}
|
2022-08-07 13:29:40 +02:00
|
|
|
alpha {
|
2022-08-21 16:52:30 +02:00
|
|
|
initWith(buildTypes.debug)
|
2022-08-07 13:29:40 +02:00
|
|
|
applicationIdSuffix '.alpha'
|
|
|
|
versionNameSuffix '-ALPHA'
|
|
|
|
}
|
2023-04-14 18:27:26 +02:00
|
|
|
evaluation {
|
|
|
|
initWith(buildTypes.debug)
|
|
|
|
applicationIdSuffix '.test'
|
|
|
|
versionNameSuffix '-TEST'
|
|
|
|
}
|
2020-07-12 11:53:24 +02:00
|
|
|
}
|
2022-08-22 19:18:42 +02:00
|
|
|
|
2022-09-18 11:16:36 +02:00
|
|
|
lint {
|
2022-08-22 19:18:42 +02:00
|
|
|
// users are free to update translations whenever
|
|
|
|
// this mean that they are not usually up to date
|
|
|
|
// and that there are usually lots of missing translations
|
|
|
|
// so we ignore missing strings
|
|
|
|
disable 'MissingTranslation'
|
|
|
|
}
|
2022-08-30 19:26:32 +02:00
|
|
|
|
|
|
|
compileOptions {
|
2024-01-21 13:45:51 +01:00
|
|
|
sourceCompatibility JavaVersion.VERSION_17
|
|
|
|
targetCompatibility JavaVersion.VERSION_17
|
2022-08-30 19:26:32 +02:00
|
|
|
}
|
2024-03-09 12:40:34 +01:00
|
|
|
buildFeatures {
|
|
|
|
buildConfig true
|
|
|
|
}
|
2020-07-12 11:53:24 +02:00
|
|
|
}
|
|
|
|
|
2022-10-27 22:59:36 +02:00
|
|
|
play {
|
|
|
|
track.set("beta")
|
|
|
|
releaseName.set(android.defaultConfig.versionName + " (" + android.defaultConfig.versionCode + ")")
|
|
|
|
}
|
|
|
|
|
2020-07-12 11:53:24 +02:00
|
|
|
dependencies {
|
|
|
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
|
|
}
|