Skip to content

Commit

Permalink
Migrate Gradle builds from Groovy to Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
CheK539 committed Oct 9, 2023
1 parent 850b789 commit 63316c9
Show file tree
Hide file tree
Showing 14 changed files with 436 additions and 401 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
123 changes: 0 additions & 123 deletions build.gradle

This file was deleted.

87 changes: 87 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
}
75 changes: 0 additions & 75 deletions example/build.gradle

This file was deleted.

78 changes: 78 additions & 0 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion example/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 63316c9

Please sign in to comment.