Skip to content

Commit f64f0f3

Browse files
authored
Fix string interpolation. (#74) (#79)
1 parent a64cb1a commit f64f0f3

8 files changed

Lines changed: 613 additions & 193 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ dependencies {
170170
implementation("st.orm:storm-kotlin")
171171
runtimeOnly("st.orm:storm-core")
172172
// Use storm-compiler-plugin-2.0 for Kotlin 2.0.x, -2.1 for 2.1.x, etc.
173-
kotlinCompilerPluginClasspath("st.orm:storm-compiler-plugin-2.0:1.10.0")
173+
kotlinCompilerPluginClasspath("st.orm:storm-compiler-plugin-2.0")
174174
}
175175
```
176176

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ dependencies {
146146
implementation("st.orm:storm-kotlin")
147147
runtimeOnly("st.orm:storm-core")
148148
// Use storm-compiler-plugin-2.0 for Kotlin 2.0.x, -2.1 for 2.1.x, etc.
149-
kotlinCompilerPluginClasspath("st.orm:storm-compiler-plugin-2.0:1.10.0")
149+
kotlinCompilerPluginClasspath("st.orm:storm-compiler-plugin-2.0")
150150
}
151151
```
152152

docs/installation.md

Lines changed: 40 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,12 @@ Storm provides a Bill of Materials (BOM) for centralized version management. Imp
2323
<Tabs groupId="language">
2424
<TabItem value="kotlin" label="Kotlin" default>
2525

26-
**Gradle (Kotlin DSL):**
27-
2826
```kotlin
2927
dependencies {
3028
implementation(platform("st.orm:storm-bom:1.10.0"))
3129
}
3230
```
3331

34-
**Maven:**
35-
36-
```xml
37-
<dependencyManagement>
38-
<dependencies>
39-
<dependency>
40-
<groupId>st.orm</groupId>
41-
<artifactId>storm-bom</artifactId>
42-
<version>1.10.0</version>
43-
<type>pom</type>
44-
<scope>import</scope>
45-
</dependency>
46-
</dependencies>
47-
</dependencyManagement>
48-
```
49-
5032
</TabItem>
5133
<TabItem value="java" label="Java">
5234

@@ -77,81 +59,42 @@ dependencies {
7759
</TabItem>
7860
</Tabs>
7961

80-
## Add the Core Dependency
62+
## Add the Core Dependencies
8163

8264
<Tabs groupId="language">
8365
<TabItem value="kotlin" label="Kotlin" default>
8466

85-
**Gradle (Kotlin DSL):**
86-
8767
```kotlin
68+
plugins {
69+
id("com.google.devtools.ksp") version "2.0.21-1.0.28"
70+
}
71+
8872
dependencies {
8973
implementation(platform("st.orm:storm-bom:1.10.0"))
9074

9175
implementation("st.orm:storm-kotlin")
76+
runtimeOnly("st.orm:storm-core")
77+
ksp("st.orm:storm-metamodel-ksp")
78+
kotlinCompilerPluginClasspath("st.orm:storm-compiler-plugin-2.0")
9279
}
9380
```
9481

95-
**Maven:**
96-
97-
```xml
98-
<dependencies>
99-
<dependency>
100-
<groupId>st.orm</groupId>
101-
<artifactId>storm-kotlin</artifactId>
102-
</dependency>
103-
</dependencies>
104-
```
82+
The `storm-metamodel-ksp` dependency generates type-safe metamodel classes (e.g., `User_`, `City_`) at compile time. See [Metamodel](metamodel.md) for details. The `storm-compiler-plugin` automatically wraps string interpolations inside SQL template lambdas, making queries injection-safe by default. The `2.0` suffix matches the Kotlin major.minor version used in your project (e.g., `storm-compiler-plugin-2.1` for Kotlin 2.1.x). See [String Templates](string-templates.md) for details.
10583

10684
</TabItem>
10785
<TabItem value="java" label="Java">
10886

109-
**Maven:**
110-
111-
```xml
112-
<dependencies>
113-
<dependency>
114-
<groupId>st.orm</groupId>
115-
<artifactId>storm-java21</artifactId>
116-
</dependency>
117-
</dependencies>
118-
```
119-
12087
**Gradle (Kotlin DSL):**
12188

12289
```kotlin
12390
dependencies {
12491
implementation(platform("st.orm:storm-bom:1.10.0"))
12592

12693
implementation("st.orm:storm-java21")
94+
runtimeOnly("st.orm:storm-core")
95+
annotationProcessor("st.orm:storm-metamodel-processor")
12796
}
128-
```
129-
130-
</TabItem>
131-
</Tabs>
132-
133-
### Enable Preview Features (Java Only)
134-
135-
The Java API uses String Templates (JEP 430), a preview feature in JDK 21+. You must add `--enable-preview` to the compiler configuration:
136-
137-
**Maven:**
138-
139-
```xml
140-
<plugin>
141-
<groupId>org.apache.maven.plugins</groupId>
142-
<artifactId>maven-compiler-plugin</artifactId>
143-
<configuration>
144-
<release>21</release>
145-
<compilerArgs>
146-
<arg>--enable-preview</arg>
147-
</compilerArgs>
148-
</configuration>
149-
</plugin>
150-
```
151-
152-
**Gradle (Kotlin DSL):**
15397

154-
```kotlin
15598
tasks.withType<JavaCompile> {
15699
options.compilerArgs.add("--enable-preview")
157100
}
@@ -161,114 +104,51 @@ tasks.withType<Test> {
161104
}
162105
```
163106

164-
### Storm Compiler Plugin (Kotlin)
165-
166-
The Storm compiler plugin automatically wraps string interpolations inside SQL template lambdas, so you can write natural Kotlin syntax that is parameterized and SQL injection safe by default. See [String Templates](string-templates.md) for details.
167-
168-
<Tabs groupId="build">
169-
<TabItem value="gradle" label="Gradle (Kotlin DSL)" default>
107+
**Maven:**
170108

171-
```kotlin
172-
dependencies {
173-
kotlinCompilerPluginClasspath("st.orm:storm-compiler-plugin-2.0:1.10.0")
174-
}
109+
```xml
110+
<dependencies>
111+
<dependency>
112+
<groupId>st.orm</groupId>
113+
<artifactId>storm-java21</artifactId>
114+
</dependency>
115+
<dependency>
116+
<groupId>st.orm</groupId>
117+
<artifactId>storm-core</artifactId>
118+
<scope>runtime</scope>
119+
</dependency>
120+
<dependency>
121+
<groupId>st.orm</groupId>
122+
<artifactId>storm-metamodel-processor</artifactId>
123+
<scope>provided</scope>
124+
</dependency>
125+
</dependencies>
175126
```
176127

177-
</TabItem>
178-
<TabItem value="maven" label="Maven">
179-
180-
Add the plugin jar as a dependency of `kotlin-maven-plugin`:
128+
Enable preview features for String Templates (JEP 430):
181129

182130
```xml
183131
<plugin>
184-
<groupId>org.jetbrains.kotlin</groupId>
185-
<artifactId>kotlin-maven-plugin</artifactId>
186-
<dependencies>
187-
<dependency>
188-
<groupId>st.orm</groupId>
189-
<artifactId>storm-compiler-plugin-2.0</artifactId>
190-
<version>${storm.version}</version>
191-
</dependency>
192-
</dependencies>
132+
<groupId>org.apache.maven.plugins</groupId>
133+
<artifactId>maven-compiler-plugin</artifactId>
134+
<configuration>
135+
<release>21</release>
136+
<compilerArgs>
137+
<arg>--enable-preview</arg>
138+
</compilerArgs>
139+
</configuration>
193140
</plugin>
194141
```
195142

196143
</TabItem>
197144
</Tabs>
198145

146+
The metamodel processor generates type-safe metamodel classes (e.g., `User_`, `City_`) at compile time. See [Metamodel](metamodel.md) for details.
147+
199148
## Optional Modules
200149

201150
Storm is modular. Add only what you need.
202151

203-
### Static Metamodel
204-
205-
The metamodel generates companion classes (e.g., `User_`, `City_`) at compile time, enabling type-safe field references in queries. While optional, it is strongly recommended for projects that use Storm's query builder or repository predicates. See [Metamodel](metamodel.md) for details.
206-
207-
<Tabs groupId="language">
208-
<TabItem value="kotlin" label="Kotlin" default>
209-
210-
Kotlin projects can generate the metamodel using either KSP (for Gradle) or kapt (for Maven). Both produce the same metamodel classes.
211-
212-
**Gradle (Kotlin DSL) with KSP:**
213-
214-
```kotlin
215-
plugins {
216-
id("com.google.devtools.ksp") version "2.0.21-1.0.28"
217-
}
218-
219-
dependencies {
220-
ksp("st.orm:storm-metamodel-ksp:1.10.0")
221-
}
222-
```
223-
224-
**Maven with kapt:**
225-
226-
```xml
227-
<plugin>
228-
<groupId>org.jetbrains.kotlin</groupId>
229-
<artifactId>kotlin-maven-plugin</artifactId>
230-
<executions>
231-
<execution>
232-
<id>kapt</id>
233-
<goals><goal>kapt</goal></goals>
234-
<configuration>
235-
<annotationProcessorPaths>
236-
<path>
237-
<groupId>st.orm</groupId>
238-
<artifactId>storm-metamodel-processor</artifactId>
239-
<version>1.10.0</version>
240-
</path>
241-
</annotationProcessorPaths>
242-
</configuration>
243-
</execution>
244-
</executions>
245-
</plugin>
246-
```
247-
248-
</TabItem>
249-
<TabItem value="java" label="Java">
250-
251-
**Maven (annotation processor):**
252-
253-
```xml
254-
<dependency>
255-
<groupId>st.orm</groupId>
256-
<artifactId>storm-metamodel-processor</artifactId>
257-
<scope>provided</scope>
258-
</dependency>
259-
```
260-
261-
**Gradle (Kotlin DSL):**
262-
263-
```kotlin
264-
dependencies {
265-
annotationProcessor("st.orm:storm-metamodel-processor:1.10.0")
266-
}
267-
```
268-
269-
</TabItem>
270-
</Tabs>
271-
272152
### Database Dialects
273153

274154
Storm works with any JDBC-compatible database out of the box. Dialect modules provide database-specific optimizations (e.g., native upsert syntax, tuple comparisons). Add the one that matches your database as a runtime dependency:

docs/string-templates.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,16 @@ Add the Storm compiler plugin to your Kotlin compiler configuration. The plugin
5858
The artifact version matches the Storm version (e.g., `1.10.0`).
5959

6060
<Tabs groupId="build">
61-
<TabItem value="maven" label="Maven" default>
61+
<TabItem value="gradle" label="Gradle (Kotlin DSL)" default>
62+
63+
```kotlin
64+
dependencies {
65+
kotlinCompilerPluginClasspath("st.orm:storm-compiler-plugin-2.0")
66+
}
67+
```
68+
69+
</TabItem>
70+
<TabItem value="maven" label="Maven">
6271

6372
Add the plugin jar as a dependency of `kotlin-maven-plugin`:
6473

@@ -77,15 +86,6 @@ Add the plugin jar as a dependency of `kotlin-maven-plugin`:
7786
</plugin>
7887
```
7988

80-
</TabItem>
81-
<TabItem value="gradle" label="Gradle (Kotlin DSL)">
82-
83-
```kotlin
84-
dependencies {
85-
kotlinCompilerPluginClasspath("st.orm:storm-compiler-plugin-2.0:${stormVersion}")
86-
}
87-
```
88-
8989
</TabItem>
9090
</Tabs>
9191

0 commit comments

Comments
 (0)