|
| 1 | +# Agent Notes for this Repository (openapi-diff) |
| 2 | +This file is written for agentic coding tools working in this repo. It captures the |
| 3 | +project's build/test/format commands and the house style that the CI and formatter |
| 4 | +expect. |
| 5 | + |
| 6 | +## At-a-glance |
| 7 | +- Tech: multi-module Maven (Java), source/target = 1.8 (see `pom.xml`). |
| 8 | +- Modules: `core/` (library), `cli/` (shaded CLI jar), `maven/` (Maven plugin), |
| 9 | + `maven-example/` (example usage; install/deploy skipped). |
| 10 | +- CI runs `./mvnw ... verify` on JDK 8/11/17/21 (see `.github/workflows/*.yml`). |
| 11 | +- Formatting: `com.coveo:fmt-maven-plugin` (see `pom.xml`). |
| 12 | + |
| 13 | +## Cursor / Copilot rules |
| 14 | +- Cursor rules: none found (no `.cursor/rules/` and no `.cursorrules`). |
| 15 | +- Copilot rules: none found (no `.github/copilot-instructions.md`). |
| 16 | + |
| 17 | +## Commands |
| 18 | +Use the Maven wrapper (`./mvnw`) when possible to match CI. |
| 19 | + |
| 20 | +### Build |
| 21 | +```bash |
| 22 | +# compile + run unit tests (all modules) |
| 23 | +./mvnw test |
| 24 | + |
| 25 | +# full CI-style verification (unit tests + packaging) |
| 26 | +./mvnw verify |
| 27 | + |
| 28 | +# clean build |
| 29 | +./mvnw clean verify |
| 30 | + |
| 31 | +# build just one module (and its deps) |
| 32 | +./mvnw -pl core -am verify |
| 33 | +./mvnw -pl cli -am package |
| 34 | + |
| 35 | +# CI-style (adds some output + jacoco report) |
| 36 | +./mvnw -V -B -ntp -ff verify jacoco:report |
| 37 | +``` |
| 38 | + |
| 39 | +Notes: |
| 40 | +- For faster local iteration, add `-DskipTests=true` when appropriate. |
| 41 | + |
| 42 | +### Format / "lint" |
| 43 | +```bash |
| 44 | +# auto-format Java sources |
| 45 | +./mvnw com.coveo:fmt-maven-plugin:format |
| 46 | + |
| 47 | +# if the plugin supports it, fail if formatting differs (use in CI-like loops) |
| 48 | +./mvnw com.coveo:fmt-maven-plugin:check |
| 49 | +``` |
| 50 | + |
| 51 | +Git hook: |
| 52 | +- A local pre-commit hook may run formatting (`.git/hooks/pre-commit` runs |
| 53 | + `./mvnw com.coveo:fmt-maven-plugin:format`). Don't rely on it; run format |
| 54 | + explicitly when you change Java files. |
| 55 | + |
| 56 | +### Tests |
| 57 | +```bash |
| 58 | +# run all tests |
| 59 | +./mvnw test |
| 60 | + |
| 61 | +# run tests for a single module |
| 62 | +./mvnw -pl core test |
| 63 | +./mvnw -pl maven test |
| 64 | + |
| 65 | +# run a single test class (Surefire) |
| 66 | +./mvnw -pl core -Dtest=OpenApiDiffTest test |
| 67 | + |
| 68 | +# run a single test method (JUnit 5 via Surefire) |
| 69 | +./mvnw -pl core -Dtest=OpenApiDiffTest#testDiff test |
| 70 | +``` |
| 71 | + |
| 72 | +Notes: |
| 73 | +- Test classes must match Surefire includes (convention here is `*Test.java`). |
| 74 | +- If you only changed `cli/`, tests likely live in `core/`; run `./mvnw -pl core test`. |
| 75 | + |
| 76 | +### Docker-oriented build |
| 77 | +The `docker` Maven profile disables tests/javadoc/sources and sets `fmt.skip`. |
| 78 | + |
| 79 | +```bash |
| 80 | +./mvnw -Pdocker package |
| 81 | +docker build -t local-openapi-diff . |
| 82 | +``` |
| 83 | + |
| 84 | +### Running the CLI from source |
| 85 | + |
| 86 | +```bash |
| 87 | +# build shaded jar |
| 88 | +./mvnw -pl cli -am package |
| 89 | + |
| 90 | +# run (jar name includes version; use the *-all classifier) |
| 91 | +java -jar cli/target/openapi-diff-cli-*-all.jar --help |
| 92 | +``` |
| 93 | + |
| 94 | +## Code style guidelines |
| 95 | +### Formatting |
| 96 | +- Always run `./mvnw com.coveo:fmt-maven-plugin:format` after editing Java. |
| 97 | +- Don't fight the formatter; structure code so it reads well after formatting. |
| 98 | +- Keep lines/blocks simple; prefer extracting helper methods over deeply nested |
| 99 | + ternaries or chained calls. |
| 100 | + |
| 101 | +### Imports |
| 102 | +- Let the formatter manage import ordering. |
| 103 | +- Avoid wildcard imports. |
| 104 | +- In tests, static imports are common and preferred for AssertJ: |
| 105 | + `import static org.assertj.core.api.Assertions.assertThat;` |
| 106 | + |
| 107 | +### Java language level |
| 108 | +- Code must compile with Java 8 (no `var`, records, text blocks, etc.). |
| 109 | +- Avoid APIs added after Java 8 even if they compile on newer JDKs. |
| 110 | + |
| 111 | +### Naming and structure |
| 112 | +- Packages stay under `org.openapitools.openapidiff`. |
| 113 | +- Classes: `PascalCase`; methods/fields: `lowerCamelCase`. |
| 114 | +- Constants: `UPPER_SNAKE_CASE` and `static final`. |
| 115 | +- Prefer "Diff" suffix for comparison components (`*Diff`, `*DiffResult`). |
| 116 | +- Tests: `*Test` for unit tests; use descriptive test method names. |
| 117 | + |
| 118 | +### Types, nulls, and collections |
| 119 | +- Be explicit about ownership/mutability. Prefer returning empty collections over |
| 120 | + `null` when you control the API. |
| 121 | +- When interacting with Swagger/OpenAPI models, expect nullable fields and guard |
| 122 | + accordingly. |
| 123 | +- Prefer `final` for local variables/fields when it improves readability. |
| 124 | + |
| 125 | +### Error handling and logging |
| 126 | + |
| 127 | +- Library code: throw useful runtime exceptions for invalid input (see `OpenApiCompare.notNull(...)`). |
| 128 | +- Avoid swallowing exceptions silently; log or rethrow. |
| 129 | +- CLI / Maven plugin: prefer user-actionable messages; use SLF4J; use `MojoExecutionException`/`MojoFailureException`. |
| 130 | + |
| 131 | +### Testing conventions |
| 132 | +- Frameworks: JUnit Jupiter (JUnit 5) + AssertJ. |
| 133 | +- Keep tests deterministic; avoid depending on network. |
| 134 | +- Put fixtures in `*/src/test/resources/` and reference them in a way that works |
| 135 | + when Maven runs from the module directory. |
| 136 | +- When adding behavior, add a focused test in `core/` unless the change is truly |
| 137 | + CLI-only or Maven-plugin-only. |
| 138 | + |
| 139 | +## Repository hygiene |
| 140 | +- Line endings: contributors recommend `git config core.autocrlf input` |
| 141 | + (see `CONTRIBUTING.md`). |
| 142 | +- Prefer small, reviewable changes; add tests with fixes. |
| 143 | +- Do not commit generated artifacts (`target/`, shaded jars, etc.). |
0 commit comments