Hi,
First, to let you know, when we ask for a project with spring configuration processor on start.spring.io, the kapt
configuration is not defined and so, no configuration are generated /cc @sdeleuze.
I've comited the project just after generation here to let you know.
For my original issue, is when I try to use additional-spring-configuration-metadata.json
in kotlin / kapt / maven env. I didn't test it on gradle yet…
If I define a file, like described here (available here)
{
"groups": [
{
"name": "bar",
"type": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.FooProperties",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.FooProperties"
}
],
"properties": [
{
"name": "bar.uri",
"type": "java.net.URI",
"description": "URL of the bar component."
}
],
"hints": [
{
"name": "bar.uri",
"values": [
{
"value": "sample1"
},
{
"value": "sample2"
}
]
}
]
}
The file is not merged into the generated configuration properties. The result is:
{
"groups": [
{
"name": "foo",
"type": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.FooProperties",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.FooProperties"
},
{
"name": "foo.auth",
"type": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.AuthenticateProperties",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.FooProperties",
"sourceMethod": "getAuth()"
},
{
"name": "foo.auth.one",
"type": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.Method1",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.AuthenticateProperties",
"sourceMethod": "getOne()"
},
{
"name": "foo.auth.three",
"type": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.Method3",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.AuthenticateProperties",
"sourceMethod": "getThree()"
},
{
"name": "foo.auth.two",
"type": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.Method2",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.AuthenticateProperties",
"sourceMethod": "getTwo()"
}
],
"properties": [
{
"name": "foo.auth.one.key",
"type": "java.lang.String",
"description": "key used for method 1",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.Method1"
},
{
"name": "foo.auth.three.key",
"type": "java.lang.String",
"description": "key",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.Method3"
},
{
"name": "foo.auth.three.key-id",
"type": "java.lang.String",
"description": "keyid",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.Method3"
},
{
"name": "foo.auth.two.token",
"type": "java.lang.String",
"description": "token used for method 2",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.Method2"
},
{
"name": "foo.auth.url",
"type": "java.net.URI",
"description": "The url of the authenticate component",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.AuthenticateProperties"
},
{
"name": "foo.uri",
"type": "java.net.URI",
"description": "URL of the foo component",
"sourceType": "com.gitlab.davinkevin.issuekotlinconfigurationproperty.FooProperties"
}
],
"hints": []
}
Did I miss something on the KAPT configuration or there is a bug/missing feature to support it when used in KAPT?
For information, I tried to use this feature to overcome this potential bug 😓.
Thanks for the support. The complete code/example is available here
Comment From: snicoll
Thanks for the support. The complete code/example is available here
Thanks for sharing a sample that demonstrates the issue you're experiencing. Unfortunately, that link requires me to login. Can you please share a public repo?
Comment From: davinkevin
🤦♂️… I change the visibility of the project. This should be ok now.
Comment From: snicoll
Unfortunately, I don't think there is anything we can do without some help from JetBrains. I've reproduced the problem in both your project and our Kotlin tutorial sample project. There is also this question on StackOverflow that provides a workaround providing the explicit location of the additional metadata.
My best guess at this point is that the classpath is not in the state it should be when the annotation processor runs with kapt. I've asked for some help but I encourage you to create an issue in the JetBrains issue tracker. If you do, please add a link here so that we can follow along.
Comment From: snicoll
I've created https://youtrack.jetbrains.com/issue/KT-41217
Comment From: davinkevin
Thank you @snicoll, you were faster than me 👍.
Comment From: fanties
I found that there is no problem in spring boot version 2.3.x. since version 2.4, it can't be generated for kotlin。
Comment From: wilkinsona
@fanties Unfortunately, "it can't be generated for Kotlin" doesn't tell us enough to be able to help you. This issue isn't about the generation of metadata. It's about the merging of additional metadata into the generated metadata. If metadata isn't being generated at all then you have a different problem.
If you believe you've found a bug in Spring Boot, please open a new issue with a complete and minimal sample that reproduces the problem.