Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Migrate to Kotlin Gradle DSL #16

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ buildscript {
classpath deps.plugins.android
}
}

plugins {
id("de.fayard.buildSrcVersions") version "0.4.2"
}

apply from: "$rootDir/gradle/dependencies.gradle"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually this line should be deleted


allprojects {
Expand Down
2 changes: 2 additions & 0 deletions buildSrc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.gradle/
build/
7 changes: 7 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repositories {
jcenter()
}

plugins {
`kotlin-dsl`
}
173 changes: 173 additions & 0 deletions buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
import kotlin.String

/**
* Generated by https://github.com/jmfayard/buildSrcVersions
*
* Update this file with
* `$ ./gradlew buildSrcVersions`
*/
object Libs {
/**
* http://developer.android.com/tools/extras/support-library.html
*/
const val appcompat: String = "androidx.appcompat:appcompat:" + Versions.appcompat

/**
* https://developer.android.com/testing
*/
const val espresso_core: String = "androidx.test.espresso:espresso-core:" + Versions.espresso_core
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm new to Kotlin Gradle DSL. is it convention to use snakecase? or just whatever you'd like?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure what the convention is for Kotlin Gradle DSL, but I can't imagine it should stray too far from Kotlin conventions. In either case, this is auto-generated code that shouldn't be edited. All hand written code should strictly follow Kotlin coding conventions.


/**
* https://developer.android.com/testing
*/
const val androidx_test_runner: String = "androidx.test:runner:" + Versions.androidx_test_runner

/**
* https://github.com/robstoll/atrium
*/
const val atrium_cc_en_gb_robstoll_common: String =
"ch.tutteli.atrium:atrium-cc-en_GB-robstoll-common:" + Versions.ch_tutteli_atrium

/**
* https://github.com/robstoll/atrium
*/
const val atrium_cc_en_gb_robstoll: String = "ch.tutteli.atrium:atrium-cc-en_GB-robstoll:" +
Versions.ch_tutteli_atrium

/**
* https://developer.android.com/studio
*/
const val aapt2: String = "com.android.tools.build:aapt2:" + Versions.aapt2

/**
* https://developer.android.com/studio
*/
const val com_android_tools_build_gradle: String = "com.android.tools.build:gradle:" +
Versions.com_android_tools_build_gradle

/**
* https://developer.android.com/studio
*/
const val lint_gradle: String = "com.android.tools.lint:lint-gradle:" + Versions.lint_gradle

const val de_fayard_buildsrcversions_gradle_plugin: String =
"de.fayard.buildSrcVersions:de.fayard.buildSrcVersions.gradle.plugin:" +
Versions.de_fayard_buildsrcversions_gradle_plugin

/**
* http://mockk.io
*/
const val mockk_common: String = "io.mockk:mockk-common:" + Versions.io_mockk

/**
* http://mockk.io
*/
const val mockk: String = "io.mockk:mockk:" + Versions.io_mockk

/**
* http://junit.org
*/
const val junit: String = "junit:junit:" + Versions.junit

const val dokka_gradle_plugin: String = "org.jetbrains.dokka:dokka-gradle-plugin:" +
Versions.dokka_gradle_plugin

/**
* https://kotlinlang.org/
*/
const val kotlin_android_extensions_runtime: String =
"org.jetbrains.kotlin:kotlin-android-extensions-runtime:" + Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_android_extensions: String = "org.jetbrains.kotlin:kotlin-android-extensions:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_annotation_processing_gradle: String =
"org.jetbrains.kotlin:kotlin-annotation-processing-gradle:" + Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_gradle_plugin: String = "org.jetbrains.kotlin:kotlin-gradle-plugin:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_reflect: String = "org.jetbrains.kotlin:kotlin-reflect:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_scripting_compiler_embeddable: String =
"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:" + Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_stdlib_common: String = "org.jetbrains.kotlin:kotlin-stdlib-common:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_stdlib_jdk8: String = "org.jetbrains.kotlin:kotlin-stdlib-jdk8:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_stdlib_js: String = "org.jetbrains.kotlin:kotlin-stdlib-js:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_stdlib: String = "org.jetbrains.kotlin:kotlin-stdlib:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_test_annotations_common: String =
"org.jetbrains.kotlin:kotlin-test-annotations-common:" + Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_test_common: String = "org.jetbrains.kotlin:kotlin-test-common:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_test_js: String = "org.jetbrains.kotlin:kotlin-test-js:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_test_junit: String = "org.jetbrains.kotlin:kotlin-test-junit:" +
Versions.org_jetbrains_kotlin

/**
* https://kotlinlang.org/
*/
const val kotlin_test: String = "org.jetbrains.kotlin:kotlin-test:" +
Versions.org_jetbrains_kotlin

const val spek_dsl_jvm: String = "org.spekframework.spek2:spek-dsl-jvm:" +
Versions.org_spekframework_spek2

const val spek_dsl_metadata: String = "org.spekframework.spek2:spek-dsl-metadata:" +
Versions.org_spekframework_spek2

const val spek_runner_junit5: String = "org.spekframework.spek2:spek-runner-junit5:" +
Versions.org_spekframework_spek2
}
58 changes: 58 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import kotlin.String
import org.gradle.plugin.use.PluginDependenciesSpec
import org.gradle.plugin.use.PluginDependencySpec

/**
* Generated by https://github.com/jmfayard/buildSrcVersions
*
* Find which updates are available by running
* `$ ./gradlew buildSrcVersions`
* This will only update the comments.
*
* YOU are responsible for updating manually the dependency version.
*/
object Versions {
const val appcompat: String = "1.1.0-rc01"

const val espresso_core: String = "3.2.0"

const val androidx_test_runner: String = "1.2.0"

const val ch_tutteli_atrium: String = "0.8.0"

const val aapt2: String = "3.5.0-5435860"

const val com_android_tools_build_gradle: String = "3.5.0"

const val lint_gradle: String = "26.5.0"

const val de_fayard_buildsrcversions_gradle_plugin: String = "0.4.2"

const val io_mockk: String = "1.9.3"

const val junit: String = "4.12"

const val dokka_gradle_plugin: String = "0.9.17" // available: "0.9.18"

const val org_jetbrains_kotlin: String = "1.3.50"

const val org_spekframework_spek2: String = "2.1.0-alpha.0.11+d97ef33"
// available: "2.1.0-alpha.0.24+0fdeb6e"

/**
*
* See issue 19: How to update Gradle itself?
* https://github.com/jmfayard/buildSrcVersions/issues/19
*/
const val gradleLatestVersion: String = "5.6.1"

const val gradleCurrentVersion: String = "5.6.1"
}

/**
* See issue #47: how to update buildSrcVersions itself
* https://github.com/jmfayard/buildSrcVersions/issues/47
*/
val PluginDependenciesSpec.buildSrcVersions: PluginDependencySpec
inline get() =
id("de.fayard.buildSrcVersions").version(Versions.de_fayard_buildsrcversions_gradle_plugin)
51 changes: 0 additions & 51 deletions examples/counter/android/build.gradle

This file was deleted.

44 changes: 44 additions & 0 deletions examples/counter/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id("com.android.application")
kotlin("android")
kotlin("android.extensions")
kotlin("kapt")
}

android {
compileSdkVersion(29)
defaultConfig {
applicationId = "org.reduxkotlin.example.counter"
minSdkVersion(26)
targetSdkVersion(29)
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
getByName("debug") {
// MPP libraries don't currently get this resolution automatically
matchingFallbacks = listOf("release")
}
}
packagingOptions {
exclude("META-INF/*.kotlin_module")
}
}


dependencies {
implementation(Libs.kotlin_stdlib_jdk8)
implementation(Libs.appcompat)

implementation(project(":examples:counter:common"))
implementation(project(":lib"))
}
10 changes: 6 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ pluginManagement {
}
}

include ':lib', ':examples:counter:common', ':examples:counter:android'
rootProject.name='Redux-Kotlin'
include(
':lib',
':examples:counter:common',
':examples:counter:android'
)

rootProject.name = 'Redux-Kotlin'

rootProject.name = 'test'
enableFeaturePreview('GRADLE_METADATA')
enableFeaturePreview('STABLE_PUBLISHING')