Skip to content
Permalink
Browse files

Merge pull request #6 from jmfayard/development

 README: Why? What? How?
  • Loading branch information...
jmfayard committed Oct 16, 2018
2 parents 950b930 + fb674ac commit 81fe0c7694aa6e19eac95d1cdadf8415e86f7346
Showing with 323 additions and 25 deletions.
  1. +65 −21 README.md
  2. +51 −0 doc/Libs.kt
  3. +61 −0 doc/Versions.kt
  4. +138 −0 doc/report.json
  5. +8 −4 src/main/kotlin/jmfayard/github/io/KotlinPoetry.kt
@@ -1,51 +1,91 @@
# gradle-kotlin-dsl-libs
## gradle-kotlin-dsl-libs: painless dependencies management


Pain-less gradle dependencies management with the kotlin-dsl
# Why?

Blog article
---
Managing dependencies is a boring, painful part of a programmer's life.

https://blog.kotlin-academy.com/gradle-kotlin-1-7528a85f0d2c
To qualify as truly painless, my ideal dependency management system would have to

Screencast
---
- ✅ not make me work with magic strings
- ✅ allow me to reuse the dependencies information across modules
- ✅ have good IDE support (auto-completion, jumping to the definition, quick documentation, ...)
- ✅ provide a helpful link to the website so that I can quickly look-up what this thing does, where the documentation is, what the CHANGELOG says, ...
- ✅ inform me what newer versions of that dependency are available
- ✅ do all of the above automatically
- ✅ allow me to easily update the dependency version manually
- ✅ never do that automatically

https://github.com/jmfayard/gradle-kotlin-dsl-libs
We all have tried different iterations to make working with dependencies better.

`gradle-kotlin-dsl-libs` is my attempt at checking **all** those checkboxes.

Step 0:
---
# What?

Use either your own project or this sample repository
`gradle-kotlin-dsl-libs` is a Gradle plugin that you add to your builds.

It extends the [gradle-versions-plugin](https://github.com/ben-manes/gradle-versions-plugin) that produce a [report.json file with information about all your dependencies](doc/report.json)

It then automatically generates two Kotlin files that you can use in your build:

- [buildSrc/src/main/kotlin/Libs.kt](doc/Libs.kt)
- [buildSrc/src/main/kotlin/Versions.kt](doc/Versions.kt)

The IDE integration comes by the virtue of the Kotlin support in Gradle and Android Studio & IntelliJ.

Screencast: https://www.useloom.com/share/7edceb83fd594f319356240fcce304d5


Blog article: [How Kotlin makes editing your Gradle build less frustrating](https://blog.kotlin-academy.com/gradle-kotlin-the-missing-piece-of-the-puzzle-7528a85f0d2c)


# How?

## Step 0


Use either your own project or this sample repository

`$ git clone` https://github.com/jmfayard/sample-synclibs



Step1: Edit build.gradle(.kts)
----
## Step 1: Apply the plugin

Edit your root `build.gradle(.kts)` file

```groovy
// ./build.gradle
// don't put anything before the buildscript and plugins blocks!
buildscript {
//...
}
plugins {
// https://plugins.gradle.org/plugin/jmfayard.github.io.gradle-kotlin-dsl-libs
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.4"
// Find latest version at https://plugins.gradle.org/plugin/jmfayard.github.io.gradle-kotlin-dsl-libs
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.4" // $ ./gradlew syncLibs
}
```


## Step 2: Generate the code

Step2
----

```
$ ./gradlew syncLibs
# give him time to find all the newer versions
$ find buildSrc -name "*.kt*"
buildSrc/build.gradle.kts
buildSrc/settings.gradle.kts
buildSrc/src/main/kotlin/Libs.kt
buildSrc/src/main/kotlin/Versions.kt
`$ ./gradlew syncLibs`
```

`$ cat ` [buildSrc/src/main/kotlin/Libs.kt](https://github.com/jmfayard/sample-synclibs/blob/0054d42685ca50638c2e05670426b30323d7f6a8/buildSrc/src/main/java/Libs.kt)
Repeat this step whenever you want to check if newer versions are available.

## Step 3: Use the generated code

Step3:
----

Replace your dependency strings with Libs.xxx

@@ -61,5 +101,9 @@ Enjoy the deep integration of gradle kotlin dsl with your IDE



## Step 4: Update your dependencies

You can run again anytime the `$ ./gradlew syncLibs` task

Edit then the file: `buildSrc/src/main/kotlin/Versions.kt`

@@ -0,0 +1,51 @@
import kotlin.String

/**
* Generated by [gradle-kotlin-dsl-libs](https://github.com/jmfayard/gradle-kotlin-dsl-libs)
*
* Run again
* `$ ./gradlew syncLibs`
* to update this file */
object Libs {
/**
* [gradle website](https://developer.android.com/studio) */
const val com_android_tools_build_gradle: String =
"com.android.tools.build:gradle:" + Versions.com_android_tools_build_gradle

/**
* [firebase-database website](https://github.com/b3er/RxFirebase2) */
const val com_github_b3er_rxfirebase_firebase_database: String =
"com.github.b3er.rxfirebase:firebase-database:" + Versions.com_github_b3er_rxfirebase_firebase_database

/**
* [compiler website](https://github.com/bumptech/glide) */
const val com_github_bumptech_glide_compiler: String =
"com.github.bumptech.glide:compiler:" + Versions.com_github_bumptech_glide_compiler

const val com_google_firebase_firebase_database: String =
"com.google.firebase:firebase-database:" + Versions.com_google_firebase_firebase_database

const val io_fabric_tools_gradle: String =
"io.fabric.tools:gradle:" + Versions.io_fabric_tools_gradle

const val jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin: String =
"jmfayard.github.io.gradle-kotlin-dsl-libs:jmfayard.github.io.gradle-kotlin-dsl-libs.gradle.plugin:" + Versions.jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin

/**
* [kotlin-scripting-compiler-embeddable website](https://kotlinlang.org/) */
const val kotlin_scripting_compiler_embeddable: String =
"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:" + Versions.kotlin_scripting_compiler_embeddable

const val krangl: String = "de.mpicbg.scicomp:krangl:" + Versions.krangl

/**
* [okio website](https://github.com/square/okio/) */
const val okio: String = "com.squareup.okio:okio:" + Versions.okio

const val org_jetbrains_kotlin_jvm_gradle_plugin: String =
"org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:" + Versions.org_jetbrains_kotlin_jvm_gradle_plugin

/**
* [rxjava website](https://github.com/ReactiveX/RxJava) */
const val rxjava: String = "io.reactivex.rxjava2:rxjava:" + Versions.rxjava
}
@@ -0,0 +1,61 @@
import kotlin.String

/**
* Generated by [gradle-kotlin-dsl-libs](https://github.com/jmfayard/gradle-kotlin-dsl-libs)
*
* Run again
* `$ ./gradlew syncLibs`
* to update this file */
object Versions {
/**
* [gradle website](https://developer.android.com/studio) */
const val com_android_tools_build_gradle: String =
"3.2.1" // available milestone: "3.3.0-alpha13"

/**
* [firebase-database website](https://github.com/b3er/RxFirebase2) */
const val com_github_b3er_rxfirebase_firebase_database: String = "11.2.0" // up-to-date

/**
* [compiler website](https://github.com/bumptech/glide) */
const val com_github_bumptech_glide_compiler: String = "4.8.0" // up-to-date

const val com_google_firebase_firebase_database: String =
"12.0.0" // available milestone: "16.0.3"

const val io_fabric_tools_gradle: String = "1.26.1" // up-to-date

const val jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin: String =
"0.2.4" // up-to-date

/**
* [kotlin-scripting-compiler-embeddable website](https://kotlinlang.org/) */
const val kotlin_scripting_compiler_embeddable: String = "1.2.71" // up-to-date

const val krangl: String = "0.10.3" // up-to-date

/**
* [okio website](https://github.com/square/okio/) */
const val okio: String = "2.0.0" // available milestone: "2.1.0"

const val org_jetbrains_kotlin_jvm_gradle_plugin: String = "1.2.71" // up-to-date

/**
* [rxjava website](https://github.com/ReactiveX/RxJava) */
const val rxjava: String = "2.2.0" // available milestone: "2.2.2"

/**
*
* To update Gradle, edit the wrapper file at path:
* ./gradle/wrapper/gradle-wrapper.properties
*/
object Gradle {
const val runningVersion: String = "4.10.2"

const val currentVersion: String = "4.10.2"

const val nightlyVersion: String = "5.1-20181015235836+0000"

const val releaseCandidate: String = ""
}
}
@@ -0,0 +1,138 @@
{
"current": {
"dependencies": [
{
"group": "com.github.b3er.rxfirebase",
"version": "11.2.0",
"projectUrl": "https://github.com/b3er/RxFirebase2",
"name": "firebase-database"
},
{
"group": "com.github.bumptech.glide",
"version": "4.8.0",
"projectUrl": "https://github.com/bumptech/glide",
"name": "compiler"
},
{
"group": "de.mpicbg.scicomp",
"version": "0.10.3",
"projectUrl": null,
"name": "krangl"
},
{
"group": "io.fabric.tools",
"version": "1.26.1",
"projectUrl": null,
"name": "gradle"
},
{
"group": "jmfayard.github.io.gradle-kotlin-dsl-libs",
"version": "0.2.4",
"projectUrl": null,
"name": "jmfayard.github.io.gradle-kotlin-dsl-libs.gradle.plugin"
},
{
"group": "org.jetbrains.kotlin",
"version": "1.2.71",
"projectUrl": "https://kotlinlang.org/",
"name": "kotlin-scripting-compiler-embeddable"
},
{
"group": "org.jetbrains.kotlin.jvm",
"version": "1.2.71",
"projectUrl": null,
"name": "org.jetbrains.kotlin.jvm.gradle.plugin"
}
],
"count": 7
},
"gradle": {
"current": {
"version": "4.10.2",
"reason": "",
"isUpdateAvailable": false,
"isFailure": false
},
"nightly": {
"version": "5.1-20181015235836+0000",
"reason": "",
"isUpdateAvailable": true,
"isFailure": false
},
"enabled": true,
"releaseCandidate": {
"version": "",
"reason": "update check succeeded: no release available",
"isUpdateAvailable": false,
"isFailure": false
},
"running": {
"version": "4.10.2",
"reason": "",
"isUpdateAvailable": false,
"isFailure": false
}
},
"exceeded": {
"dependencies": [

],
"count": 0
},
"outdated": {
"dependencies": [
{
"group": "com.android.tools.build",
"available": {
"release": null,
"milestone": "3.3.0-alpha13",
"integration": null
},
"version": "3.2.1",
"projectUrl": "https://developer.android.com/studio",
"name": "gradle"
},
{
"group": "com.google.firebase",
"available": {
"release": null,
"milestone": "16.0.3",
"integration": null
},
"version": "12.0.0",
"projectUrl": null,
"name": "firebase-database"
},
{
"group": "com.squareup.okio",
"available": {
"release": null,
"milestone": "2.1.0",
"integration": null
},
"version": "2.0.0",
"projectUrl": "https://github.com/square/okio/",
"name": "okio"
},
{
"group": "io.reactivex.rxjava2",
"available": {
"release": null,
"milestone": "2.2.2",
"integration": null
},
"version": "2.2.0",
"projectUrl": "https://github.com/ReactiveX/RxJava",
"name": "rxjava"
}
],
"count": 4
},
"unresolved": {
"dependencies": [

],
"count": 0
},
"count": 11
}

0 comments on commit 81fe0c7

Please sign in to comment.
You can’t perform that action at this time.