Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Convert Groovy to Kotlin DSL (#79)
Browse files Browse the repository at this point in the history
* Convert Groovy to Kotlin DSL

* Format compose.versions.toml

* Use shared dependency and add a comment

Use shared dependency in BOM module

Add comment about BOM in sample module
  • Loading branch information
ghostbear authored Jan 21, 2022
1 parent 33cd589 commit 9aad0dd
Show file tree
Hide file tree
Showing 15 changed files with 448 additions and 365 deletions.
2 changes: 1 addition & 1 deletion bom/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies {
api(project(":permissions"))
api(project(":photopicker"))
api(project(":storage"))
api("com.squareup.okio:okio:3.0.0")
api(libs.okio)
}
}

Expand Down
81 changes: 0 additions & 81 deletions build.gradle

This file was deleted.

90 changes: 90 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import org.jetbrains.dokka.gradle.DokkaMultiModuleTask

/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

plugins {
id("com.diffplug.spotless") version "5.12.5"
id("org.jetbrains.dokka") version "1.4.32"
id("me.tylerbwong.gradle.metalava") version "0.1.9" apply false
id("com.vanniktech.maven.publish") version "0.18.0" apply false
id("org.jetbrains.kotlin.plugin.parcelize") version "1.4.32" apply false
}

allprojects {
// TODO: Remove ext section when filesystem and mediastore is removed
ext {
set("kotlin_version", "1.5.31")
set("compose_version", "1.0.5")
}
repositories {
google()
mavenCentral()
}
}

tasks.withType<DokkaMultiModuleTask>().configureEach {
outputDirectory.set(rootProject.file("docs/api"))
failOnWarning.set(true)
}

subprojects {
apply<com.diffplug.gradle.spotless.SpotlessPlugin>()
spotless {
kotlin {
target("**/*.kt")
ktlint("0.41.0")
licenseHeaderFile(rootProject.file("spotless/copyright.txt"))
}

groovyGradle {
target("**/*.gradle")
greclipse().configFile(rootProject.file("spotless/greclipse.properties"))
licenseHeaderFile(
rootProject.file("spotless/copyright.txt"),
"(buildscript|apply|import|plugins)"
)
}
}

if (project.hasProperty("POM_ARTIFACT_ID") && project.properties["POM_ARTIFACT_ID"] != "modernstorage-bom") {
apply<me.tylerbwong.gradle.metalava.plugin.MetalavaPlugin>()

metalava {
filename = "api/current.api"
reportLintsAsErrors = true
}
}
}

// Extension function due to metalava not having proper Kotlin DSL
fun Project.metalava(configure: Action<me.tylerbwong.gradle.metalava.extension.MetalavaExtension>): Unit =
(this as ExtensionAware).extensions.configure("metalava", configure)
11 changes: 11 additions & 0 deletions gradle/androidx.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[libraries]
corektx = { module = "androidx.core:core-ktx", version = "1.7.0" }
appcompat = { module = "androidx.appcompat:appcompat", version = "1.4.0" }
material = { module = "com.google.android.material:material", version = "1.4.0" }
lifecycleruntimektx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version = "2.4.0" }
junit = { module = "androidx.test.ext:junit", version = "1.1.3" }
junitktx = { module = "androidx.test.ext:junit-ktx", version = "1.1.3" }
espresso = { module = "androidx.test.espresso:espresso-core", version = "3.4.0" }
rules = { module = "androidx.test:rules", version = "1.4.0" }
uiautomator = { module = "androidx.test.uiautomator:uiautomator", version = "2.2.0" }
runner = { module = "androidx.test:runner", version = "1.4.0" }
12 changes: 12 additions & 0 deletions gradle/compose.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[versions]
current = "1.0.5"

[libraries]
ui = { module = "androidx.compose.ui:ui", version.ref = "current" }
material = { module = "androidx.compose.material:material", version.ref = "current" }
icons = { module = "androidx.compose.material:material-icons-extended", version.ref = "current" }
uitoolingpreview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "current" }
activity = { module = "androidx.activity:activity-compose", version = "1.4.0" }
navigation = { module = "androidx.navigation:navigation-compose", version = "2.4.0-rc01" }
uitooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "current" }
junit = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "current" }
12 changes: 12 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[versions]
kotlin = "1.5.31"

[libraries]
stdlib-jdk7 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk7", version.ref = "kotlin" }
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version = "1.5.2" }

okio = { module = "com.squareup.okio:okio", version = "3.0.0" }
glide = { module = "com.github.skydoves:landscapist-glide", version = "1.4.5" }

junit = { module = "junit:junit", version = "4.13.2" }
robolectric = { module = "org.robolectric:robolectric", version = "4.7.3" }
64 changes: 0 additions & 64 deletions permissions/build.gradle

This file was deleted.

69 changes: 69 additions & 0 deletions permissions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id("com.android.library")
kotlin("android")
id("org.jetbrains.dokka")
id("com.vanniktech.maven.publish")
}

android {
compileSdk = 31

defaultConfig {
minSdk = 21
targetSdk = 31

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}

testOptions {
unitTests {
isIncludeAndroidResources = true
}
}
}

dependencies {

implementation(androidx.corektx)
implementation(androidx.appcompat)
implementation(androidx.material)
testImplementation(libs.junit)
testImplementation(libs.robolectric)
androidTestImplementation(androidx.junit)
androidTestImplementation(androidx.junitktx)
}
Loading

0 comments on commit 9aad0dd

Please sign in to comment.