GitHub is used for project Source Code Management (SCM) using the SSH protocol for authentication.
- Create a GitHub account if you do not already have one.
- Setup GitHub access via SSH
You must install these tools:
-
git
: For source control -
java
: The language this SDK is built in. Java 9 is a minimum requirement to build the project. -
docker
: Required If Super-Linter needs to run locally
The sdk-java project requires that you develop (commit) code changes to branches that belong to a fork of the cdevents/sdk-java
repository in your GitHub account before submitting them as Pull Requests (PRs) to the actual project repository.
-
Create a fork of the
cdevents/sdk-java
repository in your GitHub account. -
Create a clone of your fork on your local machine:
git clone [email protected]:${YOUR_GITHUB_USERNAME}/sdk-java.git
-
Configure
git
remote repositoriesAdding
cdevents/sdk-java
as theupstream
and your fork as theorigin
remote repositories to your.git/config
sets you up nicely for regularly syncing your fork and submitting pull requests.-
Change into the project directory
cd sdk-java
-
Configure sdk-java as the
upstream
repositorygit remote add upstream [email protected]:cdevents/sdk-java.git # Optional: Prevent accidental pushing of commits by changing the upstream URL to `no_push` git remote set-url --push upstream no_push
-
Configure your fork as the
origin
repositorygit remote add origin [email protected]:${YOUR_GITHUB_USERNAME}/sdk-java.git
-
$ docker run -e RUN_LOCAL=true -e USE_FIND_ALGORITHM=true -v /path/to/local/codebase:/tmp/lint github/super-linter:v4
To run unit tests:
$ ./mvnw test
To run all targets, before creating a commit:
./mvnw verify
The Java SDK Generator is utilized to create events from the CDEvents Spec schemas, and the CDEvents Spec repository is added as a Git Submodule to this repository which needs to be updated with latest Spec release.
- Steps involved to generate latest SDK
-
Update spec submodule to the latest release
- Create a private working branch from cdevents/sdk-java
- Update submodule by running
git submodule update --init
- Checkout the latest release spec version to update the spec repo, from spec root directory
cd spec git checkout main && git pull git checkout <latest-release-tag> cd ../
- Verify the latest Spec is applied and Push the modified spec to your private working branch
-
Generate model classes from CDEvents Spec schemas using maven plugin
jsonschema2pojo
- Compare the existing
jsonschema2pojo
plugin configuration in the generator's pom.xml file with the available CDEvents Spec schemas - Add/update executions for
jsonschema2pojo
plugin configuration in the generator's pom.xml file as below,<execution> <id>generate-<subject>-<predicate>-from-schema</id> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> <configuration> <sourcePaths> <sourcePath>${parent.project.dir}/spec/schemas/<schema-file-name>.json</sourcePath> </sourcePaths> <targetPackage>dev.cdevents.models.<subject>.<predicate></targetPackage> </configuration> </execution>
- Where,
id
,sourcePath
needs to be updated with the actual file name andtargetPackage
directory structure needs to be created in sdk models for each new schema file if you find in CDEvents Spec schemas
- Compare the existing
-
The Schema Preprocessor updates the CDEvents Spec schemas to comply with
jsonschema2pojo
for generating model classes.
Currently 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
Example:from "$ref": "links/embeddedlinksarray" to "$ref": "links/embeddedlinksarray.json"
-
Generate CDEvent classes using mustache template
- event-template.mustache needs an update If there is any change in the
context
orsubject
of a CDEvent - All the CDEvents generated by using
event-template.mustache
- Java SDK Generator will be executed as a Maven module from the parent pom.xml
- event-template.mustache needs an update If there is any change in the
-
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 -
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.