|
| 1 | +## Overview |
| 2 | + |
| 3 | +This is the Adyen Java API Library, providing Java developers with an easy way to interact with the Adyen API. The library is a wrapper around the Adyen API, generated from OpenAPI specifications. |
| 4 | + |
| 5 | +## Code Generation |
| 6 | + |
| 7 | +A significant portion of this library, particularly the API services and data models, is automatically generated |
| 8 | + |
| 9 | +- **Engine**: We use [OpenAPI Generator](https://openapi-generator.tech/) with custom [Mustache](https://mustache.github.io/) templates to convert Adyen's OpenAPI specifications into Java code. |
| 10 | +- **Templates**: The custom templates are located in the `/templates` directory. These templates are tailored to fit our custom HTTP client and model structure. |
| 11 | +- **Automation**: |
| 12 | + - **Centralized**: The primary generation process is managed in a separate repository, [`adyen-sdk-automation`](https://github.com/Adyen/adyen-sdk-automation). Changes to the OpenAPI specs trigger a GitHub workflow in that repository, which generates the code and opens Pull Requests in this library. |
| 13 | + - **Local**: For development and testing, you must use the [`adyen-sdk-automation`](https://github.com/Adyen/adyen-sdk-automation) repository. |
| 14 | + |
| 15 | +### Local Code Generation |
| 16 | + |
| 17 | +To test new features or changes to the templates, you must run the generation process from a local clone of the `adyen-sdk-automation` repository. |
| 18 | + |
| 19 | +1. **Clone the automation repository**: |
| 20 | + ```bash |
| 21 | + git clone https://github.com/Adyen/adyen-sdk-automation.git |
| 22 | + ``` |
| 23 | + |
| 24 | +2. **Link this library**: The automation project needs to target your local clone of `adyen-java-api-library`. From inside the `adyen-sdk-automation` directory, run the following commands. This will replace the `java/repo` directory with a symlink to your local project. |
| 25 | + ```bash |
| 26 | + rm -rf java/repo |
| 27 | + ln -s /path/to/your/adyen-java-api-library java/repo |
| 28 | + ``` |
| 29 | + |
| 30 | +3. **Run the generator**: You can now run the Gradle commands to generate code. |
| 31 | + - **To generate all services for the Java library**: |
| 32 | + ```bash |
| 33 | + ./gradlew :java:services |
| 34 | + ``` |
| 35 | + - **To generate a single service (e.g., Checkout)**: |
| 36 | + ```bash |
| 37 | + ./gradlew :java:checkout |
| 38 | + ``` |
| 39 | + - **To clean the repository before generating**: |
| 40 | + ```bash |
| 41 | + ./gradlew :java:cleanRepo :java:checkout |
| 42 | + ``` |
| 43 | + |
| 44 | +## Core Components |
| 45 | + |
| 46 | +- **`Client.java`**: The central class for configuring the library (API key, environment, etc.) and accessing API services. |
| 47 | +- **`Service.java`**: The base class for all API services, containing the generic HTTP client logic. |
| 48 | +- **`/service`**: This package contains the generated service classes (e.g., `Checkout`, `Management`) that expose methods for specific API endpoints. |
| 49 | +- **`/model`**: This package contains the generated data models used for API requests and responses. |
| 50 | + |
| 51 | +## Development Workflow |
| 52 | + |
| 53 | +This is a standard Maven project. |
| 54 | + |
| 55 | +### Building |
| 56 | + |
| 57 | +To compile the source code, run the tests, and package the project into a JAR file, use: |
| 58 | + |
| 59 | +```bash |
| 60 | +mvn install |
| 61 | +``` |
| 62 | + |
| 63 | +### Running Tests |
| 64 | + |
| 65 | +To execute the unit tests: |
| 66 | + |
| 67 | +```bash |
| 68 | +mvn test |
| 69 | +``` |
| 70 | + |
| 71 | +### Code Style & Formatting |
| 72 | + |
| 73 | +We use Checkstyle for linting and Spotless for formatting. |
| 74 | + |
| 75 | +- **Check for style violations**: |
| 76 | + ```bash |
| 77 | + mvn checkstyle:check |
| 78 | + ``` |
| 79 | +- **Apply formatting**: |
| 80 | + ```bash |
| 81 | + mvn spotless:apply |
| 82 | + ``` |
| 83 | + |
| 84 | +The build will fail if there are any Checkstyle violations. Run `spotless:apply` before committing. |
| 85 | + |
| 86 | +## Release Process |
| 87 | + |
| 88 | +The release process is automated via GitHub Actions. When a release is triggered: |
| 89 | +1. A script determines the next version number (major, minor, or patch). |
| 90 | +2. The `pom.xml` and other version files are updated. |
| 91 | +3. A pull request is created with the version bump. |
| 92 | +4. Once merged, a GitHub release is created, and the new version is published to Maven Central. |
0 commit comments