Skip to content

Commit ea59662

Browse files
committed
Disable using kapt by default, add JVM overloads for methods for adding dependencies and improve documentation
Fixes #322 Fixes #325
1 parent 1d81ec6 commit ea59662

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

docs/libraries.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,38 @@ plugins {
6868
}
6969
```
7070

71-
This plugin adds dependencies to api and annotations ("scanner") artifacts to your project. You may turn off
72-
the auto-including of these artifacts by specifying following Gradle properties:
73-
- `kotlin.jupyter.add.api` to `false`.
74-
- `kotlin.jupyter.add.scanner` to `false`.
71+
This plugin adds following dependencies to your project:
72+
73+
| Artifact | Gradle option to exclude/include | Enabled by default | Dependency scope | Method for adding dependency manually |
74+
| :------------------------------- | :------------------------------- | :----------------- | :------------------- | :--------------------------------------- |
75+
| `kotlin-jupyter-api` | `kotlin.jupyter.add.api` | yes | `compileOnly` | `addApiDependency(version: String?)` |
76+
| `kotlin-jupyter-api-annotations` | `kotlin.jupyter.add.scanner` | no | `implementation` | `addScannerDependency(version: String?)` |
77+
| `kotlin-jupyter-test-kit` | `kotlin.jupyter.add.testkit` | yes | `testImplementation` | `addTestKitDependency(version: String?)` |
78+
79+
You may turn on / turn off the dependency with its default version (version of the plugin)
80+
by setting corresponding Gradle option to `true` or `false`.
81+
If the corresponding option is set to `false` (by default or in your setup), you still
82+
can add it manually using the method from the table inside `kotlinJupyter` extension like that:
7583

76-
Add these dependencies manually using `kotlinJupyter` extension:
7784
```groovy
7885
kotlinJupyter {
79-
addApiDependency("<version>")
80-
addScannerDependency("<version>")
86+
addApiDependency() // Use default version
87+
addApiDependency("0.10.0.1") // Use custom artifact version
8188
}
8289
```
8390

84-
Finally, implement `org.jetbrains.kotlinx.jupyter.api.libraries.LibraryDefinitionProducer` or
91+
### Adding library integration using annotation processor
92+
93+
If you don't have problems with kapt (i.e. you use JDK version under 16), you can use annotations to
94+
mark integration classes.
95+
96+
First, enable `kotlin-jupyter-api-annotations` dependency by adding following line to your `gradle.properties`:
97+
98+
```
99+
kotlin.jupyter.add.scanner = true
100+
```
101+
102+
Then, implement `org.jetbrains.kotlinx.jupyter.api.libraries.LibraryDefinitionProducer` or
85103
`org.jetbrains.kotlinx.jupyter.api.libraries.LibraryDefinition` and mark implementation with
86104
`JupyterLibrary` annotation:
87105

@@ -109,8 +127,9 @@ For a further information see docs for:
109127
- `org.jetbrains.kotlinx.jupyter.api.libraries.LibraryDefinitionProducer`
110128
- `org.jetbrains.kotlinx.jupyter.api.libraries.LibraryDefinition`
111129

112-
### Avoiding using annotation processor
130+
### Adding library integration avoiding use of annotation processor
113131
You may want not to use annotation processing for implementations detection.
132+
The reason may be, for example, the problems with kapt.
114133
Then you may refer your implementations right in your buildscript. Note that
115134
no checking for existence will be performed in this case.
116135

jupyter-lib/kotlin-jupyter-api-gradle-plugin/src/main/kotlin/org/jetbrains/kotlinx/jupyter/api/plugin/KotlinJupyterPluginExtension.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class KotlinJupyterPluginExtension(
1111
private val project: Project
1212
) {
1313
private val enableApiDependency = project.propertyByFlag("kotlin.jupyter.add.api", true)
14-
private val enableScannerDependency = project.propertyByFlag("kotlin.jupyter.add.scanner", true)
14+
private val enableScannerDependency = project.propertyByFlag("kotlin.jupyter.add.scanner", false)
1515
private val enableTestKitDependency = project.propertyByFlag("kotlin.jupyter.add.testkit", true)
1616

1717
internal fun addDependenciesIfNeeded() {
@@ -20,10 +20,12 @@ class KotlinJupyterPluginExtension(
2020
if (enableTestKitDependency.get()) addTestKitDependency()
2121
}
2222

23+
@JvmOverloads
2324
fun addApiDependency(version: String? = null) = with(project) {
2425
configureDependency("compileOnly", kernelDependency("api", version))
2526
}
2627

28+
@JvmOverloads
2729
fun addScannerDependency(version: String? = null) = with(project) {
2830
configurations.whenAdded({ it.name == "kapt" }) { kaptConf ->
2931
val annotationsDependency = kernelDependency("api-annotations", version)
@@ -34,6 +36,7 @@ class KotlinJupyterPluginExtension(
3436
}
3537
}
3638

39+
@JvmOverloads
3740
fun addTestKitDependency(version: String? = null) = with(project) {
3841
configureDependency("testImplementation", kernelDependency("test-kit", version))
3942
}

jupyter-lib/kotlin-jupyter-api-gradle-plugin/src/test/kotlin/org/jetbrains/kotlinx/jupyter/api/plugin/test/ResourcesTaskTests.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class ResourcesTaskTests {
3737
private fun runResourcesTask(args: Array<String>? = null, type: String = ""): BuildResult {
3838
val arguments = args?.toMutableList() ?: mutableListOf(
3939
"-Pkotlin.jupyter.add.api=false",
40-
"-Pkotlin.jupyter.add.scanner=false",
4140
"--stacktrace",
4241
"--info"
4342
)

0 commit comments

Comments
 (0)