Skip to content

Commit

Permalink
Split openapi support in two modules, to avoid adding dependencies ne…
Browse files Browse the repository at this point in the history
…eded only for code-generation to project runtime classpath
  • Loading branch information
koperagen committed Oct 16, 2024
1 parent 0bb5130 commit 92ab4dc
Show file tree
Hide file tree
Showing 36 changed files with 103 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ internal class Integration(private val notebook: Notebook, private val options:
"org.jetbrains.kotlinx:dataframe-jdbc:$version",
"org.jetbrains.kotlinx:dataframe-arrow:$version",
"org.jetbrains.kotlinx:dataframe-openapi:$version",
"org.jetbrains.kotlinx:dataframe-openapi-generator:$version",
)
}

Expand Down
53 changes: 53 additions & 0 deletions dataframe-openapi-generator/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
plugins {
with(libs.plugins) {
alias(kotlin.jvm)
alias(publisher)
alias(serialization)
alias(kover)
alias(ktlint)
alias(jupyter.api)
}
}

group = "org.jetbrains.kotlinx"

val jupyterApiTCRepo: String by project

repositories {
mavenLocal()
mavenCentral()
maven(jupyterApiTCRepo)
}

dependencies {
api(project(":core"))
api(project(":dataframe-openapi"))

implementation(libs.sl4j)
implementation(libs.kotlinLogging)
implementation(libs.kotlin.reflect)
implementation(libs.kotlinpoet)
api(libs.swagger) {
// Fix for Android
exclude("jakarta.validation")
}

testApi(project(":core"))
testImplementation(libs.junit)
testImplementation(libs.kotestAssertions) {
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
}
}

kotlinPublications {
publication {
publicationName = "dataframeOpenApi"
artifactId = project.name
description = "OpenAPI code generation support for Kotlin Dataframe"
packageName = artifactId
}
}

kotlin {
explicitApi()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.jetbrains.kotlinx.dataframe.io

import org.jetbrains.kotlinx.dataframe.codeGen.FieldType
import org.jetbrains.kotlinx.dataframe.codeGen.Marker
import org.jetbrains.kotlinx.dataframe.codeGen.MarkerVisibility
import org.jetbrains.kotlinx.dataframe.codeGen.ValidFieldName

internal fun AdditionalProperty.Companion.getMarker(typeArguments: List<String>) =
Marker(
name = AdditionalProperty::class.qualifiedName!!,
isOpen = false,
fields = listOf(
generatedFieldOf(
fieldName = ValidFieldName.of(AdditionalProperty<*>::key.name),
columnName = AdditionalProperty<*>::key.name,
overrides = false,
fieldType = FieldType.ValueFieldType(String::class.qualifiedName!!),
),
generatedFieldOf(
fieldName = ValidFieldName.of(AdditionalProperty<*>::`value`.name),
columnName = AdditionalProperty<*>::`value`.name,
overrides = false,
fieldType = FieldType.ValueFieldType(Any::class.qualifiedName!! + "?"),
),
),
superMarkers = emptyList(),
visibility = MarkerVisibility.EXPLICIT_PUBLIC,
typeParameters = emptyList(),
typeArguments = typeArguments,
)
31 changes: 4 additions & 27 deletions dataframe-openapi/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
plugins {
with(libs.plugins) {
alias(kotlin.jvm)
alias(publisher)
alias(serialization)
alias(kover)
alias(ktlint)
alias(jupyter.api)
}
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.ktlint)
alias(libs.plugins.publisher)
alias(libs.plugins.jupyter.api)
}

group = "org.jetbrains.kotlinx"

val jupyterApiTCRepo: String by project

repositories {
mavenLocal()
mavenCentral()
maven(jupyterApiTCRepo)
}

dependencies {
api(project(":core"))

implementation(libs.sl4j)
implementation(libs.kotlinLogging)
implementation(libs.kotlin.reflect)
implementation(libs.kotlinpoet)
api(libs.swagger) {
// Fix for Android
exclude("jakarta.validation")
}

testApi(project(":core"))
testImplementation(libs.junit)
testImplementation(libs.kotestAssertions) {
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
}
}

kotlinPublications {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ package org.jetbrains.kotlinx.dataframe.io

import org.jetbrains.kotlinx.dataframe.annotations.DataSchema
import org.jetbrains.kotlinx.dataframe.api.KeyValueProperty
import org.jetbrains.kotlinx.dataframe.codeGen.FieldType
import org.jetbrains.kotlinx.dataframe.codeGen.Marker
import org.jetbrains.kotlinx.dataframe.codeGen.MarkerVisibility
import org.jetbrains.kotlinx.dataframe.codeGen.ValidFieldName

/**
* A [DataSchema] interface can implement this if it represents a map-like data schema (so key: value).
Expand All @@ -19,29 +15,5 @@ public interface AdditionalProperty<T> : KeyValueProperty<T> {
/** Value of the property. */
override val value: T

public companion object {
internal fun getMarker(typeArguments: List<String>) =
Marker(
name = AdditionalProperty::class.qualifiedName!!,
isOpen = false,
fields = listOf(
generatedFieldOf(
fieldName = ValidFieldName.of(AdditionalProperty<*>::key.name),
columnName = AdditionalProperty<*>::key.name,
overrides = false,
fieldType = FieldType.ValueFieldType(String::class.qualifiedName!!),
),
generatedFieldOf(
fieldName = ValidFieldName.of(AdditionalProperty<*>::`value`.name),
columnName = AdditionalProperty<*>::`value`.name,
overrides = false,
fieldType = FieldType.ValueFieldType(Any::class.qualifiedName!! + "?"),
),
),
superMarkers = emptyList(),
visibility = MarkerVisibility.EXPLICIT_PUBLIC,
typeParameters = emptyList(),
typeArguments = typeArguments,
)
}
public companion object
}
6 changes: 6 additions & 0 deletions docs/StardustDocs/topics/gettingStartedGradleAdvanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ dependencies {
implementation("org.jetbrains.kotlinx:dataframe-jdbc:%dataFrameVersion%")
implementation("org.jetbrains.kotlinx:dataframe-arrow:%dataFrameVersion%")
implementation("org.jetbrains.kotlinx:dataframe-openapi:%dataFrameVersion%")

// This artifact is only needed to directly call functions that generate @DataSchema code from OpenAPI specifications
// It's used by Gradle and KSP plugins internally.
// Your project needs dataframe-openapi to use generated code
implementation("org.jetbrains.kotlinx:dataframe-openapi-generator:%dataFrameVersion%")
}
```

Expand All @@ -144,6 +149,7 @@ dependencies {
implementation 'org.jetbrains.kotlinx:dataframe-jdbc:%dataFrameVersion%'
implementation 'org.jetbrains.kotlinx:dataframe-arrow:%dataFrameVersion%'
implementation 'org.jetbrains.kotlinx:dataframe-openapi:%dataFrameVersion%'
implementation 'org.jetbrains.kotlinx:dataframe-openapi-generator:%dataFrameVersion%'
}
```

Expand Down
5 changes: 3 additions & 2 deletions plugins/dataframe-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dependencies {
api(libs.kotlin.reflect)
implementation(project(":core"))
implementation(project(":dataframe-arrow"))
implementation(project(":dataframe-openapi"))
implementation(project(":dataframe-openapi-generator"))
implementation(project(":dataframe-excel"))
implementation(project(":dataframe-jdbc"))

Expand Down Expand Up @@ -116,12 +116,13 @@ val integrationTestTask = task<Test>("integrationTest") {
dependsOn(":dataframe-arrow:publishToMavenLocal")
dependsOn(":dataframe-excel:publishToMavenLocal")
dependsOn(":dataframe-jdbc:publishToMavenLocal")
dependsOn(":dataframe-openapi-generator:publishToMavenLocal")
dependsOn(":dataframe-openapi:publishToMavenLocal")
dependsOn(":publishApiPublicationToMavenLocal")
dependsOn(":dataframe-arrow:publishDataframeArrowPublicationToMavenLocal")
dependsOn(":dataframe-excel:publishDataframeExcelPublicationToMavenLocal")
dependsOn(":dataframe-jdbc:publishDataframeJDBCPublicationToMavenLocal")
dependsOn(":dataframe-openapi:publishDataframeOpenApiPublicationToMavenLocal")
dependsOn(":dataframe-openapi-generator:publishDataframeOpenApiPublicationToMavenLocal")
dependsOn(":plugins:symbol-processor:publishMavenPublicationToMavenLocal")
dependsOn(":core:publishCorePublicationToMavenLocal")
description = "Runs integration tests."
Expand Down
2 changes: 1 addition & 1 deletion plugins/symbol-processor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ group = "org.jetbrains.kotlinx.dataframe"
dependencies {
implementation(project(":core"))
implementation(project(":dataframe-arrow"))
implementation(project(":dataframe-openapi"))
implementation(project(":dataframe-openapi-generator"))
implementation(project(":dataframe-excel"))
implementation(project(":dataframe-jdbc"))
implementation(libs.ksp.api)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ class DataFrameSymbolProcessorTest {
}
}

private val petstoreYaml = File("../../dataframe-openapi/src/test/resources/petstore.yaml")
private val petstoreYaml = File("../../dataframe-openapi-generator/src/test/resources/petstore.yaml")

@Test
fun `openApi yaml test`(): Unit =
Expand Down Expand Up @@ -1238,7 +1238,7 @@ class DataFrameSymbolProcessorTest {
}
}

private val apiGuruMetricsJson = File("../../dataframe-openapi/src/test/resources/apiGuruMetrics.json")
private val apiGuruMetricsJson = File("../../dataframe-openapi-generator/src/test/resources/apiGuruMetrics.json")

@Test
fun `non openApi json test 2`(): Unit =
Expand Down Expand Up @@ -1275,7 +1275,7 @@ class DataFrameSymbolProcessorTest {
}
}

private val petstoreJson = File("../../dataframe-openapi/src/test/resources/petstore.json")
private val petstoreJson = File("../../dataframe-openapi-generator/src/test/resources/petstore.json")

@Test
fun `openApi json test`(): Unit =
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ plugins {
}
include("dataframe-excel")
include("core")
include("dataframe-openapi-generator")

0 comments on commit 92ab4dc

Please sign in to comment.