-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add jupyter integration for lets-plot-kotlin and lets-plot-kotlin-geo…
…tools (#258) * Agg jupyter integration for lets-plot-kotlin and lets-plot-kotlin-geotools * Extract integrations to separate modules and artifacts with all LP/LPK implementations; extract spec serialization to util module * little code clean up * rename util to json & remove lets-plot mention * move serialization version
- Loading branch information
1 parent
11fd59b
commit c81d496
Showing
21 changed files
with
836 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
kotlin("jvm") | ||
`maven-publish` | ||
signing | ||
id("com.google.devtools.ksp") | ||
kotlin("jupyter.api") | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
val geoToolsVersion = extra["geotools.version"] as String | ||
|
||
dependencies { | ||
implementation(projects.plotApi) | ||
// basic LPK jupyter integration | ||
implementation(projects.jupyter) | ||
|
||
// geotools implementations | ||
implementation(projects.geotools) | ||
implementation("org.geotools:gt-main:$geoToolsVersion") | ||
implementation("org.geotools:gt-geojson:$geoToolsVersion") | ||
|
||
testImplementation(kotlin("test")) | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(11) | ||
} | ||
tasks.withType<KotlinCompile>().all { | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_11.toString() | ||
} | ||
} | ||
|
||
tasks.withType<JavaCompile>().all { | ||
sourceCompatibility = JavaVersion.VERSION_11.toString() | ||
targetCompatibility = JavaVersion.VERSION_11.toString() | ||
} | ||
|
||
tasks.processJupyterApiResources { | ||
libraryProducers = listOf("org.jetbrains.letsPlot.toolkit.geotools.jupyter.Integration") | ||
} | ||
|
||
val artifactBaseName = "lets-plot-kotlin-geotools-jupyter" | ||
val artifactGroupId = project.group as String | ||
val artifactVersion = project.version as String | ||
|
||
afterEvaluate { | ||
|
||
publishing { | ||
publications { | ||
// Build artifact with all dependencies. | ||
create<MavenPublication>("letsPlotKotlinGeotoolsJupyter") { | ||
|
||
groupId = artifactGroupId | ||
artifactId = artifactBaseName | ||
version = artifactVersion | ||
|
||
from(components["java"]) | ||
|
||
pom { | ||
name.set("Lets-Plot Kotlin Geotools Jupyter Integration") | ||
description.set( | ||
"Lets-Plot Kotlin Geotools Integration For Kotlin Jupyter Kernel." | ||
) | ||
url.set("https://github.com/JetBrains/lets-plot-kotlin") | ||
licenses { | ||
license { | ||
name.set("MIT") | ||
url.set("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/LICENSE") | ||
} | ||
} | ||
developers { | ||
developer { | ||
id.set("jetbrains") | ||
name.set("JetBrains") | ||
email.set("[email protected]") | ||
} | ||
} | ||
scm { | ||
url.set("https://github.com/JetBrains/lets-plot-kotlin") | ||
} | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal { | ||
val localMavenRepository: String by project | ||
url = uri(localMavenRepository) | ||
} | ||
} | ||
} | ||
} | ||
signing { | ||
if (!(project.version as String).contains("SNAPSHOT")) { | ||
sign(publishing.publications) | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ls-jupyter/src/main/kotlin/org/jetbrains/letsPlot/toolkit/geotools/jupyter/Integration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.jetbrains.letsPlot.toolkit.geotools.jupyter | ||
|
||
import org.jetbrains.kotlinx.jupyter.api.Notebook | ||
import org.jetbrains.kotlinx.jupyter.api.libraries.JupyterIntegration | ||
import org.jetbrains.kotlinx.jupyter.api.libraries.repositories | ||
import org.jetbrains.letsPlot.export.VersionChecker | ||
|
||
@Suppress("unused") | ||
class Integration(private val notebook: Notebook, private val options: MutableMap<String, String?>) : | ||
JupyterIntegration() { | ||
private val api = options["api"] ?: VersionChecker.letsPlotKotlinAPIVersion | ||
override fun Builder.onLoaded() { | ||
repositories { | ||
maven("https://repo.osgeo.org/repository/release") | ||
} | ||
import("org.jetbrains.letsPlot.toolkit.geotools.toSpatialDataset") | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...pyter/src/test/kotlin/org/jetbrains/letsPlot/toolkit/geotools/jupyter/NaturalEarthTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.jetbrains.letsPlot.toolkit.geotools.jupyter | ||
|
||
import org.jetbrains.kotlinx.jupyter.testkit.JupyterReplTestCase | ||
import kotlin.test.Test | ||
|
||
class NaturalEarthTest : JupyterReplTestCase() { | ||
private val geotoolsDependencies = """ | ||
USE { | ||
dependencies { | ||
implementation("org.geotools:gt-shapefile:30.0") | ||
} | ||
} | ||
""".trimIndent() | ||
|
||
private val naturalEarthMap = """ | ||
import org.geotools.data.shapefile.ShapefileDataStoreFactory | ||
import org.geotools.data.simple.SimpleFeatureCollection | ||
import java.net.URL | ||
val factory = ShapefileDataStoreFactory() | ||
val worldFeatures : SimpleFeatureCollection = with("naturalearth_lowres") { | ||
val url = "https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/shp/${'$'}this/${'$'}this.shp" | ||
factory.createDataStore(URL(url)).featureSource.features | ||
} | ||
val world = worldFeatures.toSpatialDataset(10) | ||
letsPlot() + | ||
geomMap(map = world) + | ||
ggsize(700, 400) + | ||
themeVoid() | ||
""".trimIndent() | ||
|
||
@Test | ||
fun `natural earth example compilation in jupyter`() { | ||
execRendered(geotoolsDependencies) | ||
execRendered(naturalEarthMap) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
plugins { | ||
kotlin("jvm") | ||
`maven-publish` | ||
signing | ||
} | ||
|
||
val serializationVersion = extra["serialization.version"] as String | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serializationVersion") | ||
|
||
testImplementation(kotlin("test")) | ||
} | ||
|
||
|
||
val artifactBaseName = "lets-plot-kotlin-json" | ||
val artifactGroupId = project.group as String | ||
val artifactVersion = project.version as String | ||
|
||
afterEvaluate { | ||
publishing { | ||
publications { | ||
create<MavenPublication>("letsPlotKotlinJson") { | ||
groupId = artifactGroupId | ||
artifactId = artifactBaseName | ||
version = artifactVersion | ||
|
||
from(components["java"]) | ||
|
||
pom { | ||
name.set("Lets-Plot Kotlin Util") | ||
description.set( | ||
"Lets-Plot Kotlin Util For Json Serialization." | ||
) | ||
url.set("https://github.com/JetBrains/lets-plot-kotlin") | ||
licenses { | ||
license { | ||
name.set("MIT") | ||
url.set("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/LICENSE") | ||
} | ||
} | ||
developers { | ||
developer { | ||
id.set("jetbrains") | ||
name.set("JetBrains") | ||
email.set("[email protected]") | ||
} | ||
} | ||
scm { | ||
url.set("https://github.com/JetBrains/lets-plot-kotlin") | ||
} | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal { | ||
val localMavenRepository: String by project | ||
url = uri(localMavenRepository) | ||
} | ||
} | ||
} | ||
} | ||
signing { | ||
if (!(project.version as String).contains("SNAPSHOT")) { | ||
sign(publishing.publications) | ||
} | ||
} |
Oops, something went wrong.