diff --git a/CHANGELOG.md b/CHANGELOG.md index 11b7c5a7..4270d39c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ parameters. - Example: - Removed sorting options by file size from `UploadFragment`. +- Project: + - Migrated Gradle builds from Groovy to Kotlin. ## 3.3.0 - Library: diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 1e3c1e45..00000000 --- a/build.gradle +++ /dev/null @@ -1,123 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - def versions = [:] - versions.kotlin_version = '1.9.10' - versions.kotlin_coroutines = '1.7.3' - versions.min_sdk = 22 - versions.target_sdk = 34 - versions.compile_sdk = 34 - versions.jdk = JavaVersion.VERSION_17 - - versions.gradle_version = '8.1.1' - - versions.androidx_core = "1.12.0" - versions.material = "1.9.0" - versions.navigation = "2.7.3" - versions.lifecycle = "2.6.2" - versions.constraintlayout = "2.1.4" - versions.annotation = '1.7.0' - versions.appcompat = "1.6.1" - versions.fragment = "1.6.1" - versions.work = "2.8.1" - versions.preference = "1.2.1" - - versions.okhttp = "4.11.0" - versions.retrofit = "2.9.0" - - versions.picasso = "2.71828" - - versions.moshi = "1.15.0" - - versions.junit = "4.13.2" - versions.test_runner = "1.5.2" - versions.espresso_core = "3.5.1" - - ext.versions = versions - - repositories { - maven { url "https://maven.google.com" } - google() - mavenCentral() - } - dependencies { - classpath "com.android.tools.build:gradle:$versions.gradle_version" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin_version" - classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$versions.navigation" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -plugins { - id 'base' - id 'signing' - id 'maven-publish' -} - -allprojects { - repositories { - mavenLocal() // look into local .m2 cache. - google() - mavenCentral() - } -} - -subprojects { - - // apply publishing plugins to all subprojects to global control of publishing repositories. - apply plugin: "base" - apply plugin: "signing" - apply plugin: "maven-publish" - - def isReleaseVersion = !version.toString().toLowerCase().endsWith("snapshot") - - tasks { - // Always run tests as part of the `build` task. - if(findByName("test")) { - named("check") { - dependOn(named("test")) - } - } - } - - // Setup global publishing repository settings. - signing { - useGpgCmd() - sign(publishing.publications) - } - - publishing { - repositories { - maven { - // Dynamically select either Maven Central or na Internal repository depending on the value of uploadcare.publish.type / UPLOADCARE_PUBLISH_TYPE - name = "selected" - - // Allow deploying to a custom repository (for testing purposes) - def publishInternally = project.findProperty("uploadcare.publish.type")?.toString() == "internal" - def repositoryUrl - - if (isReleaseVersion) { - def releaseMavenCentral = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - def releaseInternal = (project.findProperty("uploadcare.publish.internal.release") ?: System.getenv("UPLOADCARE_PUBLISH_INTERNAL_RELEASE") ?: "") as String - repositoryUrl = (releaseInternal != "" && publishInternally) ? releaseInternal: releaseMavenCentral - } else { - def snapshotMavenCentral = "https://oss.sonatype.org/content/repositories/snapshots/" - def snapshotInternal = (project.findProperty("uploadcare.publish.internal.snapshot") ?: System.getenv("UPLOADCARE_PUBLISH_INTERNAL_SNAPSHOT") ?: "") as String - repositoryUrl = (snapshotInternal != "" && publishInternally) ? snapshotInternal : snapshotMavenCentral - } - - url = uri(repositoryUrl) - - credentials { - def mavenCentralUser = (project.findProperty("uploadcare.publish.sonatype.user") ?: System.getenv("UPLOADCARE_PUBLISH_SONATYPE_USER") ?: "") as String - def mavenCentralPass = (project.findProperty("uploadcare.publish.sonatype.pass") ?: System.getenv("UPLOADCARE_PUBLISH_SONATYPE_PASS") ?: "") as String - def internalUser = (project.findProperty("uploadcare.publish.internal.user") ?: System.getenv("UPLOADCARE_PUBLISH_INTERNAL_USER") ?: "") as String - def internalPass = (project.findProperty("uploadcare.publish.internal.pass") ?: System.getenv("UPLOADCARE_PUBLISH_INTERNAL_PASS") ?: "") as String - username = (publishInternally) ? internalUser : mavenCentralUser - password = (publishInternally) ? internalPass : mavenCentralPass - } - } - } - } -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..9432d8f1 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,87 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + maven(url = "https://maven.google.com") + google() + mavenCentral() + } + dependencies { + classpath(libs.gradle) + classpath(libs.kotlin.plugin) + classpath(libs.navigation.safe.args.plugin) + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +plugins { + id("base") + id("signing") + id("maven-publish") +} + +allprojects { + repositories { + mavenLocal() // look into local .m2 cache. + google() + mavenCentral() + } +} + +subprojects { + + // apply publishing plugins to all subprojects to global control of publishing repositories. + apply(plugin = "base") + apply(plugin = "signing") + apply(plugin = "maven-publish") + + val isReleaseVersion = !version.toString().lowercase().endsWith("snapshot") + + tasks { + // Always run tests as part of the `build` task. + findByName("test")?.apply { + named("check") { + dependsOn(named("test")) + } + } + } + + // Setup global publishing repository settings. + signing { + useGpgCmd() + sign(publishing.publications) + } + + publishing { + repositories { + maven { + // Dynamically select either Maven Central or na Internal repository depending on the value of uploadcare.publish.type / UPLOADCARE_PUBLISH_TYPE + name = "selected" + + // Allow deploying to a custom repository (for testing purposes) + val publishInternally = project.findProperty("uploadcare.publish.type")?.toString() == "internal" + val repositoryUrl = if (isReleaseVersion) { + val releaseMavenCentral = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + val releaseInternal = (project.findProperty("uploadcare.publish.internal.release") ?: System.getenv("UPLOADCARE_PUBLISH_INTERNAL_RELEASE") ?: "") as String + if (releaseInternal != "" && publishInternally) releaseInternal else releaseMavenCentral + } else { + val snapshotMavenCentral = "https://oss.sonatype.org/content/repositories/snapshots/" + val snapshotInternal = (project.findProperty("uploadcare.publish.internal.snapshot") ?: System.getenv("UPLOADCARE_PUBLISH_INTERNAL_SNAPSHOT") ?: "") as String + if (snapshotInternal != "" && publishInternally) snapshotInternal else snapshotMavenCentral + } + + url = uri(repositoryUrl) + + credentials { + val mavenCentralUser = (project.findProperty("uploadcare.publish.sonatype.user") ?: System.getenv("UPLOADCARE_PUBLISH_SONATYPE_USER") ?: "") as String + val mavenCentralPass = (project.findProperty("uploadcare.publish.sonatype.pass") ?: System.getenv("UPLOADCARE_PUBLISH_SONATYPE_PASS") ?: "") as String + val internalUser = (project.findProperty("uploadcare.publish.internal.user") ?: System.getenv("UPLOADCARE_PUBLISH_INTERNAL_USER") ?: "") as String + val internalPass = (project.findProperty("uploadcare.publish.internal.pass") ?: System.getenv("UPLOADCARE_PUBLISH_INTERNAL_PASS") ?: "") as String + username = if (publishInternally) internalUser else mavenCentralUser + password = if (publishInternally) internalPass else mavenCentralPass + } + } + } + } +} diff --git a/example/build.gradle b/example/build.gradle deleted file mode 100644 index e22b85a6..00000000 --- a/example/build.gradle +++ /dev/null @@ -1,75 +0,0 @@ -plugins { - id 'com.android.application' - id 'kotlin-android' - id 'kotlin-parcelize' - id 'kotlin-kapt' - id "androidx.navigation.safeargs.kotlin" -} - -android { - compileSdkVersion versions.compile_sdk - namespace "com.uploadcare.android.example" - - defaultConfig { - applicationId "com.uploadcare.android.example" - minSdkVersion versions.min_sdk - targetSdkVersion versions.target_sdk - versionCode 10 - versionName "${version}" - } - - buildFeatures { - dataBinding = true - } - - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - packagingOptions { - exclude 'META-INF/NOTICE' - exclude 'META-INF/LICENSE' - } - - lintOptions { - abortOnError false - } - - compileOptions { - sourceCompatibility versions.jdk - targetCompatibility versions.jdk - } - - kotlinOptions { - jvmTarget = versions.jdk - } -} - -dependencies { - implementation project (':widget') - implementation project (':library') - - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin_version" - implementation "org.jetbrains.kotlin:kotlin-reflect:$versions.kotlin_version" - - implementation "androidx.core:core-ktx:$versions.androidx_core" - - implementation "androidx.navigation:navigation-fragment-ktx:$versions.navigation" - implementation "androidx.navigation:navigation-ui-ktx:$versions.navigation" - - implementation "androidx.fragment:fragment-ktx:$versions.fragment" - implementation "androidx.appcompat:appcompat:$versions.appcompat" - implementation "com.google.android.material:material:$versions.material" - implementation "androidx.constraintlayout:constraintlayout:$versions.constraintlayout" - - implementation "androidx.lifecycle:lifecycle-common-java8:$versions.lifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$versions.lifecycle" - - implementation "com.squareup.picasso:picasso:$versions.picasso" - - androidTestImplementation "androidx.test:runner:$versions.test_runner" - androidTestImplementation "androidx.test.espresso:espresso-core:$versions.espresso_core" -} diff --git a/example/build.gradle.kts b/example/build.gradle.kts new file mode 100644 index 00000000..7b8993db --- /dev/null +++ b/example/build.gradle.kts @@ -0,0 +1,78 @@ +plugins { + id("com.android.application") + id("kotlin-android") + id("kotlin-parcelize") + id("kotlin-kapt") + id("androidx.navigation.safeargs.kotlin") +} + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + namespace = "com.uploadcare.android.example" + + defaultConfig { + applicationId = "com.uploadcare.android.example" + minSdkPreview = libs.versions.minSdk.get() + targetSdkPreview = libs.versions.targetSdk.get() + versionCode = 10 + versionName = libs.versions.appVersion.get() + } + + buildFeatures { + dataBinding = true + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + packaging { + resources { + excludes += "META-INF/NOTICE" + excludes += "META-INF/LICENSE" + } + } + + lint { + abortOnError = false + } + + compileOptions { + val javaVersion = JavaVersion.toVersion(libs.versions.jdk.get()) + sourceCompatibility(javaVersion) + targetCompatibility(javaVersion) + } + + kotlinOptions { + jvmTarget = libs.versions.jdk.get() + } +} + +dependencies { + implementation(project(":widget")) + implementation(project(":library")) + + implementation(libs.kotlin.stdlib) + implementation(libs.kotlin.reflect) + + implementation (libs.androidx.core) + + implementation (libs.navigation.fragment) + implementation (libs.navigation.ui) + + implementation (libs.fragment.ktx) + implementation (libs.appcompat) + implementation (libs.material) + implementation (libs.constraintlayout) + + implementation (libs.lifecycle.common) + implementation (libs.lifecycle.viewmodel) + + implementation(libs.picasso) + + androidTestImplementation (libs.test.runner) + androidTestImplementation (libs.test.espresso.core) +} diff --git a/example/proguard-rules.pro b/example/proguard-rules.pro index 8f1b0f49..137bfc5f 100644 --- a/example/proguard-rules.pro +++ b/example/proguard-rules.pro @@ -2,7 +2,7 @@ # By default, the flags in this file are appended to flags specified # in /sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. +# directive in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..8465033a --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,70 @@ +[versions] +appVersion = "3.3.0" +kotlinVersion = "1.9.10" +kotlinCoroutines = "1.7.3" +minSdk = "22" +targetSdk = "34" +compileSdk = "34" +jdk = "17" +gradleVersion = "8.1.1" +androidxCore = "1.12.0" +material = "1.9.0" +navigation = "2.7.3" +lifecycle = "2.6.2" +constraintLayout = "2.1.4" +annotation = "1.7.0" +appcompat = "1.6.1" +fragment = "1.6.1" +work = "2.8.1" +preference = "1.2.1" +okhttp = "4.11.0" +retrofit = "2.9.0" +picasso = "2.71828" +moshi = "1.15.0" +junit = "4.13.2" +testRunner = "1.5.2" +espressoCore = "3.5.1" + +[libraries] +gradle = { group = "com.android.tools.build", name = "gradle", version.ref = "gradleVersion" } +kotlin-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlinVersion" } +navigation-safe-args-plugin = { group = "androidx.navigation", name = "navigation-safe-args-gradle-plugin", version.ref = "navigation" } + +kotlin-stdlib = { group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version.ref = "kotlinVersion" } +kotlin-reflect = { group = "org.jetbrains.kotlin", name = "kotlin-reflect", version.ref = "kotlinVersion" } +kotlin-coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "kotlinCoroutines" } +kotlin-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "kotlinCoroutines" } + +annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" } +androidx-core = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" } +navigation-fragment = { group = "androidx.navigation", name = "navigation-fragment-ktx", version.ref = "navigation" } +navigation-ui = { group = "androidx.navigation", name = "navigation-ui-ktx", version.ref = "navigation" } +fragment-ktx = { group = "androidx.fragment", name = "fragment-ktx", version.ref = "fragment" } +appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } +constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintLayout" } +lifecycle-common = { group = "androidx.lifecycle", name = "lifecycle-common-java8", version.ref = "lifecycle" } +lifecycle-viewmodel = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycle" } + +material = { group = "com.google.android.material", name = "material", version.ref = "material" } + +picasso = { group = "com.squareup.picasso", name = "picasso", version.ref = "picasso" } + +retrofit-retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } +retrofit-converter-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "retrofit" } + +moshi-moshi = { group = "com.squareup.moshi", name = "moshi", version.ref = "moshi" } +moshi-adapters = { group = "com.squareup.moshi", name = "moshi-adapters", version.ref = "moshi" } +moshi-kotlin = { group = "com.squareup.moshi", name = "moshi-kotlin", version.ref = "moshi" } + +okhttp-okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" } +okhttp-logging-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "okhttp" } +okhttp-mockwebserver = { group = "com.squareup.okhttp3", name = "mockwebserver", version.ref = "okhttp" } + +work-runtime = { module = "androidx.work:work-runtime-ktx", version.ref = "work" } +work-gcm = { module = "androidx.work:work-gcm", version.ref = "work" } + +preference-ktx = { module = "androidx.preference:preference-ktx", version.ref = "preference" } + +test-runner = { group = "androidx.test", name = "runner", version.ref = "testRunner" } +test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } +test-junit = { group = "junit", name = "junit", version.ref = "junit" } diff --git a/library/build.gradle b/library/build.gradle.kts similarity index 51% rename from library/build.gradle rename to library/build.gradle.kts index d17b4be3..c1c5d9b1 100644 --- a/library/build.gradle +++ b/library/build.gradle.kts @@ -1,70 +1,70 @@ plugins { - id 'com.android.library' - id 'kotlin-android' - id 'kotlin-parcelize' - id 'kotlin-kapt' - id 'maven-publish' + id("com.android.library") + id("kotlin-android") + id("kotlin-parcelize") + id("kotlin-kapt") + id("maven-publish") } group = "com.uploadcare.android.library" android { - compileSdkVersion versions.compile_sdk - namespace "com.uploadcare.android.library" + compileSdk = libs.versions.compileSdk.get().toInt() + namespace = "com.uploadcare.android.library" defaultConfig { - minSdkVersion versions.min_sdk - targetSdkVersion versions.target_sdk - versionCode 14 - versionName "${version}" - buildConfigField 'String', 'VERSION_NAME', "\"${version}\"" + minSdkPreview = libs.versions.minSdk.get() + buildConfigField("String", "VERSION_NAME", "\"${libs.versions.appVersion.get()}\"") } buildTypes { release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") } } - packagingOptions { - exclude 'META-INF/LICENSE' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/NOTICE' - exclude 'META-INF/NOTICE.txt' - exclude 'META-INF/DEPENDENCIES' + packaging { + resources { + excludes += "META-INF/LICENSE" + excludes += "META-INF/LICENSE.txt" + excludes += "META-INF/NOTICE" + excludes += "META-INF/NOTICE.txt" + excludes += "META-INF/DEPENDENCIES" + } } buildFeatures { buildConfig = true } - lintOptions { - abortOnError false + lint { + abortOnError = false } compileOptions { - sourceCompatibility versions.jdk - targetCompatibility versions.jdk + val javaVersion = JavaVersion.toVersion(libs.versions.jdk.get()) + sourceCompatibility(javaVersion) + targetCompatibility(javaVersion) } kotlinOptions { - jvmTarget = versions.jdk + jvmTarget = libs.versions.jdk.get() } } dependencies { - testImplementation "junit:junit:$versions.junit" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin_version" - implementation "org.jetbrains.kotlin:kotlin-reflect:$versions.kotlin_version" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.kotlin_coroutines" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.kotlin_coroutines" - implementation "com.squareup.moshi:moshi:$versions.moshi" - implementation "com.squareup.moshi:moshi-adapters:$versions.moshi" - implementation "com.squareup.moshi:moshi-kotlin:$versions.moshi" - implementation "androidx.annotation:annotation:$versions.annotation" - implementation "com.squareup.okhttp3:okhttp:$versions.okhttp" - implementation "com.squareup.okhttp3:logging-interceptor:$versions.okhttp" - testImplementation "com.squareup.okhttp3:mockwebserver:$versions.okhttp" + testImplementation(libs.test.junit) + implementation(libs.kotlin.stdlib) + implementation(libs.kotlin.reflect) + implementation(libs.kotlin.coroutines.android) + implementation(libs.kotlin.coroutines.core) + implementation(libs.moshi.moshi) + implementation(libs.moshi.adapters) + implementation(libs.moshi.kotlin) + implementation(libs.annotation) + implementation(libs.okhttp.okhttp) + implementation(libs.okhttp.logging.interceptor) + testImplementation(libs.okhttp.mockwebserver) } // Make sure unit tests always run when we are building the code. @@ -75,12 +75,12 @@ tasks.named("build") { afterEvaluate { publishing { publications { - release(MavenPublication) { + create("release") { from(components["release"]) - groupId = project.group + groupId = project.group.toString() artifactId = "uploadcare-android" - version = project.version + version = libs.versions.appVersion.get() //withBuildIdentifier(), available in newer gradle versions. diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro index 8f1b0f49..137bfc5f 100644 --- a/library/proguard-rules.pro +++ b/library/proguard-rules.pro @@ -2,7 +2,7 @@ # By default, the flags in this file are appended to flags specified # in /sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. +# directive in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index a6fe3a61..00000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':example', ':library', ':widget' \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..2bd6db84 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +include(":example", ":library", ":widget") diff --git a/widget/build.gradle b/widget/build.gradle deleted file mode 100644 index 930fd049..00000000 --- a/widget/build.gradle +++ /dev/null @@ -1,159 +0,0 @@ -plugins { - id 'com.android.library' - id 'kotlin-android' - id 'kotlin-parcelize' - id 'kotlin-kapt' - id "androidx.navigation.safeargs.kotlin" - id 'maven-publish' -} - -group = "com.uploadcare.android.widget" - -android { - - compileSdkVersion versions.compile_sdk - namespace "com.uploadcare.android.widget" - - defaultConfig { - minSdkVersion versions.min_sdk - targetSdkVersion versions.target_sdk - versionCode 13 - versionName "${version}" - } - - buildFeatures { - buildConfig = true - dataBinding = true - } - - buildTypes { - debug { - debuggable true - versionNameSuffix '-DEBUG' - buildConfigField "String", "SOCIAL_API_ENDPOINT", '"https://social.uploadcare.com/"' - } - release { - debuggable false - minifyEnabled false - buildConfigField "String", "SOCIAL_API_ENDPOINT", '"https://social.uploadcare.com/"' - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - - packagingOptions { - exclude 'META-INF/DEPENDENCIES.txt' - exclude 'META-INF/DEPENDENCIES' - exclude 'META-INF/dependencies.txt' - exclude 'META-INF/LICENSE.txt' - exclude 'META-INF/LICENSE' - exclude 'META-INF/license.txt' - exclude 'META-INF/LGPL2.1' - exclude 'META-INF/NOTICE.txt' - exclude 'META-INF/NOTICE' - exclude 'META-INF/notice.txt' - } - - lintOptions { - abortOnError false - } - - compileOptions { - sourceCompatibility versions.jdk - targetCompatibility versions.jdk - } - - kotlinOptions { - jvmTarget = versions.jdk - } -} - -dependencies { - implementation project (':library') - - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$versions.kotlin_version" - implementation "org.jetbrains.kotlin:kotlin-reflect:$versions.kotlin_version" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.kotlin_coroutines" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.kotlin_coroutines" - - implementation "androidx.core:core-ktx:$versions.androidx_core" - - implementation "androidx.navigation:navigation-fragment-ktx:$versions.navigation" - implementation "androidx.navigation:navigation-ui-ktx:$versions.navigation" - - implementation "androidx.fragment:fragment-ktx:$versions.fragment" - implementation "androidx.appcompat:appcompat:$versions.appcompat" - implementation "com.google.android.material:material:$versions.material" - implementation "androidx.constraintlayout:constraintlayout:$versions.constraintlayout" - implementation "androidx.preference:preference-ktx:$versions.preference" - - implementation "androidx.lifecycle:lifecycle-common-java8:$versions.lifecycle" - implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$versions.lifecycle" - - implementation "androidx.work:work-runtime-ktx:$versions.work" - implementation "androidx.work:work-gcm:$versions.work" - - implementation "com.squareup.moshi:moshi:$versions.moshi" - implementation "com.squareup.moshi:moshi-adapters:$versions.moshi" - implementation "com.squareup.moshi:moshi-kotlin:$versions.moshi" - - implementation "com.squareup.okhttp3:okhttp:$versions.okhttp" - implementation "com.squareup.okhttp3:logging-interceptor:$versions.okhttp" - testImplementation "com.squareup.okhttp3:mockwebserver:$versions.okhttp" - - implementation "com.squareup.retrofit2:retrofit:$versions.retrofit" - implementation "com.squareup.retrofit2:converter-moshi:$versions.retrofit" - - implementation "com.squareup.picasso:picasso:$versions.picasso" - - androidTestImplementation "androidx.test:runner:$versions.test_runner" - androidTestImplementation "androidx.test.espresso:espresso-core:$versions.espresso_core" -} - -// Make sure unit tests always run when we are building the code. -tasks.named("build") { - dependsOn(tasks.named("check")) -} - -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - from(components["release"]) - - groupId = project.group - artifactId = "uploadcare-android-widget" - version = project.version - - //withBuildIdentifier(), available in newer gradle versions. - - pom { - name.set("uploadcare-android-widget") - url.set("https://github.com/uploadcare/uploadcare-android") - description.set("Android widget for the Uploadcare API.") - issueManagement { - url.set("https://github.com/uploadcare/uploadcare-android/issues") - } - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - scm { - connection.set("scm:git:git://github.com/uploadcare/uploadcare-android.git") - developerConnection.set("scm:git:ssh://github.com/uploadcare/uploadcare-android.git") - url.set("https://github.com/uploadcare/uploadcare-android") - } - developers { - developer { - name.set("raphaelnew") - email.set("iraphaele@gmail.com") - organization.set("Uploadcare") - url.set("https://github.com/raphaelnew") - } - } - } - } - } - } -} diff --git a/widget/build.gradle.kts b/widget/build.gradle.kts new file mode 100644 index 00000000..fffe961a --- /dev/null +++ b/widget/build.gradle.kts @@ -0,0 +1,155 @@ +plugins { + id("com.android.library") + id("kotlin-android") + id("kotlin-parcelize") + id("kotlin-kapt") + id("androidx.navigation.safeargs.kotlin") + id("maven-publish") +} + +group = "com.uploadcare.android.widget" + +android { + compileSdk = libs.versions.compileSdk.get().toInt() + namespace = "com.uploadcare.android.widget" + + defaultConfig { + minSdkPreview = libs.versions.minSdk.get() + } + + buildFeatures { + buildConfig = true + dataBinding = true + } + + buildTypes { + debug { + buildConfigField("String", "SOCIAL_API_ENDPOINT", "\"https://social.uploadcare.com/\"") + } + release { + isMinifyEnabled = false + buildConfigField("String", "SOCIAL_API_ENDPOINT", "\"https://social.uploadcare.com/\"") + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + + packaging { + resources { + excludes += "META-INF/DEPENDENCIES.txt" + excludes += "META-INF/DEPENDENCIES" + excludes += "META-INF/dependencies.txt" + excludes += "META-INF/LICENSE.txt" + excludes += "META-INF/LICENSE" + excludes += "META-INF/license.txt" + excludes += "META-INF/LGPL2.1" + excludes += "META-INF/NOTICE.txt" + excludes += "META-INF/NOTICE" + excludes += "META-INF/notice.txt" + } + } + + lint { + abortOnError = false + } + + compileOptions { + val javaVersion = JavaVersion.toVersion(libs.versions.jdk.get()) + sourceCompatibility(javaVersion) + targetCompatibility(javaVersion) + } + + kotlinOptions { + jvmTarget = libs.versions.jdk.get() + } +} + +dependencies { + implementation(project(":library")) + + implementation(libs.kotlin.stdlib) + implementation(libs.kotlin.reflect) + implementation(libs.kotlin.coroutines.android) + implementation(libs.kotlin.coroutines.core) + + implementation(libs.androidx.core) + + implementation(libs.navigation.fragment) + implementation(libs.navigation.ui) + + implementation(libs.fragment.ktx) + implementation(libs.appcompat) + implementation(libs.material) + implementation(libs.constraintlayout) + implementation(libs.preference.ktx) + + implementation(libs.lifecycle.common) + implementation(libs.lifecycle.viewmodel) + + implementation(libs.work.runtime) + implementation(libs.work.gcm) + + implementation(libs.moshi.moshi) + implementation(libs.moshi.adapters) + implementation(libs.moshi.kotlin) + + implementation(libs.okhttp.okhttp) + implementation(libs.okhttp.logging.interceptor) + testImplementation(libs.okhttp.mockwebserver) + + implementation(libs.retrofit.retrofit) + implementation(libs.retrofit.converter.moshi) + + implementation(libs.picasso) + + androidTestImplementation(libs.test.runner) + androidTestImplementation(libs.test.espresso.core) +} + +// Make sure unit tests always run when we are building the code. +tasks.named("build") { + dependsOn(tasks.named("check")) +} + +afterEvaluate { + publishing { + publications { + create("release") { + from(components["release"]) + + groupId = project.group.toString() + artifactId = "uploadcare-android-widget" + version = libs.versions.appVersion.get() + + //withBuildIdentifier(), available in newer gradle versions. + + pom { + name.set("uploadcare-android-widget") + url.set("https://github.com/uploadcare/uploadcare-android") + description.set("Android widget for the Uploadcare API.") + issueManagement { + url.set("https://github.com/uploadcare/uploadcare-android/issues") + } + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + scm { + connection.set("scm:git:git://github.com/uploadcare/uploadcare-android.git") + developerConnection.set("scm:git:ssh://github.com/uploadcare/uploadcare-android.git") + url.set("https://github.com/uploadcare/uploadcare-android") + } + developers { + developer { + name.set("raphaelnew") + email.set("iraphaele@gmail.com") + organization.set("Uploadcare") + url.set("https://github.com/raphaelnew") + } + } + } + } + } + } +} diff --git a/widget/proguard-rules.pro b/widget/proguard-rules.pro index 8f1b0f49..137bfc5f 100644 --- a/widget/proguard-rules.pro +++ b/widget/proguard-rules.pro @@ -2,7 +2,7 @@ # By default, the flags in this file are appended to flags specified # in /sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. +# directive in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html