Skip to content

Commit 87c5861

Browse files
committed
Made orbital version configurable in gradle
1 parent 752b582 commit 87c5861

File tree

5 files changed

+222
-13
lines changed

5 files changed

+222
-13
lines changed

CLAUDE.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# CLAUDE.md
2+
3+
## Project Overview
4+
5+
Preflight is a Kotlin-based testing framework for Taxi/Orbital projects. It provides a lightweight wrapper around Kotest's DescribeSpec for writing unit and integration tests against Taxi schemas and Orbital services. The project consists of a multi-module Gradle build with a core runtime library and a Gradle plugin.
6+
7+
## Architecture
8+
9+
### Core Components
10+
11+
- **preflight-runtime**: Core testing DSL and execution engine (`preflight-core/preflight-runtime/`)
12+
- `OrbitalSpec`: Base test class extending Kotest's DescribeSpec with Taxi/Orbital-specific functionality
13+
- `PreflightExtension`: Kotest extension that handles Taxi compilation and Orbital service initialization
14+
- `StubHelper`: Utilities for stubbing external data sources in tests
15+
- Environment variable support and configuration management
16+
17+
- **preflight-gradle-plugin**: Gradle plugin for project integration (`preflight-core/preflight-gradle-plugin/`)
18+
- `PreflightPlugin`: Main plugin class that configures Kotlin JVM, dependencies, and test execution
19+
- Automatically sets up JVM toolchain (Java 21), source sets, and test runner configuration
20+
21+
### Project Structure
22+
23+
The repository uses a composite build structure:
24+
- Root project includes core modules and example projects as composite builds
25+
- Example projects demonstrate usage patterns and serve as integration tests
26+
- Documentation site built with Next.js in `docs/` directory
27+
28+
## Common Development Commands
29+
30+
### Building and Testing
31+
```bash
32+
# Build all modules
33+
./gradlew build
34+
35+
# Run all tests (including example projects)
36+
./gradlew test
37+
38+
# Publish to local Maven repository
39+
./gradlew publishToMavenLocal
40+
41+
# Publish all subprojects to local Maven
42+
./gradlew publishAllMavenLocal
43+
```
44+
45+
### Working with Example Projects
46+
```bash
47+
# Test simple project example
48+
cd example-projects/simple-project && ./gradlew test
49+
50+
# Test project with Orbital dependencies
51+
cd example-projects/project-with-orbital-dependency && ./gradlew test
52+
53+
# Test mixed sources project (Avro, OpenAPI, Taxi)
54+
cd example-projects/mixed-sources && ./gradlew test
55+
```
56+
57+
### Plugin Development
58+
```bash
59+
# Build and test the Gradle plugin specifically
60+
cd preflight-core/preflight-gradle-plugin && ./gradlew test
61+
62+
# Generate version constants (automatically done during build)
63+
./gradlew generateVersionConstants
64+
```
65+
66+
## Key Conventions
67+
68+
### Test Structure
69+
- Tests extend `OrbitalSpec` class which provides Taxi query execution methods
70+
- Follow Kotest's DescribeSpec style: `describe("context") { it("should...") { ... } }`
71+
- Test files go in `test/` directory (not `src/test/`)
72+
- Use `.queryForScalar()`, `.queryForObject()`, `.queryForCollection()` for different return types
73+
74+
### Stubbing External Services
75+
```kotlin
76+
// Preferred: using stub scenarios
77+
"query".queryForObject(stub("serviceName").returns("json"))
78+
79+
// Advanced: using stub customizer callback
80+
"query".queryForObject { stubService -> /* configure */ }
81+
```
82+
83+
### Environment Variables
84+
- Support loading from `test-resources/env.conf` files
85+
- Override via `env()` or `environmentVariables()` methods in specs
86+
- Use HOCON format for configuration files
87+
88+
## Dependencies and Repositories
89+
90+
The project uses:
91+
- Kotlin 1.9.23 with JVM target 21
92+
- Kotest 5.8.0 for testing framework
93+
- Custom Orbital/Taxi libraries from `https://repo.orbitalhq.com/release`
94+
- Gradle Shadow plugin for fat JAR creation
95+
- Maven publishing with S3-based Orbital repository
96+
97+
## Configuration
98+
99+
### Orbital Version Configuration
100+
The plugin supports configurable Orbital versions via the `preflight` extension:
101+
102+
```kotlin
103+
// Default usage (Orbital 0.36.0-M9)
104+
plugins {
105+
id("com.orbitalhq.preflight")
106+
}
107+
108+
// Custom Orbital version
109+
preflight {
110+
orbitalVersion = "0.37.0"
111+
}
112+
```
113+
114+
**Implementation details:**
115+
- Extension class: `PreflightExtension` in `PreflightPlugin.kt`
116+
- Default version: "0.36.0-M9"
117+
- Dependencies are added in `afterEvaluate` block to access extension values
118+
- Orbital dependencies are injected by plugin, Taxi comes transitively
119+
120+
## Version Management
121+
122+
Project version is managed centrally in `preflight-core/build.gradle.kts` (currently 0.0.4). The Gradle plugin uses code generation to embed version constants at build time via the `generateVersionConstants` task.

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,29 @@ plugins {
3030
}
3131
```
3232

33+
## Configuration
34+
35+
### Orbital Version
36+
By default, Preflight uses Orbital version `0.36.0-M9`. You can configure which version of Orbital to test against using the `preflight` extension:
37+
38+
```kotlin
39+
// build.gradle.kts - uses default Orbital version (0.36.0-M9)
40+
plugins {
41+
id("com.orbitalhq.preflight")
42+
}
43+
44+
// OR specify a custom Orbital version
45+
preflight {
46+
orbitalVersion = "0.37.0"
47+
}
48+
```
49+
50+
**Benefits of configurable versions:**
51+
- Test against different Orbital versions without changing plugin code
52+
- Taxi dependencies come transitively from Orbital, ensuring compatibility
53+
- Easy to upgrade/downgrade versions for testing
54+
- No dependency version conflicts
55+
3356
### On Taxi CLI vs Gradle
3457
We plan to provide full support for executing tests using the Taxi CLI, which will make Gradle optional for CI/CD purposes.
3558

docs/pages/index.mdx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ First, add a `build.gradle.kts` file in your Taxi project root (next to your `ta
2424
// build.gradle.kts
2525
plugins {
2626
kotlin("jvm") version "1.9.23"
27-
id("com.orbitalhq.preflight") version "0.0.3" // Whatever the current latest version is
27+
id("com.orbitalhq.preflight") version "0.0.4" // Whatever the current latest version is
2828
}
2929
```
3030

@@ -35,6 +35,23 @@ You also need a `settings.gradle.kts` (but can be blank)
3535
// This file can be left blank
3636
```
3737

38+
### Configuration (Optional)
39+
By default, Preflight uses Orbital version `0.36.0-M9`. You can configure which version of Orbital to test against:
40+
41+
```kotlin
42+
// Use default Orbital version
43+
plugins {
44+
id("com.orbitalhq.preflight") version "0.0.4"
45+
}
46+
47+
// OR specify a custom Orbital version
48+
preflight {
49+
orbitalVersion = "0.37.0"
50+
}
51+
```
52+
53+
This ensures Taxi dependencies come transitively from Orbital, maintaining version compatibility.
54+
3855
Here's the directory structure:
3956

4057
```

preflight-core/preflight-gradle-plugin/src/main/kotlin/com/orbitalhq/preflight/gradle/PreflightPlugin.kt

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@ import org.gradle.api.Plugin
44
import org.gradle.api.Project
55
import org.gradle.api.tasks.SourceSetContainer
66
import org.gradle.api.tasks.testing.Test
7+
import org.gradle.api.artifacts.ModuleDependency
78
import java.net.URI
89
import com.orbitalhq.preflight.Versions
10+
11+
open class PreflightExtension {
12+
var orbitalVersion: String = "0.36.0-M9" // current default
13+
}
14+
915
class PreflightPlugin : Plugin<Project> {
1016
override fun apply(project: Project) {
1117
project.pluginManager.apply("org.jetbrains.kotlin.jvm")
1218
project.extensions.configure<org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension>("kotlin") {
1319
jvmToolchain(21)
1420
}
1521

22+
// Register the extension
23+
val extension = project.extensions.create("preflight", PreflightExtension::class.java)
24+
1625
project.repositories.mavenCentral()
1726
project.repositories.maven {
1827
name = "orbital"
@@ -21,13 +30,15 @@ class PreflightPlugin : Plugin<Project> {
2130
releasesOnly()
2231
}
2332
}
33+
project.repositories.maven {
34+
name = "orbital-snapshot"
35+
url = URI("https://repo.orbitalhq.com/snapshot")
36+
mavenContent {
37+
snapshotsOnly()
38+
}
39+
}
2440

2541

26-
project.dependencies.add("implementation", "org.jetbrains.kotlin:kotlin-stdlib")
27-
project.dependencies.add("implementation", "com.orbitalhq.preflight:preflight-runtime:${Versions.PREFLIGHT_VERSION}")
28-
project.dependencies.add("testImplementation", "io.kotest:kotest-runner-junit5:5.8.0")
29-
project.dependencies.add("testImplementation", "io.kotest:kotest-assertions-core:5.8.0")
30-
3142
val sourceSets = project.extensions.getByName("sourceSets") as SourceSetContainer
3243
val mainRuntimeClasspath = sourceSets.getByName("main").runtimeClasspath
3344
val mainSourceSet = sourceSets.getByName("main")
@@ -38,12 +49,48 @@ class PreflightPlugin : Plugin<Project> {
3849
testSourceSet.compileClasspath += mainSourceSet.output + mainSourceSet.compileClasspath
3950
testSourceSet.runtimeClasspath += mainSourceSet.output + mainSourceSet.runtimeClasspath
4051

41-
4252
project.tasks.withType(Test::class.java).configureEach {
4353
useJUnitPlatform()
4454
// Custom test directory support
4555
testClassesDirs = testSourceSet.output.classesDirs
4656
classpath = testSourceSet.runtimeClasspath
4757
}
58+
59+
// Move dependency declarations to afterEvaluate block to access extension values
60+
project.afterEvaluate {
61+
val orbitalVersion = extension.orbitalVersion
62+
63+
// Core dependencies
64+
project.dependencies.add("implementation", "org.jetbrains.kotlin:kotlin-stdlib")
65+
project.dependencies.add("implementation", "com.orbitalhq.preflight:preflight-runtime:${Versions.PREFLIGHT_VERSION}")
66+
project.dependencies.add("testImplementation", "io.kotest:kotest-runner-junit5:5.8.0")
67+
project.dependencies.add("testImplementation", "io.kotest:kotest-assertions-core:5.8.0")
68+
69+
// Orbital dependencies (moved from preflight-runtime)
70+
val taxiqlEngine = project.dependencies.create("com.orbitalhq:taxiql-query-engine:$orbitalVersion") as ModuleDependency
71+
taxiqlEngine.exclude(mapOf("group" to "org.pac4j"))
72+
taxiqlEngine.exclude(mapOf("group" to "org.jooq.pro"))
73+
project.dependencies.add("implementation", taxiqlEngine)
74+
75+
val taxiqlEngineTests = project.dependencies.create("com.orbitalhq:taxiql-query-engine:$orbitalVersion:tests") as ModuleDependency
76+
taxiqlEngineTests.exclude(mapOf("group" to "org.pac4j"))
77+
taxiqlEngineTests.exclude(mapOf("group" to "org.jooq.pro"))
78+
project.dependencies.add("implementation", taxiqlEngineTests)
79+
80+
val playgroundCore = project.dependencies.create("com.orbitalhq:taxi-playground-core:$orbitalVersion") as ModuleDependency
81+
playgroundCore.exclude(mapOf("group" to "io.confluent"))
82+
playgroundCore.exclude(mapOf("group" to "org.jooq.pro"))
83+
playgroundCore.exclude(mapOf("group" to "org.pac4j"))
84+
project.dependencies.add("implementation", playgroundCore)
85+
86+
val schemaServerCore = project.dependencies.create("com.orbitalhq:schema-server-core:$orbitalVersion") as ModuleDependency
87+
schemaServerCore.exclude(mapOf("group" to "io.confluent"))
88+
schemaServerCore.exclude(mapOf("group" to "org.pac4j"))
89+
schemaServerCore.exclude(mapOf("group" to "org.jooq.pro"))
90+
project.dependencies.add("implementation", schemaServerCore)
91+
92+
project.dependencies.add("implementation", "org.opentest4j:opentest4j:1.3.0")
93+
project.dependencies.add("implementation", "app.cash.turbine:turbine-jvm:0.12.1")
94+
}
4895
}
4996
}

preflight-core/preflight-runtime/build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ dependencies {
1010
testImplementation(platform("org.junit:junit-bom:5.10.0"))
1111
testImplementation("org.junit.jupiter:junit-jupiter")
1212

13-
api("org.taxilang:compiler:$taxiVersion")
14-
api("org.taxilang:compiler:$taxiVersion") {
13+
compileOnly("org.taxilang:compiler:$taxiVersion")
14+
compileOnly("org.taxilang:compiler:$taxiVersion") {
1515
artifact { classifier = "tests" }
1616
}
17-
api("com.orbitalhq:taxiql-query-engine:$orbitalVersion") {
17+
compileOnly("com.orbitalhq:taxiql-query-engine:$orbitalVersion") {
1818
// Not published to maven central, and not needed for testing
1919
// as it relates to saml auth
2020
exclude(group = "org.pac4j")
@@ -24,7 +24,7 @@ dependencies {
2424
exclude(group = "org.jooq.pro")
2525
exclude(group = "org.pac4j")
2626
}
27-
api("com.orbitalhq:taxiql-query-engine:$orbitalVersion") {
27+
compileOnly("com.orbitalhq:taxiql-query-engine:$orbitalVersion") {
2828
artifact { classifier = "tests" }
2929
// Not published to maven central, and not needed for testing
3030
// as it relates to saml auth
@@ -36,14 +36,14 @@ dependencies {
3636
exclude(group = "org.pac4j")
3737
}
3838
api("org.opentest4j:opentest4j:1.3.0")
39-
api("com.orbitalhq:taxi-playground-core:$orbitalVersion") {
39+
compileOnly("com.orbitalhq:taxi-playground-core:$orbitalVersion") {
4040
exclude(group = "io.confluent")
4141
exclude(group = "org.jooq.pro")
4242
exclude(group = "org.pac4j")
4343
}
4444

4545
api("app.cash.turbine:turbine-jvm:0.12.1")
46-
implementation("com.orbitalhq:schema-server-core:$orbitalVersion") {
46+
compileOnly("com.orbitalhq:schema-server-core:$orbitalVersion") {
4747
// This could become an issue - but this isn't published to maven central
4848
// If we end up needing this, we'll need to configure
4949
// <repositories>

0 commit comments

Comments
 (0)