Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update libs. Fix kotlin warnings. #1359

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies {

def openapiGenerate = tasks.register("generateOpenApi", OpenApiGeneratorTask) {
lang = "java"
generatedAnnotation = true
classpath.from(configurations.openapiGenerator)
openApiDefinition.convention(layout.projectDirectory.file("petstore.json"))
outputDirectory.convention(layout.buildDirectory.dir("generated/openapi"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ dependencies {

def openapiGenerate = tasks.register("generateOpenApi", OpenApiGeneratorTask) {
lang = "kotlin"
// Can't use generated annotation before this issue not fixed:
// https://github.com/micronaut-projects/micronaut-core/issues/10277
generatedAnnotation = false
classpath.from(configurations.openapiGenerator)
openApiDefinition.convention(layout.projectDirectory.file("petstore.json"))
outputDirectory.convention(layout.buildDirectory.dir("generated/openapi"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* would do. Must be used with the test entry point.
*/
public abstract class OpenApiGeneratorTask extends DefaultTask {

@Classpath
public abstract ConfigurableFileCollection getClasspath();

Expand All @@ -58,6 +59,9 @@ public abstract class OpenApiGeneratorTask extends DefaultTask {
@Input
public abstract Property<String> getLang();

@Input
public abstract Property<Boolean> getGeneratedAnnotation();

@OutputDirectory
public abstract DirectoryProperty getOutputDirectory();

Expand Down Expand Up @@ -90,6 +94,7 @@ public void execute() throws IOException {
var generatedSourcesDir = getGeneratedSourcesDirectory().get().getAsFile();
var generatedTestSourcesDir = getGeneratedTestSourcesDirectory().get().getAsFile();
var lang = getLang().get();
var generatedAnnotation = getGeneratedAnnotation().get();
Files.createDirectories(generatedSourcesDir.toPath());
Files.createDirectories(generatedTestSourcesDir.toPath());
getProject().getLogger().info("json: {}", getParameterMappings().get());
Expand All @@ -104,6 +109,7 @@ public void execute() throws IOException {
args.add(getParameterMappings().get().toString());
args.add(getResponseBodyMappings().get().toString());
args.add(lang.toUpperCase());
args.add(Boolean.toString(generatedAnnotation));
javaexec.args(args);
});
}
Expand Down
12 changes: 6 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ managed-freemarker = "2.3.32"
managed-pegdown = "1.6.0"

kotlin = "1.9.21"
ksp = "1.9.21-1.0.15"
ksp = "1.9.21-1.0.16"
jspecify = "0.3.0"
jdt-annotation = "2.2.800"
android-annotation = "1.7.0"
spotbugs-annotations = "4.8.2"
android-annotation = "1.7.1"
spotbugs-annotations = "4.8.3"
openapi-generator = "7.1.0"
swagger-parser = "1.0.68"
swagger-parser-v3 = "2.1.19"
javaparser = "3.25.7"
commons-codec = "1.16.0"

micronaut = "4.2.1"
micronaut = "4.2.2"
micronaut-platform = "4.2.2"
micronaut-security = "4.4.0"
micronaut-serde = "2.5.1"
micronaut-rxjava2 = "2.2.0"
Expand All @@ -28,11 +29,10 @@ micronaut-reactor = "3.2.0"
micronaut-gradle-plugin = "4.2.1"
micronaut-groovy = "4.1.0"
micronaut-validation = "4.2.0"
micronaut-data = "4.4.0"
micronaut-data = "4.4.1"
micronaut-test = "4.1.1"
micronaut-kotlin = "4.1.0"
micronaut-logging = "1.2.0"
micronaut-platform = "4.2.1"

[libraries]
# Core
Expand Down
5 changes: 1 addition & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ include 'test-suite-java-server-generator'
include 'test-suite-kotlin-kapt-client-generator'
include 'test-suite-kotlin-kapt-server-generator'
include 'test-suite-kotlin-ksp-client-generator'
// Skip it. Need to fix issues:
// https://github.com/micronaut-projects/micronaut-core/issues/10228
// https://github.com/micronaut-projects/micronaut-core/issues/10227
//include 'test-suite-kotlin-ksp-server-generator'
include 'test-suite-kotlin-ksp-server-generator'
include 'test-suite-generator-util'

dependencyResolutionManagement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ public class GeneratorMain {
* The main executable.
*
* @param args The argument array, consisting of:
* <ol>
* <li>Server or client boolean.</li>
* <li>The definition file path.</li>
* <li>The output directory.</li>
* <li>A comma-separated list of output kinds.</li>
* </ol>
* <ol>
* <li>Server or client boolean.</li>
* <li>The definition file path.</li>
* <li>The output directory.</li>
* <li>A comma-separated list of output kinds.</li>
* </ol>
*
* @throws URISyntaxException In case definition file path is incorrect.
*/
public static void main(String[] args) throws URISyntaxException {
boolean server = "server".equals(args[0]);
var lang = GeneratorLanguage.valueOf(args[6].toUpperCase());
var generatedAnnotation = Boolean.parseBoolean(args[7]);
List<ParameterMapping> parameterMappings =
parseParameterMappings(args[4]);
List<ResponseBodyMapping> responseBodyMappings =
Expand Down Expand Up @@ -84,24 +86,28 @@ public static void main(String[] args) throws URISyntaxException {
serverOptions.withControllerPackage("io.micronaut.openapi.test.controller");
// commented out because currently this would prevent the test project from compiling
// because we generate both abstract classes _and_ dummy implementations
serverOptions.withGenerateImplementationFiles(false);
serverOptions.withAuthentication(false);
serverOptions.withGenerateImplementationFiles(false)
.withAuthentication(false)
.withGeneratedAnnotation(generatedAnnotation);
});
} else {
builder.forJavaServer(serverOptions -> {
serverOptions.withControllerPackage("io.micronaut.openapi.test.controller");
// commented out because currently this would prevent the test project from compiling
// because we generate both abstract classes _and_ dummy implementations
serverOptions.withGenerateImplementationFiles(false);
serverOptions.withAuthentication(false);
serverOptions.withGenerateImplementationFiles(false)
.withAuthentication(false)
.withGeneratedAnnotation(generatedAnnotation);
});
}
} else {
if (lang == GeneratorLanguage.KOTLIN) {
builder.forKotlinClient(client -> {
client.withGeneratedAnnotation(generatedAnnotation);
});
} else {
builder.forJavaClient(client -> {
client.withGeneratedAnnotation(generatedAnnotation);
});
}
}
Expand Down Expand Up @@ -136,7 +142,7 @@ private static List<Map<String, String>> parseListOfMaps(String string) {
assert string.charAt(0) == '[';
int i = 1;

while(string.charAt(i) != ']') {
while (string.charAt(i) != ']') {
if (string.charAt(i) == ' ') {
++i;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,52 @@ open class RequestBodyController : RequestBodyApi {
return Mono.empty()
}

override fun sendListOfSimpleModels(simpleModels: List<SimpleModel>?): Mono<List<SimpleModel>> {
return Mono.just(simpleModels!!)
override fun sendListOfSimpleModels(simpleModel: List<SimpleModel>?): Mono<List<SimpleModel>> {
return Mono.just(simpleModel!!)
}

override fun sendModelWithRequiredProperties(model: ModelWithRequiredProperties?): Mono<ModelWithRequiredProperties> {
return Mono.just(model!!)
override fun sendModelWithRequiredProperties(modelWithRequiredProperties: ModelWithRequiredProperties?): Mono<ModelWithRequiredProperties> {
return Mono.just(modelWithRequiredProperties!!)
}

override fun sendDateModel(model: DateModel?): Mono<DateModel> {
return Mono.just(model!!)
override fun sendDateModel(dateModel: DateModel?): Mono<DateModel> {
return Mono.just(dateModel!!)
}

override fun sendEnum(color: String): Mono<ColorEnum> {
return Mono.just(fromValue(color.replace("\"", "")))
override fun sendEnum(body: String): Mono<ColorEnum> {
return Mono.just(fromValue(body.replace("\"", "")))
}

override fun sendEnumList(availableColors: List<ColorEnum>): Mono<List<ColorEnum>> {
return Mono.just(availableColors)
override fun sendEnumList(colorEnum: List<ColorEnum>): Mono<List<ColorEnum>> {
return Mono.just(colorEnum)
}

override fun sendModelWithMapProperty(model: ModelWithMapProperty): Mono<ModelWithMapProperty> {
return Mono.just(model)
override fun sendModelWithMapProperty(modelWithMapProperty: ModelWithMapProperty): Mono<ModelWithMapProperty> {
return Mono.just(modelWithMapProperty)
}

override fun sendModelWithValidatedListProperty(modelWithValidatedListProperty: ModelWithValidatedListProperty): Mono<Void> {
return Mono.empty()
}

override fun sendNestedModel(model: NestedModel): Mono<NestedModel> {
return Mono.just(model)
override fun sendNestedModel(nestedModel: NestedModel): Mono<NestedModel> {
return Mono.just(nestedModel)
}

override fun sendModelWithInnerEnum(model: ModelWithInnerEnum): Mono<ModelWithInnerEnum> {
return Mono.just(model)
override fun sendModelWithInnerEnum(modelWithInnerEnum: ModelWithInnerEnum): Mono<ModelWithInnerEnum> {
return Mono.just(modelWithInnerEnum)
}

override fun sendModelWithDiscriminator(model: Animal): Mono<Animal> {
return Mono.just(model)
override fun sendModelWithDiscriminator(animal: Animal): Mono<Animal> {
return Mono.just(animal)
}

override fun sendBytes(bytes: ByteArray?): Mono<ByteArray> {
return Mono.just(bytes!!)
override fun sendBytes(body: ByteArray?): Mono<ByteArray> {
return Mono.just(body!!)
}

override fun sendModelWithEnumList(model: ModelWithEnumList): Mono<ModelWithEnumList> {
return Mono.just(model)
override fun sendModelWithEnumList(modelWithEnumList: ModelWithEnumList): Mono<ModelWithEnumList> {
return Mono.just(modelWithEnumList)
}

override fun sendFile(file: CompletedFileUpload?): Mono<ByteArray> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.time.ZonedDateTime
* A response that contains information about last modification.
*
* @param <T> The response body type.
</T> */
*/
data class DatedResponse<T>(
@NonNull
var body: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.io.OutputStream
* A class for writing [DatedResponse] to the HTTP response with JSON body.
*
* @param <T> the type of the response body
</T> */
*/
@Singleton
@Produces(MediaType.APPLICATION_JSON)
@Order(-1)
Expand All @@ -34,7 +34,7 @@ internal class DatedResponseBodyWriter<T> private constructor(
override fun createSpecific(
type: Argument<DatedResponse<T>>
): MessageBodyWriter<DatedResponse<T>> {
val bt: Argument<T> = type.getTypeParameters()[0] as Argument<T>
val bt: Argument<T> = type.typeParameters[0] as Argument<T>
val writer = registry.findWriter(bt, listOf(MediaType.APPLICATION_JSON_TYPE))
.orElseThrow { ConfigurationException("No JSON message writer present") }
return DatedResponseBodyWriter(registry, writer, bt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class PageBodyWriter<T>(
constructor(registry: MessageBodyHandlerRegistry) : this(registry, null, null)

override fun createSpecific(type: Argument<Page<T>>): MessageBodyWriter<Page<T>> {
val bt: Argument<List<T>> = Argument.listOf(type.getTypeParameters()[0]) as Argument<List<T>>
val bt: Argument<List<T>> = Argument.listOf(type.typeParameters[0]) as Argument<List<T>>
val writer = registry.findWriter(bt, listOf(MediaType.APPLICATION_JSON_TYPE))
.orElseThrow { ConfigurationException("No JSON message writer present") }
return PageBodyWriter(registry, writer, bt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,52 @@ open class RequestBodyController : RequestBodyApi {
return Mono.empty()
}

override fun sendListOfSimpleModels(simpleModels: List<SimpleModel>?): Mono<List<SimpleModel>> {
return Mono.just(simpleModels!!)
override fun sendListOfSimpleModels(simpleModel: List<SimpleModel>?): Mono<List<SimpleModel>> {
return Mono.just(simpleModel!!)
}

override fun sendModelWithRequiredProperties(model: ModelWithRequiredProperties?): Mono<ModelWithRequiredProperties> {
return Mono.just(model!!)
override fun sendModelWithRequiredProperties(modelWithRequiredProperties: ModelWithRequiredProperties?): Mono<ModelWithRequiredProperties> {
return Mono.just(modelWithRequiredProperties!!)
}

override fun sendDateModel(model: DateModel?): Mono<DateModel> {
return Mono.just(model!!)
override fun sendDateModel(dateModel: DateModel?): Mono<DateModel> {
return Mono.just(dateModel!!)
}

override fun sendEnum(color: String): Mono<ColorEnum> {
return Mono.just(fromValue(color.replace("\"", "")))
override fun sendEnum(body: String): Mono<ColorEnum> {
return Mono.just(fromValue(body.replace("\"", "")))
}

override fun sendEnumList(availableColors: List<ColorEnum>): Mono<List<ColorEnum>> {
return Mono.just(availableColors)
override fun sendEnumList(colorEnum: List<ColorEnum>): Mono<List<ColorEnum>> {
return Mono.just(colorEnum)
}

override fun sendModelWithMapProperty(model: ModelWithMapProperty): Mono<ModelWithMapProperty> {
return Mono.just(model)
override fun sendModelWithMapProperty(modelWithMapProperty: ModelWithMapProperty): Mono<ModelWithMapProperty> {
return Mono.just(modelWithMapProperty)
}

override fun sendModelWithValidatedListProperty(modelWithValidatedListProperty: ModelWithValidatedListProperty): Mono<Void> {
return Mono.empty()
}

override fun sendNestedModel(model: NestedModel): Mono<NestedModel> {
return Mono.just(model)
override fun sendNestedModel(nestedModel: NestedModel): Mono<NestedModel> {
return Mono.just(nestedModel)
}

override fun sendModelWithInnerEnum(model: ModelWithInnerEnum): Mono<ModelWithInnerEnum> {
return Mono.just(model)
override fun sendModelWithInnerEnum(modelWithInnerEnum: ModelWithInnerEnum): Mono<ModelWithInnerEnum> {
return Mono.just(modelWithInnerEnum)
}

override fun sendModelWithDiscriminator(model: Animal): Mono<Animal> {
return Mono.just(model)
override fun sendModelWithDiscriminator(animal: Animal): Mono<Animal> {
return Mono.just(animal)
}

override fun sendBytes(bytes: ByteArray?): Mono<ByteArray> {
return Mono.just(bytes!!)
override fun sendBytes(body: ByteArray?): Mono<ByteArray> {
return Mono.just(body!!)
}

override fun sendModelWithEnumList(model: ModelWithEnumList): Mono<ModelWithEnumList> {
return Mono.just(model)
override fun sendModelWithEnumList(modelWithEnumList: ModelWithEnumList): Mono<ModelWithEnumList> {
return Mono.just(modelWithEnumList)
}

override fun sendFile(file: CompletedFileUpload?): Mono<ByteArray> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.time.ZonedDateTime
* A response that contains information about last modification.
*
* @param <T> The response body type.
</T> */
*/
data class DatedResponse<T>(
@NonNull
var body: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.io.OutputStream
* A class for writing [DatedResponse] to the HTTP response with JSON body.
*
* @param <T> the type of the response body
</T> */
*/
@Singleton
@Produces(MediaType.APPLICATION_JSON)
@Order(-1)
Expand All @@ -34,7 +34,7 @@ internal class DatedResponseBodyWriter<T> private constructor(
override fun createSpecific(
type: Argument<DatedResponse<T>>
): MessageBodyWriter<DatedResponse<T>> {
val bt: Argument<T> = type.getTypeParameters()[0] as Argument<T>
val bt: Argument<T> = type.typeParameters[0] as Argument<T>
val writer = registry.findWriter(bt, listOf(MediaType.APPLICATION_JSON_TYPE))
.orElseThrow { ConfigurationException("No JSON message writer present") }
return DatedResponseBodyWriter(registry, writer, bt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal class PageBodyWriter<T>(
constructor(registry: MessageBodyHandlerRegistry) : this(registry, null, null)

override fun createSpecific(type: Argument<Page<T>>): MessageBodyWriter<Page<T>> {
val bt: Argument<List<T>> = Argument.listOf(type.getTypeParameters()[0]) as Argument<List<T>>
val bt: Argument<List<T>> = Argument.listOf(type.typeParameters[0]) as Argument<List<T>>
val writer = registry.findWriter(bt, listOf(MediaType.APPLICATION_JSON_TYPE))
.orElseThrow { ConfigurationException("No JSON message writer present") }
return PageBodyWriter(registry, writer, bt)
Expand Down
Loading