migrate build.gradle to kts

This commit is contained in:
Helium314 2025-01-19 18:15:58 +01:00
parent 5283c5878c
commit da8827efc3
5 changed files with 142 additions and 153 deletions

View file

@ -1,117 +0,0 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlinx-serialization'
android {
compileSdk 34
buildToolsVersion = '34.0.0'
defaultConfig {
applicationId "helium314.keyboard"
minSdkVersion 21
targetSdkVersion 34
versionCode 2301
versionName '2.3'
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
buildTypes {
release {
minifyEnabled true
shrinkResources false
debuggable false
jniDebuggable false
renderscriptDebuggable false
}
nouserlib { // same as release, but does not allow the user to provide a library
minifyEnabled true
shrinkResources false
debuggable false
jniDebuggable false
renderscriptDebuggable false
}
debug {
minifyEnabled true
jniDebuggable false
applicationIdSuffix ".debug"
}
runTests { // build variant for running tests on CI that skips tests known to fail
minifyEnabled true
jniDebuggable false
}
archivesBaseName = "HeliBoard_" + defaultConfig.versionName
}
buildFeatures {
viewBinding true
buildConfig true
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
ndkVersion '26.2.11394342'
packagingOptions {
jniLibs {
// shrinks APK by 3 MB, zipped size unchanged
useLegacyPackaging true
}
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
// see https://github.com/Helium314/HeliBoard/issues/477
dependenciesInfo {
includeInApk = false
includeInBundle = false
}
namespace "helium314.keyboard.latin"
lint {
abortOnError true
}
}
dependencies {
// androidx
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.preference:preference:1.2.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.autofill:autofill:1.1.0'
// kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3"
// color picker for user-defined colors
implementation 'com.github.martin-stone:hsv-alpha-color-picker-android:3.1.0'
// test
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.14.2'
testImplementation 'org.robolectric:robolectric:4.12.1'
testImplementation 'androidx.test:runner:1.6.2'
testImplementation 'androidx.test:core:1.6.1'
}

117
app/build.gradle.kts Executable file
View file

@ -0,0 +1,117 @@
plugins {
id("com.android.application")
kotlin("android")
kotlin("plugin.serialization") version "2.0.21"
}
android {
compileSdk = 34
buildToolsVersion = "34.0.0"
defaultConfig {
applicationId = "helium314.keyboard"
minSdk = 21
targetSdk = 34
versionCode = 2301
versionName = "2.3"
ndk {
abiFilters.clear()
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64"))
}
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = false
isDebuggable = false
isJniDebuggable = false
}
create("nouserlib") { // same as release, but does not allow the user to provide a library
isMinifyEnabled = true
isShrinkResources = false
isDebuggable = false
isJniDebuggable = false
}
debug {
isMinifyEnabled = true
isJniDebuggable = false
applicationIdSuffix = ".debug"
}
create("runTests") { // build variant for running tests on CI that skips tests known to fail
isMinifyEnabled = true
isJniDebuggable = false
}
base.archivesBaseName = "HeliBoard_" + defaultConfig.versionName
}
buildFeatures {
viewBinding = true
buildConfig = true
}
externalNativeBuild {
ndkBuild {
path = File("src/main/jni/Android.mk")
}
}
ndkVersion = "26.2.11394342"
packagingOptions {
jniLibs {
// shrinks APK by 3 MB, zipped size unchanged
useLegacyPackaging = true
}
}
testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
// see https://github.com/Helium314/HeliBoard/issues/477
dependenciesInfo {
includeInApk = false
includeInBundle = false
}
namespace = "helium314.keyboard.latin"
lint {
abortOnError = true
}
}
dependencies {
// androidx
implementation("androidx.core:core-ktx:1.13.1")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.preference:preference:1.2.1")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.autofill:autofill:1.1.0")
// kotlin
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
// color picker for user-defined colors
implementation("com.github.martin-stone:hsv-alpha-color-picker-android:3.1.0")
// test
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito:mockito-core:5.15.2")
testImplementation("org.robolectric:robolectric:4.12.1")
testImplementation("androidx.test:runner:1.6.2")
testImplementation("androidx.test:core:1.6.1")
}

View file

@ -1,33 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '2.0.21'
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.7.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}

24
build.gradle.kts Executable file
View file

@ -0,0 +1,24 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
val kotlinVersion = "2.0.21"
repositories {
mavenCentral()
google()
}
dependencies {
classpath("com.android.tools.build:gradle:8.7.2")
classpath(kotlin("gradle-plugin", version = kotlinVersion))
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}

View file

@ -25,11 +25,9 @@ task makeEmoji(type: JavaExec, dependsOn: ['jar']) {
} }
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib:2.0.21"
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_21 sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21 targetCompatibility = JavaVersion.VERSION_21