If you haven't done so already, register to Hacktoberfest
==> https://hacktoberfest.digitalocean.com/
Head over to the "issues" tab and select a library for which you feel like contributing a usage sample
For the purpose of the guide, I will assume you choose to work on Koin
- 🛠 Fork the project
- ⬇️ Download the project locally
- ⑂ Create a git branch called
<LIBRARY_NAME>
- 📁 Open the folder
kotlin-jvm
in IntelliJ IDEA Community or in Android Studio - ⌛ Wait until your IDE has configured Gradle and indexed all the thing
- 📂 Open the file
kotlin-jvm/src/main/kotlin/playground/_main.kt
▶️ Run themain()
function
Or, if you are fine with using the command-line:
$ git clone https://github.com/LouisCAD/kotlin-libraries-playground
$ cd kotlin-libraries-playground
$ git checkout -b <LIBRARY_NAME>
$ cd kotlin-jvm
$ ./gradlew run
> Task :run
# square/moshi - A modern JSON library for Kotlin and Java
Test: User(name=Robert, age=42)
Test: {"name":"Robert","age":42}
# (more tests)
BUILD SUCCESSFUL in 12s
Look at the other samples for inspiration. Some notes:
- Put your code in a different package, but for simplicity keep it in the root
playground
folder, this is why we are ignoring the warning. - Document what the library does and where people can find more information. People unfamiliar with the library will thank you!
- Put your code in a
main()
function so that it can be run alone. But make sure to call it fromkotlin-jvm/src/main/kotlin/playground/_main.kt
so that it's run when all the code is run! - Document which library you are using, for when all samples are run
- Try to keep all your code in this single file!
Add all libraries your need in build.gradle.kts
!
Note that the project is configured with gradle refreshVersions
When you want to add a new library, either
- You can quickly add new dependencies without leaving the IDEA, if the dependency is embedded in the plugin. Here you find the list of supported libraries
- If the dependency is not yet in
gradle refreshVersions
, use the normal Gradle syntax, but replace the version by an underscore.
dependencies {
implementation(Square.okHttp3.okHttp) // 1
implementation("org.kodein.di:kodein-di:_") // 2
}
- Sync Gradle. The latest version of the library you added will be added to the file
versions.properties
Later, you can update dependencies version by running the task $ ./gradlew refreshVersions
Then you simply edit the file versions.properties
and Sync Gradle again.
Here you are on your own. Well not exactly, you have the documentation of the library to follow.
Just strive to have your code both simple and meaningful
Common mistakes made in pull-requests:
- Did your put code in his own package?
- Did you call your sample from
kotlin-jvm/src/main/kotlin/playground/_main.kt
? - Did you reformat your code before committing? Use the action
Reformat Code Alt-Cmd-L
- Make sure your code is run when you run the task
./gradlew runOnGitHub
. This task will be run on GitHub Actions - Create your pull request. Hint: there is an action for that in IntelliJ/Android Studio
Open the issue that was assigned to you, and describe why you are stuck. We will do our best to unstuck you :)