From 88d3bddcc3bcfe72bba28c9771263310728f7ac9 Mon Sep 17 00:00:00 2001 From: Jalander Ramagiri Date: Wed, 5 Jun 2024 11:44:26 +0100 Subject: [PATCH] Update with review comments Signed-off-by: Jalander Ramagiri --- DEVELOPMENT.md | 18 ++++++++++++++---- preprocessor/pom.xml | 4 ++-- .../preprocessor/PreprocessSchemas.java | 11 +++++------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 2db3595..230015b 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -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.
+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)
+ 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) - \ No newline at end of file + - [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.
+ 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. \ No newline at end of file diff --git a/preprocessor/pom.xml b/preprocessor/pom.xml index 678d19f..15eb92b 100644 --- a/preprocessor/pom.xml +++ b/preprocessor/pom.xml @@ -21,7 +21,7 @@ true 11 11 - ${project.basedir}/../sdk + ${project.basedir}/../spec/schemas ${project.basedir}/../ @@ -58,7 +58,7 @@ dev.cdevents.preprocessor.PreprocessSchemas - ${parent.project.dir} + ${spec.schemas.dir} diff --git a/preprocessor/src/main/java/dev/cdevents/preprocessor/PreprocessSchemas.java b/preprocessor/src/main/java/dev/cdevents/preprocessor/PreprocessSchemas.java index 6b894e4..e29ccea 100644 --- a/preprocessor/src/main/java/dev/cdevents/preprocessor/PreprocessSchemas.java +++ b/preprocessor/src/main/java/dev/cdevents/preprocessor/PreprocessSchemas.java @@ -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 "); - throw new IllegalArgumentException("Prent directory path argument not passed to PreprocessSchemas"); + System.err.println("Usage: PreprocessSchemas "); + 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);