Skip to content

Commit

Permalink
feat: use detekt to extract kotlin schema (#549)
Browse files Browse the repository at this point in the history
fixes #530
  • Loading branch information
worstell authored Nov 3, 2023
1 parent 0694253 commit 714bbc9
Show file tree
Hide file tree
Showing 9 changed files with 725 additions and 63 deletions.
63 changes: 42 additions & 21 deletions examples/echo-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<java.version>11</java.version>
<kotlin.version>1.9.0</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>

<dependencies>
Expand Down Expand Up @@ -62,26 +64,6 @@
</configuration>
</execution>
</executions>
<configuration>
<compilerPlugins>
<compilerPlugin>ksp</compilerPlugin>
</compilerPlugins>
<pluginOptions>
<option>ksp:apoption=dest=${project.build.directory}</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>com.dyescape</groupId>
<artifactId>kotlin-maven-symbol-processing</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ftl-runtime</artifactId>
<version>${ftl.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- Download the Wire compiler. -->
<plugin>
Expand All @@ -103,6 +85,13 @@
<classifier>jar-with-dependencies</classifier>
<destFileName>ftl-generator.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>xyz.block</groupId>
<artifactId>ftl-runtime</artifactId>
<version>${ftl.version}</version>
<classifier>jar-with-dependencies</classifier>
<destFileName>ftl-runtime.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
Expand All @@ -125,7 +114,8 @@
</goals>
<configuration>
<outputFile>${project.build.directory}/classpath.txt</outputFile>
<prefix>dependency</prefix>
<outputProperty>generated.classpath</outputProperty>
<prefix>${project.build.directory}/dependency</prefix>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -173,6 +163,37 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.ozsie</groupId>
<artifactId>detekt-maven-plugin</artifactId>
<version>1.23.3</version>
<configuration>
<disableDefaultRuleSets>true</disableDefaultRuleSets>
<classPath>${generated.classpath}</classPath>
<jvmTarget>${java.version}</jvmTarget>
<config>${project.build.directory}/detekt.yml</config>
<plugins>
<plugin>
${project.build.directory}/dependency/ftl-runtime-${ftl.version}.jar
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check-with-type-resolution</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>xyz.block</groupId>
<artifactId>ftl-runtime</artifactId>
<version>${ftl.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
63 changes: 42 additions & 21 deletions examples/online-boutique/services/ad-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<java.version>11</java.version>
<kotlin.version>1.9.0</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>

<dependencies>
Expand Down Expand Up @@ -62,26 +64,6 @@
</configuration>
</execution>
</executions>
<configuration>
<compilerPlugins>
<compilerPlugin>ksp</compilerPlugin>
</compilerPlugins>
<pluginOptions>
<option>ksp:apoption=dest=${project.build.directory}</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>com.dyescape</groupId>
<artifactId>kotlin-maven-symbol-processing</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>ftl-runtime</artifactId>
<version>${ftl.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- Download the Wire compiler. -->
<plugin>
Expand All @@ -103,6 +85,13 @@
<classifier>jar-with-dependencies</classifier>
<destFileName>ftl-generator.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>xyz.block</groupId>
<artifactId>ftl-runtime</artifactId>
<version>${ftl.version}</version>
<classifier>jar-with-dependencies</classifier>
<destFileName>ftl-runtime.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
Expand All @@ -125,7 +114,8 @@
</goals>
<configuration>
<outputFile>${project.build.directory}/classpath.txt</outputFile>
<prefix>dependency</prefix>
<outputProperty>generated.classpath</outputProperty>
<prefix>${project.build.directory}/dependency</prefix>
</configuration>
</execution>
</executions>
Expand Down Expand Up @@ -172,6 +162,37 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.ozsie</groupId>
<artifactId>detekt-maven-plugin</artifactId>
<version>1.23.3</version>
<configuration>
<disableDefaultRuleSets>true</disableDefaultRuleSets>
<classPath>${generated.classpath}</classPath>
<jvmTarget>${java.version}</jvmTarget>
<config>${project.build.directory}/detekt.yml</config>
<plugins>
<plugin>
${project.build.directory}/dependency/ftl-runtime-${ftl.version}.jar
</plugin>
</plugins>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check-with-type-resolution</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>xyz.block</groupId>
<artifactId>ftl-runtime</artifactId>
<version>${ftl.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ class ModuleGenerator() {
""".trimIndent()
)

Path.of(buildDir, "detekt.yml").writeText(
"""
SchemaExtractorRuleSet:
ExtractSchemaRule:
active: true
output: ${buildDir}
""".trimIndent()
)

val mainFile = Path.of(buildDir, "main")
mainFile.writeText(
"""
Expand Down
23 changes: 23 additions & 0 deletions kotlin-runtime/ftl-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<properties>
<rootDir>${basedir}/../..</rootDir>
<maven.deploy.skip>false</maven.deploy.skip>
<detekt.version>1.23.1</detekt.version>
</properties>

<dependencies>
Expand All @@ -38,6 +39,12 @@
<version>1.9.20-RC-1.0.13</version>
</dependency>

<dependency>
<groupId>io.gitlab.arturbosch.detekt</groupId>
<artifactId>detekt-api</artifactId>
<version>${detekt.version}</version>
</dependency>

<!-- Classgraph -->
<dependency>
<groupId>io.github.classgraph</groupId>
Expand All @@ -51,6 +58,22 @@
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>io.gitlab.arturbosch.detekt</groupId>
<artifactId>detekt-test</artifactId>
<version>${detekt.version}</version>
<exclusions>
<!-- Exclude Kotlin Main KTS to fix SLF4J diamond dependency problem. -->
<exclusion>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-main-kts</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
Loading

0 comments on commit 714bbc9

Please sign in to comment.