Skip to content

Commit 0946fc5

Browse files
committed
On branch copilot/add-classical-code-gen-workflow-ready-for-review
modified: pom.xml - Add profiles for generating code and updating the schemas from which the code is generated. modified: scripts/codegen/java.ts - Address copilot comment: > requiredSet is computed but never used in renderNestedType(), which makes the generator harder to maintain (and can confuse future changes around nullability/boxing). Remove it or use it to drive required-vs-optional component typing if that’s the intent. Signed-off-by: Ed Burns <edburns@microsoft.com>
1 parent f51bcb4 commit 0946fc5

File tree

2 files changed

+98
-1
lines changed

2 files changed

+98
-1
lines changed

pom.xml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,5 +650,103 @@
650650
</plugins>
651651
</build>
652652
</profile>
653+
<!-- Update the @github/copilot npm schema package to a new version.
654+
Usage: mvn generate-sources -Pupdate-schemas-from-npm-artifact -Dcopilot.schema.version=1.0.25 -->
655+
<profile>
656+
<id>update-schemas-from-npm-artifact</id>
657+
<build>
658+
<plugins>
659+
<plugin>
660+
<groupId>org.codehaus.mojo</groupId>
661+
<artifactId>exec-maven-plugin</artifactId>
662+
<version>3.6.2</version>
663+
<executions>
664+
<execution>
665+
<id>update-copilot-schema-version</id>
666+
<phase>generate-sources</phase>
667+
<goals>
668+
<goal>exec</goal>
669+
</goals>
670+
<configuration>
671+
<executable>npm</executable>
672+
<workingDirectory>${project.basedir}/scripts/codegen</workingDirectory>
673+
<arguments>
674+
<argument>install</argument>
675+
<argument>@github/copilot@${copilot.schema.version}</argument>
676+
</arguments>
677+
</configuration>
678+
</execution>
679+
</executions>
680+
</plugin>
681+
<plugin>
682+
<groupId>org.apache.maven.plugins</groupId>
683+
<artifactId>maven-enforcer-plugin</artifactId>
684+
<version>3.5.0</version>
685+
<executions>
686+
<execution>
687+
<id>require-schema-version</id>
688+
<phase>validate</phase>
689+
<goals>
690+
<goal>enforce</goal>
691+
</goals>
692+
<configuration>
693+
<rules>
694+
<requireProperty>
695+
<property>copilot.schema.version</property>
696+
<message>You must specify -Dcopilot.schema.version=VERSION (e.g. 1.0.25)</message>
697+
</requireProperty>
698+
</rules>
699+
</configuration>
700+
</execution>
701+
</executions>
702+
</plugin>
703+
</plugins>
704+
</build>
705+
</profile>
706+
<!-- Run the TypeScript code generator to regenerate Java sources from the current schema.
707+
Usage: mvn generate-sources -Pcodegen -->
708+
<profile>
709+
<id>codegen</id>
710+
<build>
711+
<plugins>
712+
<plugin>
713+
<groupId>org.codehaus.mojo</groupId>
714+
<artifactId>exec-maven-plugin</artifactId>
715+
<version>3.6.2</version>
716+
<executions>
717+
<execution>
718+
<id>codegen-npm-install</id>
719+
<phase>generate-sources</phase>
720+
<goals>
721+
<goal>exec</goal>
722+
</goals>
723+
<configuration>
724+
<executable>npm</executable>
725+
<workingDirectory>${project.basedir}/scripts/codegen</workingDirectory>
726+
<arguments>
727+
<argument>ci</argument>
728+
</arguments>
729+
</configuration>
730+
</execution>
731+
<execution>
732+
<id>codegen-generate</id>
733+
<phase>generate-sources</phase>
734+
<goals>
735+
<goal>exec</goal>
736+
</goals>
737+
<configuration>
738+
<executable>npm</executable>
739+
<workingDirectory>${project.basedir}/scripts/codegen</workingDirectory>
740+
<arguments>
741+
<argument>run</argument>
742+
<argument>generate</argument>
743+
</arguments>
744+
</configuration>
745+
</execution>
746+
</executions>
747+
</plugin>
748+
</plugins>
749+
</build>
750+
</profile>
653751
</profiles>
654752
</project>

scripts/codegen/java.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,6 @@ function renderNestedType(nested: JavaClassDef, indentLevel: number, nestedTypes
431431
lines.push(`${ind}}`);
432432
} else if (nested.kind === "class" && nested.schema?.properties) {
433433
const localNestedTypes = new Map<string, JavaClassDef>();
434-
const requiredSet = new Set(nested.schema.required || []);
435434
const fields: { jsonName: string; javaName: string; javaType: string; description?: string }[] = [];
436435

437436
for (const [propName, propSchema] of Object.entries(nested.schema.properties)) {

0 commit comments

Comments
 (0)