Skip to content

Commit 15ba174

Browse files
committed
1 parent 1e5f6dd commit 15ba174

File tree

6 files changed

+62
-19
lines changed

6 files changed

+62
-19
lines changed

build.gradle.kts

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,9 @@ kotlin {
114114
}
115115

116116
dependencies {
117-
"kapt"("io.vertx:vertx-codegen:$vertxVersion:processor")
118-
}
119-
120-
//todo: this is a hack to get json-mappers.properties working correctly
121-
project.tasks {
122-
all {
123-
copy {
124-
doFirst {
125-
file("$projectDir/src/jvmMain/resources/META-INF/vertx/json-mappers.properties")
126-
.copyTo(file("$buildDir/generated/source/kapt/main/META-INF/vertx/json-mappers.properties"), overwrite = true)
127-
}
128-
}
129-
}
130-
register("cleanProcessedResources") {
131-
doFirst {
132-
file("$buildDir/processedResources").deleteRecursively()
133-
}
134-
}
135-
getByName("jvmProcessResources").dependsOn("cleanProcessedResources")
117+
val kapt by configurations
118+
kapt("io.vertx:vertx-codegen:$vertxVersion:processor")
119+
kapt(findProject("codegen") ?: project(":protocol:codegen"))
136120
}
137121

138122
configure<org.jetbrains.kotlin.noarg.gradle.NoArgExtension> {
@@ -153,3 +137,7 @@ spotless {
153137
licenseHeaderFile(file("LICENSE-HEADER.txt"))
154138
}
155139
}
140+
141+
kapt {
142+
annotationProcessor("spp.protocol.codegen.ProtocolCodeGenProcessor")
143+
}

codegen/build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
kotlin("jvm")
3+
}
4+
5+
val vertxVersion: String by project
6+
val joorVersion: String by project
7+
8+
repositories {
9+
mavenCentral()
10+
}
11+
12+
dependencies {
13+
implementation("io.vertx:vertx-codegen:$vertxVersion")
14+
implementation("org.jooq:joor:$joorVersion")
15+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Source++, the open-source live coding platform.
3+
* Copyright (C) 2022 CodeBrig, Inc.
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published
7+
* by the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
package spp.protocol.codegen
19+
20+
import io.vertx.codegen.CodeGen
21+
import io.vertx.codegen.CodeGenProcessor
22+
import org.joor.Reflect
23+
24+
/**
25+
* Better (but still hacky) fix for https://github.com/sourceplusplus/live-platform/issues/430.
26+
*/
27+
@Suppress("unused")
28+
class ProtocolCodeGenProcessor : CodeGenProcessor() {
29+
init {
30+
val mappers = mutableListOf<List<CodeGen.Converter>>()
31+
Reflect.on(this).set("mappers", mappers)
32+
val inputStream = ProtocolCodeGenProcessor::class.java.getResource(
33+
"/META-INF/vertx/json-mappers.properties"
34+
)!!.openStream()
35+
Reflect.onClass(CodeGenProcessor::class.java).call("loadJsonMappers", mappers, inputStream)
36+
}
37+
}

src/jvmMain/resources/META-INF/vertx/json-mappers.properties renamed to codegen/src/main/resources/META-INF/vertx/json-mappers.properties

File renamed without changes.

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ jacksonVersion=2.13.1
88
slf4jVersion=1.7.33
99
kotlinxDatetime=0.4.0
1010
kotlinxSerializationJson=1.3.3
11+
joorVersion=0.9.13

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ pluginManagement {
1010
}
1111

1212
rootProject.name = 'protocol'
13+
14+
include "codegen"

0 commit comments

Comments
 (0)