chore: migrate gradle from groovy to kotlin dsl (buildscripts) (#4758)

Co-authored-by: IndusAryan <a1@gmail.com>
This commit is contained in:
IndusAryan 2023-09-12 15:16:58 +05:30 committed by GitHub
parent 02932a838d
commit 4cef17c9ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 159 additions and 173 deletions

View File

@ -1,134 +0,0 @@
import java.time.Instant
plugins {
id 'com.android.application'
id 'com.google.devtools.ksp'
id 'kotlin-android'
id 'kotlinx-serialization'
id 'kotlin-parcelize'
}
android {
compileSdk 34
defaultConfig {
applicationId 'com.github.libretube'
minSdk 21
targetSdk 33
versionCode 40
versionName '0.17.1'
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
resValue "string", "app_name", "LibreTube"
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
arg("exportSchema", "true")
}
}
buildFeatures {
viewBinding true
}
applicationVariants.configureEach { variant ->
// use the date as version for debug builds
if (variant.name == 'debug') {
variant.outputs.each { output ->
output.versionCodeOverride = getUnixTime()
}
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
applicationIdSuffix ".debug"
resValue "string", "app_name", "LibreTube Debug"
}
}
compileOptions {
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}
splits {
abi {
enable true
reset()
include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
universalApk true
}
}
packagingOptions {
jniLibs {
excludes += ['lib/armeabi-v7a/*_neon.so']
}
}
namespace 'com.github.libretube'
}
dependencies {
//debugImplementation libs.square.leakcanary
/* Android Core */
implementation libs.androidx.activity
implementation libs.androidx.appcompat
implementation libs.androidx.core
implementation libs.androidx.constraintlayout
implementation libs.androidx.fragment
implementation libs.androidx.legacySupport
implementation libs.androidx.navigation.fragment
implementation libs.androidx.navigation.ui
implementation libs.androidx.preference
implementation libs.androidx.work.runtime
/* Android Lifecycle */
implementation libs.lifecycle.viewmodel
implementation libs.lifecycle.runtime
implementation libs.lifecycle.livedata
implementation libs.lifecycle.service
/* Testing */
androidTestImplementation libs.androidx.test.junit
androidTestImplementation libs.androidx.test.espressoCore
/* Design */
implementation libs.material
/* ExoPlayer */
implementation libs.androidx.media3.exoplayer
implementation libs.androidx.media3.ui
implementation libs.androidx.media3.exoplayer.hls
implementation libs.androidx.media3.exoplayer.dash
implementation libs.androidx.media3.session
implementation(libs.androidx.media3.datasource.cronet) { exclude group: 'com.google.android.gms' }
/* Retrofit and Kotlinx Serialization */
implementation libs.square.retrofit
implementation libs.kotlinx.serialization
implementation libs.kotlinx.datetime
implementation libs.kotlinx.serialization.retrofit
/* Cronet and Coil */
coreLibraryDesugaring libs.desugaring
implementation libs.cronet.embedded
implementation libs.cronet.okhttp
implementation libs.coil
/* Room */
ksp libs.room.compiler
implementation libs.room
}
static def getUnixTime() {
return Instant.now().getEpochSecond()
}

131
app/build.gradle.kts Normal file
View File

@ -0,0 +1,131 @@
import java.time.Instant
plugins {
id("com.android.application")
id("com.google.devtools.ksp")
id("kotlin-android")
id("kotlinx-serialization")
id("kotlin-parcelize")
}
android {
compileSdk = 34
defaultConfig {
applicationId = "com.github.libretube"
minSdk = 21
targetSdk = 33
versionCode = 40
versionName = "0.17.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
resValue("string", "app_name", "LibreTube")
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
arg("exportSchema", "true")
}
}
viewBinding {
enable = true
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
getByName("debug") {
isDebuggable = true
applicationIdSuffix = ".debug"
resValue("string", "app_name", "LibreTube Debug")
}
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
splits {
abi {
isEnable = true
reset()
include("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
isUniversalApk = true
}
}
packagingOptions {
exclude("lib/armeabi-v7a/*_neon.so")
}
namespace = "com.github.libretube"
tasks.register("testClasses")
}
dependencies {
// debugImplementation libs.square.leakcanary
/* Android Core */
implementation(libs.androidx.activity)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.fragment)
implementation(libs.androidx.legacySupport)
implementation(libs.androidx.navigation.fragment)
implementation(libs.androidx.navigation.ui)
implementation(libs.androidx.preference)
implementation(libs.androidx.work.runtime)
/* Android Lifecycle */
implementation(libs.lifecycle.viewmodel)
implementation(libs.lifecycle.runtime)
implementation(libs.lifecycle.livedata)
implementation(libs.lifecycle.service)
/* Testing */
androidTestImplementation(libs.androidx.test.junit)
androidTestImplementation(libs.androidx.test.espressoCore)
/* Design */
implementation(libs.material)
/* ExoPlayer */
implementation(libs.androidx.media3.exoplayer)
implementation(libs.androidx.media3.ui)
implementation(libs.androidx.media3.exoplayer.hls)
implementation(libs.androidx.media3.exoplayer.dash)
implementation(libs.androidx.media3.session)
implementation(libs.androidx.media3.datasource.cronet) {
exclude(group = "com.google.android.gms")
}
/* Retrofit and Kotlinx Serialization */
implementation(libs.square.retrofit)
implementation(libs.kotlinx.serialization)
implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.serialization.retrofit)
/* Cronet and Coil */
coreLibraryDesugaring(libs.desugaring)
implementation(libs.cronet.embedded)
implementation(libs.cronet.okhttp)
implementation(libs.coil)
/* Room */
ksp(libs.room.compiler)
implementation(libs.room)
}
fun getUnixTime() = Instant.now().epochSecond

View File

@ -1,6 +1,6 @@
# Add project specific ProGuard rules here. # Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the # You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle. # proguardFiles setting in build.gradle.kts.
# #
# For more details, see # For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html # http://developer.android.com/guide/developing/tools/proguard.html

View File

@ -1,29 +0,0 @@
//plugins {
// id 'com.android.application' apply false version '7.2.1'
//id 'org.jetbrains.kotlin.android' apply false version '1.7.0'
//}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
}
dependencies {
classpath libs.gradle
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 'com.google.devtools.ksp' version '1.9.0-1.0.12' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}

25
build.gradle.kts Normal file
View File

@ -0,0 +1,25 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
val kotlinVersion = "1.8.22"
repositories {
google()
mavenCentral()
}
dependencies {
classpath(libs.gradle)
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
// NOTE: Do not place your application dependencies here, they belong
// to the individual module build.gradle files
}
}
plugins {
id("com.google.devtools.ksp") version("1.9.0-1.0.12") apply false
}
tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
}

View File

@ -1,11 +1,3 @@
//pluginManagement {
// repositories {
//gradlePluginPortal()
// google()
// mavenCentral()
// }
//}
dependencyResolutionManagement { dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories { repositories {
@ -15,4 +7,5 @@ dependencyResolutionManagement {
} }
rootProject.name = "LibreTube" rootProject.name = "LibreTube"
include ':app'
include(":app")