Add Kotlin support for "addGeneratedAnnotation" flag (#1115)

This adds logic so that the Kotlin code generator also supports the
"addGeneratedAnnotation" flag.

Also:
* Add Antora documentation
* Adjust names (generated-annotation -> add-generated-annotation)
* Adjust doc comments
This commit is contained in:
Daniel Chao
2025-07-08 14:05:15 -07:00
committed by GitHub
parent 3a35be6311
commit 48ad4386c8
14 changed files with 76 additions and 15 deletions

View File

@@ -190,7 +190,6 @@ public class PklPlugin implements Plugin<Project> {
configureBaseSpec(spec);
configureCodeGenSpec(spec);
spec.getAddGeneratedAnnotation().convention(false);
spec.getGenerateGetters().convention(false);
spec.getGenerateJavadoc().convention(false);
// Not using `convention()` so that users can disable generation of
@@ -207,7 +206,6 @@ public class PklPlugin implements Plugin<Project> {
.configure(
task -> {
configureCodeGenTask(task, spec);
task.getGeneratedAnnotation().set(spec.getAddGeneratedAnnotation());
task.getGenerateGetters().set(spec.getGenerateGetters());
task.getGenerateJavadoc().set(spec.getGenerateJavadoc());
task.getParamsAnnotation().set(spec.getParamsAnnotation());
@@ -354,6 +352,8 @@ public class PklPlugin implements Plugin<Project> {
spec.getImplementSerializable().convention(false);
spec.getAddGeneratedAnnotation().convention(false);
configureCodeGenSpecModulePath(spec);
}
@@ -454,6 +454,7 @@ public class PklPlugin implements Plugin<Project> {
task.getOutputDir().set(spec.getOutputDir());
task.getGenerateSpringBootConfig().set(spec.getGenerateSpringBootConfig());
task.getImplementSerializable().set(spec.getImplementSerializable());
task.getAddGeneratedAnnotation().set(spec.getAddGeneratedAnnotation());
task.getRenames().set(spec.getRenames());
}

View File

@@ -28,7 +28,7 @@ public abstract class CodeGenTask extends ModulesTask {
@Input
@Optional
public abstract Property<Boolean> getGeneratedAnnotation();
public abstract Property<Boolean> getAddGeneratedAnnotation();
@Input
public abstract Property<String> getIndent();

View File

@@ -47,7 +47,7 @@ public abstract class JavaCodeGenTask extends CodeGenTask {
getCliBaseOptions(),
getProject().file(getOutputDir()).toPath(),
getIndent().get(),
getGeneratedAnnotation().get(),
getAddGeneratedAnnotation().get(),
getGenerateGetters().get(),
getGenerateJavadoc().get(),
getGenerateSpringBootConfig().get(),

View File

@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ public abstract class KotlinCodeGenTask extends CodeGenTask {
getGenerateKdoc().get(),
getGenerateSpringBootConfig().get(),
getImplementSerializable().get(),
getAddGeneratedAnnotation().get(),
getRenames().get()))
.run();
}