Skip to content

Commit 3d3780b

Browse files
authored
Merge pull request #111 from sourceplusplus/revert-110-codegen-removal
Revert "refactor: remove codegen module"
2 parents 0aee305 + b11db1e commit 3d3780b

File tree

5 files changed

+59
-2
lines changed

5 files changed

+59
-2
lines changed

build.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ dependencies {
7777
testImplementation("io.vertx:vertx-junit5:$vertxVersion")
7878
testImplementation("io.vertx:vertx-core:$vertxVersion")
7979

80-
kapt("io.vertx:vertx-codegen:$vertxVersion:processor")
81-
compileOnly("io.vertx:vertx-codegen:$vertxVersion")
80+
annotationProcessor("io.vertx:vertx-codegen:$vertxVersion:processor")
81+
kapt(findProject("codegen") ?: project(":protocol:codegen"))
8282

8383
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.21.0")
8484
}
@@ -142,3 +142,7 @@ spotless {
142142
licenseHeader(formattedLicenseHeader)
143143
}
144144
}
145+
146+
kapt {
147+
annotationProcessor("spp.protocol.codegen.ProtocolCodeGenProcessor")
148+
}

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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Source++, the open-source live coding platform.
3+
* Copyright (C) 2022 CodeBrig, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package spp.protocol.codegen
18+
19+
import io.vertx.codegen.CodeGen
20+
import io.vertx.codegen.CodeGenProcessor
21+
import org.joor.Reflect
22+
23+
/**
24+
* Better (but still hacky) fix for https://github.com/sourceplusplus/sourceplusplus/issues/430.
25+
*/
26+
@Suppress("unused")
27+
class ProtocolCodeGenProcessor : CodeGenProcessor() {
28+
init {
29+
val mappers = mutableListOf<List<CodeGen.Converter>>()
30+
Reflect.on(this).set("mappers", mappers)
31+
val inputStream = ProtocolCodeGenProcessor::class.java.getResource(
32+
"/META-INF/vertx/json-mappers.properties"
33+
)!!.openStream()
34+
Reflect.onClass(CodeGenProcessor::class.java).call("loadJsonMappers", mappers, inputStream)
35+
}
36+
}

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)