Closed mustafakibar closed 5 years ago
you need to add -Acodegen.generators=sc_data_object_converters
to you annotation processor compiler args. it's should be like that
task<JavaCompile>("annotationProcessing") {
source = fileTree("${project.projectDir}/src/main/kotlin")
classpath = configurations.compile.get() + configurations.compileOnly.get()
destinationDir = project.file("build/generated")
options.annotationProcessorPath = classpath
options.compilerArgs = listOf(
"-proc:only",
"-processor", "io.vertx.codegen.CodeGenProcessor",
"-Acodegen.output=${project.projectDir}/src/main/",
"-Acodegen.generators=sc_data_object_converters"
)
}
without that argument, it will load all the generator, so you must config all the generator which you required.
tasks {
register<JavaCompile>("annotationProcessing") {
source("src/main/kotlin")
classpath = configurations["annotationProcessor"] + configurations["compile"] + configurations["compileOnly"]
destinationDir = project.file("build/generated")
options.annotationProcessorPath = classpath
options.annotationProcessorGeneratedSourcesDirectory = file("build/generated")
options.compilerArgs = listOf(
"-proc:only",
"-processor", "io.vertx.codegen.CodeGenProcessor",
"-Acodegen.output=${project.projectDir}/src/main/",
"-Acodegen.generators=sc_data_object_converters"
)
}
getByName("compileJava").dependsOn("annotationProcessing")
}
sourceSets {
getByName("main").resources.srcDirs("conf", "src/main/resources")
getByName("main").java.srcDirs("src/main/kotlin", "src/main/java", "build/generated")
getByName("test").java.srcDirs("src/test/kotlin", "src/test/java")
}
Thank you for interest I tried it unfortunately did not work 😞 I have tried different combinations as follows but nothing changed;
kapt(Config.Libs.vertx_codegen_kapt)
> annotationProcessor(Config.Libs.vertx_codegen_kapt)
options.annotationProcessorPath = classpath
> options.annotationProcessorPath = configurations.annotationProcessor.get()
Config.Libs.vertx_codegen_kapt = io.vertx:vertx-codegen:3.8.1:processor
sorry, I missed a very important configuration. For gradle 5 and above, you need to configure the dependency of annotation processor
separately.
dependencies {
annotationProcessor("io.vertx:vertx-codegen:$version")
//other dependencies which annotation processor depends on
}
Yes I tried but it didnt work. If I change kapt to annotationProcessor of the previous comment this time I got an error like that 'Annotation Processor io.vertx.codegen.CodeGenProcessor not found' .
Can you provide the simplest code to reproduce on github?
here is the reproduce: repo-link
Sorry, I saw that you are using the JavaCompile task, I mistakenly think that your DataObject is a Java class. If you use the kotlin class, it seems that you can only use kapt to execute codegen I submitted a pr so that I can delete my repository and the links discussed in this issue will not return 404. https://github.com/mustafakibar/vertx-codegen.snake-case/pull/1
Working smoothly thanks!
I have a project with vert.x(3.8.1), kotlin(1.3.50) and gradle(5.6). I have many classes marked as
@DataObject(generateConverter = true)
.Also I want to use snake_case format on generated files so I'm using @eutkin sample
https://github.com/eutkin/vertx-gen-snake-case
.Response class:
When I was build my project then I look at the ResponseConverter class, but as you see below keys not the snake_case format. After a few attempts, I saw that the codegen processor does not use the
DataObjectHelperGeneratorLoader
but I already defined under resources. What's wrong?Project structure:
build.gradle.kts:
io.vertx.codegen.GeneratorLoader:
io.github.eutkin.snakecase.DataObjectHelperGeneratorLoader