Migrate to kotlin gradle scripts

This commit is contained in:
Ensar Sarajčić 2023-08-17 14:46:52 +02:00
parent c8d94a704d
commit dd91cfe713
8 changed files with 287 additions and 211 deletions

View File

@ -1,159 +0,0 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 34
namespace = "com.simplemobiletools.gallery.pro"
defaultConfig {
applicationId "com.simplemobiletools.gallery.pro"
minSdkVersion 23
targetSdkVersion 34
versionCode 394
versionName "6.27.2"
setProperty("archivesBaseName", "gallery-$versionCode")
vectorDrawables.useSupportLibrary = true
}
signingConfigs {
if (keystorePropertiesFile.exists()) {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
}
buildTypes {
debug {
// we cannot change the original package name, else PhotoEditorSDK won't work
//applicationIdSuffix ".debug"
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (keystorePropertiesFile.exists()) {
signingConfig signingConfigs.release
}
}
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
if (is_proprietary) {
main.java.srcDirs += 'src/proprietary/kotlin'
}
}
flavorDimensions "licensing"
productFlavors {
proprietary {}
foss {}
prepaid {}
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
packagingOptions {
resources {
excludes += ['META-INF/library_release.kotlin_module']
}
}
buildFeatures {
buildConfig = true
viewBinding = true
}
}
dependencies {
implementation 'com.github.esensar:Simple-Commons:98cea1b5bb'
implementation 'com.vanniktech:android-image-cropper:4.5.0'
implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.media3:media3-exoplayer:1.1.0'
implementation 'com.google.vr:sdk-panowidget:1.180.0'
implementation 'com.google.vr:sdk-videowidget:1.180.0'
implementation 'org.apache.sanselan:sanselan:0.97-incubator'
implementation 'info.androidhive:imagefilters:1.0.7'
implementation 'com.caverock:androidsvg-aar:1.4'
implementation 'com.github.tibbi:gestureviews:a8e8fa8d27'
implementation 'com.github.tibbi:subsampling-scale-image-view:80efdaa570'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'com.github.penfeizhou.android.animation:awebp:2.25.0'
implementation 'com.github.penfeizhou.android.animation:apng:2.25.0'
implementation 'com.squareup.okio:okio:3.0.0'
implementation('com.squareup.picasso:picasso:2.71828') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
compileOnly 'com.squareup.okhttp3:okhttp:4.9.0'
kapt 'com.github.bumptech.glide:compiler:4.15.1'
kapt 'androidx.room:room-compiler:2.5.2'
implementation 'androidx.room:room-runtime:2.5.2'
annotationProcessor 'androidx.room:room-compiler:2.5.2'
//implementation project(':commons')
}
// Apply the PESDKPlugin
if (is_proprietary) {
apply plugin: 'ly.img.android.sdk'
imglyConfig {
vesdk {
enabled true
licensePath 'vesdk_android_license'
}
pesdk {
enabled true
licensePath 'pesdk_android_license'
}
modules {
include 'ui:video-trim'
include 'ui:core'
include 'ui:text'
include 'ui:focus'
include 'ui:brush'
include 'ui:filter'
include 'ui:sticker'
include 'ui:overlay'
include 'ui:transform'
include 'ui:adjustment'
include 'ui:video-composition'
include 'backend:serializer'
include 'backend:sticker-smart'
include 'backend:sticker-animated'
include 'assets:font-basic'
include 'assets:filter-basic'
include 'assets:overlay-basic'
include 'assets:sticker-shapes'
include 'assets:sticker-emoticons'
include 'assets:sticker-animated'
}
}
}

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

@ -0,0 +1,135 @@
import java.io.FileInputStream
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.konan.properties.Properties
val isProprietary = gradle.startParameter.taskNames.any { task -> task.contains("Proprietary") }
plugins {
alias(libs.plugins.android)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.ksp)
alias(libs.plugins.imgly).apply(false)
}
val keystorePropertiesFile: File = rootProject.file("keystore.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
android {
compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt()
defaultConfig {
applicationId = libs.versions.app.version.appId.get()
minSdk = project.libs.versions.app.build.minimumSDK.get().toInt()
targetSdk = project.libs.versions.app.build.targetSDK.get().toInt()
versionName = project.libs.versions.app.version.versionName.get()
versionCode = project.libs.versions.app.version.versionCode.get().toInt()
setProperty("archivesBaseName", "gallery-$versionCode")
}
signingConfigs {
if (keystorePropertiesFile.exists()) {
register("release") {
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
storeFile = file(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
}
}
}
buildFeatures {
viewBinding = true
buildConfig = true
}
buildTypes {
debug {
// we cannot change the original package name, else PhotoEditorSDK won't work
//applicationIdSuffix = ".debug"
}
release {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
if (keystorePropertiesFile.exists()) {
signingConfig = signingConfigs.getByName("release")
}
}
}
flavorDimensions.add("licensing")
productFlavors {
register("proprietary")
register("foss")
register("prepaid")
}
sourceSets {
getByName("main").java.srcDirs("src/main/kotlin")
if (isProprietary) {
getByName("main").java.srcDirs("src/proprietary/kotlin")
}
}
compileOptions {
val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get().toString())
sourceCompatibility = currentJavaVersionFromLibs
targetCompatibility = currentJavaVersionFromLibs
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = project.libs.versions.app.build.kotlinJVMTarget.get()
}
namespace = libs.versions.app.version.appId.get()
lint {
checkReleaseBuilds = false
abortOnError = false
}
packaging {
resources {
excludes += "META-INF/library_release.kotlin_module"
}
}
}
dependencies {
implementation(libs.simple.tools.commons)
implementation(libs.android.image.cropper)
implementation(libs.exif)
implementation(libs.android.gif.drawable)
implementation(libs.androidx.constraintlayout)
implementation(libs.androidx.media3.exoplayer)
implementation(libs.sdk.panowidget)
implementation(libs.sdk.videowidget)
implementation(libs.sanselan)
implementation(libs.imagefilters)
implementation(libs.androidsvg.aar)
implementation(libs.gestureviews)
implementation(libs.subsamplingscaleimageview)
implementation(libs.androidx.swiperefreshlayout)
implementation(libs.awebp)
implementation(libs.apng)
implementation(libs.okio)
implementation(libs.picasso) {
exclude(group = "com.squareup.okhttp3", module = "okhttp")
}
compileOnly(libs.okhttp)
ksp(libs.glide.compiler)
implementation(libs.bundles.room)
ksp(libs.androidx.room.compiler)
}
// Apply the PESDKPlugin
if (isProprietary) {
apply(from = "../gradle/imglysdk.gradle")
}

View File

@ -1,49 +0,0 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
// needed only if we are including commons locally from our pc, not via Jitpack
/*ext {
propCompileSdkVersion = 33
propMinSdkVersion = 23
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '5.34.26'
}*/
ext.kotlin_version = '1.8.22'
ext.is_proprietary = gradle.startParameter.taskNames.any { task -> task.contains("Proprietary") }
repositories {
google()
jcenter()
if (is_proprietary) {
maven { url 'https://artifactory.img.ly/artifactory/imgly' }
}
}
dependencies {
classpath 'com.android.tools.build:gradle:8.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
if (is_proprietary) {
classpath 'ly.img.android.pesdk:plugin:10.7.3'
}
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
if (is_proprietary) {
maven { url 'https://artifactory.img.ly/artifactory/imgly' }
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

6
build.gradle.kts Normal file
View File

@ -0,0 +1,6 @@
plugins {
alias(libs.plugins.android).apply(false)
alias(libs.plugins.kotlinAndroid).apply(false)
alias(libs.plugins.ksp).apply(false)
alias(libs.plugins.imgly).apply(false)
}

42
gradle/imglysdk.gradle Normal file
View File

@ -0,0 +1,42 @@
// This file had to stay in Groovy
// Since just converting it to Kotlin will not work
// There needs to be a way to conditinally apply this plugin
// But that results in missing references for `imglyConfig`
apply plugin: 'ly.img.android.sdk'
imglyConfig {
vesdk {
enabled true
licensePath 'vesdk_android_license'
}
pesdk {
enabled true
licensePath 'pesdk_android_license'
}
modules {
include 'ui:video-trim'
include 'ui:core'
include 'ui:text'
include 'ui:focus'
include 'ui:brush'
include 'ui:filter'
include 'ui:sticker'
include 'ui:overlay'
include 'ui:transform'
include 'ui:adjustment'
include 'ui:video-composition'
include 'backend:serializer'
include 'backend:sticker-smart'
include 'backend:sticker-animated'
include 'assets:font-basic'
include 'assets:filter-basic'
include 'assets:overlay-basic'
include 'assets:sticker-shapes'
include 'assets:sticker-emoticons'
include 'assets:sticker-animated'
}
}

84
gradle/libs.versions.toml Normal file
View File

@ -0,0 +1,84 @@
[versions]
#imgly
imgly = "10.7.3"
#jetbrains
kotlin = "1.8.22"
#KSP
ksp = "1.8.22-1.0.11"
#AndroidX
androidx-swiperefreshlayout = "1.1.0"
androidx-constraintlayout = "2.1.4"
#exif
exif = "1.0.1"
#Room
room = "2.6.0-alpha03"
#Simple tools
simple-commons = "2b25092d2a"
#Gradle
gradlePlugins-agp = "8.1.0"
#Other
androidGifDrawable = "1.2.25"
androidImageCropper = "4.5.0"
apng = "2.25.0"
awebp = "2.25.0"
glideCompiler = "4.15.1"
gestureviews = "a8e8fa8d27"
androidsvgAar = "1.4"
imagefilters = "1.0.7"
sanselan = "0.97-incubator"
sdkVideowidget = "1.180.0"
sdkPanowidget = "1.180.0"
media3Exoplayer = "1.1.0"
okhttp = "4.9.0"
okio = "3.0.0"
picasso = "2.71828"
#build
app-build-compileSDKVersion = "34"
app-build-targetSDK = "34"
app-build-minimumSDK = "23"
app-build-javaVersion = "VERSION_17"
app-build-kotlinJVMTarget = "17"
#versioning
app-version-appId = "com.simplemobiletools.gallery.pro"
app-version-versionCode = "394"
app-version-versionName = "6.27.2"
subsamplingScaleImageView = "80efdaa570"
[libraries]
#AndroidX
androidx-media3-exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3Exoplayer" }
androidx-swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref = "androidx-swiperefreshlayout" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" }
#exif
exif = { module = "it.sephiroth.android.exif:library", version.ref = "exif" }
#Room
androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
#Simple Mobile Tools
simple-tools-commons = { module = "com.github.SimpleMobileTools:Simple-Commons", version.ref = "simple-commons" }
#Other
android-gif-drawable = { module = "pl.droidsonroids.gif:android-gif-drawable", version.ref = "androidGifDrawable" }
android-image-cropper = { module = "com.vanniktech:android-image-cropper", version.ref = "androidImageCropper" }
subsamplingscaleimageview = { module = "com.github.tibbi:subsampling-scale-image-view", version.ref = "subsamplingScaleImageView" }
androidsvg-aar = { module = "com.caverock:androidsvg-aar", version.ref = "androidsvgAar" }
gestureviews = { module = "com.github.tibbi:gestureviews", version.ref = "gestureviews" }
imagefilters = { module = "info.androidhive:imagefilters", version.ref = "imagefilters" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }
sanselan = { module = "org.apache.sanselan:sanselan", version.ref = "sanselan" }
sdk-videowidget = { module = "com.google.vr:sdk-videowidget", version.ref = "sdkVideowidget" }
sdk-panowidget = { module = "com.google.vr:sdk-panowidget", version.ref = "sdkPanowidget" }
apng = { module = "com.github.penfeizhou.android.animation:apng", version.ref = "apng" }
awebp = { module = "com.github.penfeizhou.android.animation:awebp", version.ref = "awebp" }
glide-compiler = { module = "com.github.bumptech.glide:compiler", version.ref = "glideCompiler" }
picasso = { module = "com.squareup.picasso:picasso", version.ref = "picasso" }
[bundles]
room = [
"androidx-room-ktx",
"androidx-room-runtime",
]
[plugins]
android = { id = "com.android.application", version.ref = "gradlePlugins-agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
imgly = { id = "ly.img.android.sdk", version.ref = "imgly" }

View File

@ -1,3 +0,0 @@
include ':app'
//include ':commons'
//project(':commons').projectDir = new File('../Simple-Commons/commons')

20
settings.gradle.kts Normal file
View File

@ -0,0 +1,20 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
jcenter()
mavenCentral()
maven(url = "https://artifactory.img.ly/artifactory/imgly")
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
jcenter()
mavenCentral()
maven { setUrl("https://jitpack.io") }
maven(url = "https://artifactory.img.ly/artifactory/imgly")
}
}
include(":app")