Skip to content

Commit

Permalink
WIP: feat: use detekt to extract kotlin schema
Browse files Browse the repository at this point in the history
fixes #530
  • Loading branch information
worstell committed Nov 3, 2023
1 parent 1ddb00b commit 168420d
Show file tree
Hide file tree
Showing 8 changed files with 639 additions and 23 deletions.
52 changes: 32 additions & 20 deletions examples/echo-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,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 +83,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,6 +112,7 @@
</goals>
<configuration>
<outputFile>${project.build.directory}/classpath.txt</outputFile>
<outputProperty>generated.classpath</outputProperty>
<prefix>dependency</prefix>
</configuration>
</execution>
Expand Down Expand Up @@ -173,6 +161,30 @@
</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>17</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>ctr</goal>
</goals>
</execution>
</executions>
</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
29 changes: 26 additions & 3 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 @@ -32,10 +33,16 @@
<version>1.6.4</version>
</dependency>

<!-- <dependency>-->
<!-- <groupId>com.google.devtools.ksp</groupId>-->
<!-- <artifactId>symbol-processing-api</artifactId>-->
<!-- <version>1.9.20-RC-1.0.13</version>-->
<!-- </dependency>-->

<dependency>
<groupId>com.google.devtools.ksp</groupId>
<artifactId>symbol-processing-api</artifactId>
<version>1.9.20-RC-1.0.13</version>
<groupId>io.gitlab.arturbosch.detekt</groupId>
<artifactId>detekt-api</artifactId>
<version>${detekt.version}</version>
</dependency>

<!-- Classgraph -->
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 168420d

Please sign in to comment.