Skip to content

Commit 81fe0c7

Browse files
authored
Merge pull request #6 from jmfayard/development
README: Why? What? How?
2 parents 950b930 + fb674ac commit 81fe0c7

File tree

5 files changed

+323
-25
lines changed

5 files changed

+323
-25
lines changed

README.md

Lines changed: 65 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,91 @@
1-
# gradle-kotlin-dsl-libs
1+
## gradle-kotlin-dsl-libs: painless dependencies management
22

33

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

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

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

11-
Screencast
12-
---
10+
- ✅ not make me work with magic strings
11+
- ✅ allow me to reuse the dependencies information across modules
12+
- ✅ have good IDE support (auto-completion, jumping to the definition, quick documentation, ...)
13+
- ✅ 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, ...
14+
- ✅ inform me what newer versions of that dependency are available
15+
- ✅ do all of the above automatically
16+
- ✅ allow me to easily update the dependency version manually
17+
- ✅ never do that automatically
1318

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

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

17-
Step 0:
18-
---
23+
# What?
1924

20-
Use either your own project or this sample repository
25+
`gradle-kotlin-dsl-libs` is a Gradle plugin that you add to your builds.
26+
27+
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)
28+
29+
It then automatically generates two Kotlin files that you can use in your build:
30+
31+
- [buildSrc/src/main/kotlin/Libs.kt](doc/Libs.kt)
32+
- [buildSrc/src/main/kotlin/Versions.kt](doc/Versions.kt)
33+
34+
The IDE integration comes by the virtue of the Kotlin support in Gradle and Android Studio & IntelliJ.
35+
36+
Screencast: https://www.useloom.com/share/7edceb83fd594f319356240fcce304d5
37+
38+
39+
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)
40+
41+
42+
# How?
43+
44+
## Step 0
45+
46+
47+
Use either your own project or this sample repository
2148

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

2451

2552

26-
Step1: Edit build.gradle(.kts)
27-
----
53+
## Step 1: Apply the plugin
54+
55+
Edit your root `build.gradle(.kts)` file
2856

2957
```groovy
58+
// ./build.gradle
59+
// don't put anything before the buildscript and plugins blocks!
60+
buildscript {
61+
//...
62+
}
3063
plugins {
31-
// https://plugins.gradle.org/plugin/jmfayard.github.io.gradle-kotlin-dsl-libs
32-
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.4"
64+
// Find latest version at https://plugins.gradle.org/plugin/jmfayard.github.io.gradle-kotlin-dsl-libs
65+
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.4" // $ ./gradlew syncLibs
3366
}
3467
```
3568

3669

70+
## Step 2: Generate the code
3771

38-
Step2
39-
----
4072

73+
```
74+
$ ./gradlew syncLibs
75+
# give him time to find all the newer versions
76+
77+
$ find buildSrc -name "*.kt*"
78+
buildSrc/build.gradle.kts
79+
buildSrc/settings.gradle.kts
80+
buildSrc/src/main/kotlin/Libs.kt
81+
buildSrc/src/main/kotlin/Versions.kt
4182
42-
`$ ./gradlew syncLibs`
83+
```
4384

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

87+
## Step 3: Use the generated code
4688

47-
Step3:
48-
----
4989

5090
Replace your dependency strings with Libs.xxx
5191

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

62102

63103

104+
## Step 4: Update your dependencies
105+
106+
You can run again anytime the `$ ./gradlew syncLibs` task
64107

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

doc/Libs.kt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import kotlin.String
2+
3+
/**
4+
* Generated by [gradle-kotlin-dsl-libs](https://github.com/jmfayard/gradle-kotlin-dsl-libs)
5+
*
6+
* Run again
7+
* `$ ./gradlew syncLibs`
8+
* to update this file */
9+
object Libs {
10+
/**
11+
* [gradle website](https://developer.android.com/studio) */
12+
const val com_android_tools_build_gradle: String =
13+
"com.android.tools.build:gradle:" + Versions.com_android_tools_build_gradle
14+
15+
/**
16+
* [firebase-database website](https://github.com/b3er/RxFirebase2) */
17+
const val com_github_b3er_rxfirebase_firebase_database: String =
18+
"com.github.b3er.rxfirebase:firebase-database:" + Versions.com_github_b3er_rxfirebase_firebase_database
19+
20+
/**
21+
* [compiler website](https://github.com/bumptech/glide) */
22+
const val com_github_bumptech_glide_compiler: String =
23+
"com.github.bumptech.glide:compiler:" + Versions.com_github_bumptech_glide_compiler
24+
25+
const val com_google_firebase_firebase_database: String =
26+
"com.google.firebase:firebase-database:" + Versions.com_google_firebase_firebase_database
27+
28+
const val io_fabric_tools_gradle: String =
29+
"io.fabric.tools:gradle:" + Versions.io_fabric_tools_gradle
30+
31+
const val jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin: String =
32+
"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
33+
34+
/**
35+
* [kotlin-scripting-compiler-embeddable website](https://kotlinlang.org/) */
36+
const val kotlin_scripting_compiler_embeddable: String =
37+
"org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:" + Versions.kotlin_scripting_compiler_embeddable
38+
39+
const val krangl: String = "de.mpicbg.scicomp:krangl:" + Versions.krangl
40+
41+
/**
42+
* [okio website](https://github.com/square/okio/) */
43+
const val okio: String = "com.squareup.okio:okio:" + Versions.okio
44+
45+
const val org_jetbrains_kotlin_jvm_gradle_plugin: String =
46+
"org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:" + Versions.org_jetbrains_kotlin_jvm_gradle_plugin
47+
48+
/**
49+
* [rxjava website](https://github.com/ReactiveX/RxJava) */
50+
const val rxjava: String = "io.reactivex.rxjava2:rxjava:" + Versions.rxjava
51+
}

doc/Versions.kt

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import kotlin.String
2+
3+
/**
4+
* Generated by [gradle-kotlin-dsl-libs](https://github.com/jmfayard/gradle-kotlin-dsl-libs)
5+
*
6+
* Run again
7+
* `$ ./gradlew syncLibs`
8+
* to update this file */
9+
object Versions {
10+
/**
11+
* [gradle website](https://developer.android.com/studio) */
12+
const val com_android_tools_build_gradle: String =
13+
"3.2.1" // available milestone: "3.3.0-alpha13"
14+
15+
/**
16+
* [firebase-database website](https://github.com/b3er/RxFirebase2) */
17+
const val com_github_b3er_rxfirebase_firebase_database: String = "11.2.0" // up-to-date
18+
19+
/**
20+
* [compiler website](https://github.com/bumptech/glide) */
21+
const val com_github_bumptech_glide_compiler: String = "4.8.0" // up-to-date
22+
23+
const val com_google_firebase_firebase_database: String =
24+
"12.0.0" // available milestone: "16.0.3"
25+
26+
const val io_fabric_tools_gradle: String = "1.26.1" // up-to-date
27+
28+
const val jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin: String =
29+
"0.2.4" // up-to-date
30+
31+
/**
32+
* [kotlin-scripting-compiler-embeddable website](https://kotlinlang.org/) */
33+
const val kotlin_scripting_compiler_embeddable: String = "1.2.71" // up-to-date
34+
35+
const val krangl: String = "0.10.3" // up-to-date
36+
37+
/**
38+
* [okio website](https://github.com/square/okio/) */
39+
const val okio: String = "2.0.0" // available milestone: "2.1.0"
40+
41+
const val org_jetbrains_kotlin_jvm_gradle_plugin: String = "1.2.71" // up-to-date
42+
43+
/**
44+
* [rxjava website](https://github.com/ReactiveX/RxJava) */
45+
const val rxjava: String = "2.2.0" // available milestone: "2.2.2"
46+
47+
/**
48+
*
49+
* To update Gradle, edit the wrapper file at path:
50+
* ./gradle/wrapper/gradle-wrapper.properties
51+
*/
52+
object Gradle {
53+
const val runningVersion: String = "4.10.2"
54+
55+
const val currentVersion: String = "4.10.2"
56+
57+
const val nightlyVersion: String = "5.1-20181015235836+0000"
58+
59+
const val releaseCandidate: String = ""
60+
}
61+
}

doc/report.json

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{
2+
"current": {
3+
"dependencies": [
4+
{
5+
"group": "com.github.b3er.rxfirebase",
6+
"version": "11.2.0",
7+
"projectUrl": "https://github.com/b3er/RxFirebase2",
8+
"name": "firebase-database"
9+
},
10+
{
11+
"group": "com.github.bumptech.glide",
12+
"version": "4.8.0",
13+
"projectUrl": "https://github.com/bumptech/glide",
14+
"name": "compiler"
15+
},
16+
{
17+
"group": "de.mpicbg.scicomp",
18+
"version": "0.10.3",
19+
"projectUrl": null,
20+
"name": "krangl"
21+
},
22+
{
23+
"group": "io.fabric.tools",
24+
"version": "1.26.1",
25+
"projectUrl": null,
26+
"name": "gradle"
27+
},
28+
{
29+
"group": "jmfayard.github.io.gradle-kotlin-dsl-libs",
30+
"version": "0.2.4",
31+
"projectUrl": null,
32+
"name": "jmfayard.github.io.gradle-kotlin-dsl-libs.gradle.plugin"
33+
},
34+
{
35+
"group": "org.jetbrains.kotlin",
36+
"version": "1.2.71",
37+
"projectUrl": "https://kotlinlang.org/",
38+
"name": "kotlin-scripting-compiler-embeddable"
39+
},
40+
{
41+
"group": "org.jetbrains.kotlin.jvm",
42+
"version": "1.2.71",
43+
"projectUrl": null,
44+
"name": "org.jetbrains.kotlin.jvm.gradle.plugin"
45+
}
46+
],
47+
"count": 7
48+
},
49+
"gradle": {
50+
"current": {
51+
"version": "4.10.2",
52+
"reason": "",
53+
"isUpdateAvailable": false,
54+
"isFailure": false
55+
},
56+
"nightly": {
57+
"version": "5.1-20181015235836+0000",
58+
"reason": "",
59+
"isUpdateAvailable": true,
60+
"isFailure": false
61+
},
62+
"enabled": true,
63+
"releaseCandidate": {
64+
"version": "",
65+
"reason": "update check succeeded: no release available",
66+
"isUpdateAvailable": false,
67+
"isFailure": false
68+
},
69+
"running": {
70+
"version": "4.10.2",
71+
"reason": "",
72+
"isUpdateAvailable": false,
73+
"isFailure": false
74+
}
75+
},
76+
"exceeded": {
77+
"dependencies": [
78+
79+
],
80+
"count": 0
81+
},
82+
"outdated": {
83+
"dependencies": [
84+
{
85+
"group": "com.android.tools.build",
86+
"available": {
87+
"release": null,
88+
"milestone": "3.3.0-alpha13",
89+
"integration": null
90+
},
91+
"version": "3.2.1",
92+
"projectUrl": "https://developer.android.com/studio",
93+
"name": "gradle"
94+
},
95+
{
96+
"group": "com.google.firebase",
97+
"available": {
98+
"release": null,
99+
"milestone": "16.0.3",
100+
"integration": null
101+
},
102+
"version": "12.0.0",
103+
"projectUrl": null,
104+
"name": "firebase-database"
105+
},
106+
{
107+
"group": "com.squareup.okio",
108+
"available": {
109+
"release": null,
110+
"milestone": "2.1.0",
111+
"integration": null
112+
},
113+
"version": "2.0.0",
114+
"projectUrl": "https://github.com/square/okio/",
115+
"name": "okio"
116+
},
117+
{
118+
"group": "io.reactivex.rxjava2",
119+
"available": {
120+
"release": null,
121+
"milestone": "2.2.2",
122+
"integration": null
123+
},
124+
"version": "2.2.0",
125+
"projectUrl": "https://github.com/ReactiveX/RxJava",
126+
"name": "rxjava"
127+
}
128+
],
129+
"count": 4
130+
},
131+
"unresolved": {
132+
"dependencies": [
133+
134+
],
135+
"count": 0
136+
},
137+
"count": 11
138+
}

0 commit comments

Comments
 (0)