Skip to content

Commit

Permalink
Update with review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Jalander Ramagiri <[email protected]>
  • Loading branch information
Jalander Ramagiri committed Jun 5, 2024
1 parent 51b3ffc commit 88d3bdd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
18 changes: 14 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,19 @@ and the [CDEvents Spec repository](https://github.com/cdevents/spec/) is added a
````
- Where, `id`, `sourcePath` needs to be updated with the actual file name and `targetPackage` directory structure needs to be created in [sdk models](./sdk/src/main/java/dev/cdevents/models) for each new schema file if you find in CDEvents Spec schemas

3. Generate CDEvent classes using [mustache template](./generator/src/main/resources/template/event-template.mustache)
3. The [Schema Preprocessor](./preprocessor) updates the CDEvents Spec schemas to comply with `jsonschema2pojo` for generating model classes.</br>
Currently [PreprocessSchemas.java](./preprocessor/src/main/java/dev/cdevents/preprocessor/PreprocessSchemas.java) updates the schema's ref URL to include `.json` extension for all the spec schemas and will be executed as a Maven module from the parent [pom.xml](./pom.xml)</br>
Example:
````
from
"$ref": "links/embeddedlinksarray"
to
"$ref": "links/embeddedlinksarray.json"
````
4. Generate CDEvent classes using [mustache template](./generator/src/main/resources/template/event-template.mustache)
- [event-template.mustache](./generator/src/main/resources/template/event-template.mustache) needs an update If there is any change in the `context` or `subject` of a CDEvent
- All the [CDEvents](./sdk/src/main/java/dev/cdevents/events) generated by using `event-template.mustache`
- Run `./mvnw verify` and fix if any issues found during the build process
- Add/Update test cases for the new/updated events to validate that they are generated correctly in [sdk](./sdk)

- [Java SDK Generator](./generator) will be executed as a Maven module from the parent [pom.xml](./pom.xml)
5. Run `./mvnw verify` and fix if any issues found during the build process.</br>
Add/Update test cases for the new/updated events to validate that they are generated correctly in [sdk](./sdk)
6. Create a Code PR into `cdevents:main` from your private working branch and work on releasing the latest version of the SDK once the PR is merged.
4 changes: 2 additions & 2 deletions preprocessor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<maven.deploy.skip>true</maven.deploy.skip>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<sdk.project.dir>${project.basedir}/../sdk</sdk.project.dir>
<spec.schemas.dir>${project.basedir}/../spec/schemas</spec.schemas.dir>
<parent.project.dir>${project.basedir}/../</parent.project.dir>
</properties>

Expand Down Expand Up @@ -58,7 +58,7 @@
<configuration>
<mainClass>dev.cdevents.preprocessor.PreprocessSchemas</mainClass>
<arguments>
<argument>${parent.project.dir}</argument>
<argument>${spec.schemas.dir}</argument>
</arguments>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ private PreprocessSchemas() {
/**
*
* Main method to update schema files.
* @param args [0] - parent directory for the cdevents-sdk-java
* @param args [0] - spec schemas directory for the cdevents-sdk-java
*/
public static void main(String[] args) {
if (args == null || args.length != 1) {
System.err.println("Usage: PreprocessSchemas <schema_directory_path>");
throw new IllegalArgumentException("Prent directory path argument not passed to PreprocessSchemas");
System.err.println("Usage: PreprocessSchemas <spec_schemas_directory_path>");
throw new IllegalArgumentException("spec schemas directory path argument not passed to PreprocessSchemas");
}
String parentBaseDir = args[0];
String specSchemaDir = parentBaseDir + File.separator + "spec" + File.separator + "schemas";
String specSchemasDir = args[0];
try {
Files.walk(Paths.get(specSchemaDir))
Files.walk(Paths.get(specSchemasDir))
.filter(Files::isRegularFile)
.filter(path -> path.toString().endsWith(".json"))
.forEach(PreprocessSchemas::processFile);
Expand Down

0 comments on commit 88d3bdd

Please sign in to comment.