Skip to content

Commit 2ff6446

Browse files
Fixed issues in AGENTS.md
1 parent e067228 commit 2ff6446

1 file changed

Lines changed: 17 additions & 38 deletions

File tree

AGENTS.md

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,45 @@ This document provides guidance for AI agents and developers working on this pro
44

55
## Java Version Requirements
66

7-
This project **compiles with Java 11** (as specified in `pom.xml` with `maven.compiler.source` and `maven.compiler.target` set to 11) but **must maintain Java 8 API compatibility**.
7+
This project **compiles with Java 11** (as specified in `pom.xml` with `maven.compiler.source` and
8+
`maven.compiler.target` set to 11) but **must maintain Java 8 API compatibility**.
89

9-
### CRITICAL: Java 8 API Compatibility
10-
11-
**The project enforces Java 8 API compatibility via animal-sniffer, even though it compiles with Java 11.**
12-
13-
This means:
14-
-**Allowed:** Java 8 language features (lambdas, method references, streams, Optional, etc.)
15-
-**Allowed:** Java 11 compiler and build tools
16-
-**NOT Allowed:** APIs added in Java 9+ (e.g., `Objects.requireNonNullElse()`, `List.of()`, `Map.of()`, `String.isBlank()`, etc.)
17-
18-
When modernizing code or adding features:
19-
1. Use Java 8 language syntax features freely (lambdas, streams, etc.)
20-
2. Only use APIs available in Java 8 (check the Javadoc version!)
21-
3. The animal-sniffer plugin will fail the build if you use Java 9+ APIs
22-
4. If in doubt, verify API availability at https://docs.oracle.com/javase/8/docs/api/
10+
For example, you're allowed to use Java 11 compiler features in the code base (such as type inference
11+
with `var`) but not any new standard library features introduced after Java 8, such as `VarHandle`.
12+
This is enforced at build time using the `animal-sniffer` enforcer plugin.
2313

2414
### Running Maven Commands
2515

26-
When running Maven commands, ensure you're using Java 11 by setting `JAVA_HOME`:
27-
28-
```bash
29-
JAVA_HOME=$(/usr/libexec/java_home -v 11) mvn <command>
30-
```
16+
**NB:** When running Maven commands, ensure you're using the Java 11 version of the JDK to avoid
17+
any build issues and ensure compatibility. The precise way to do so depends on developer machine
18+
setup.
3119

3220
### Common Commands
3321

3422
**Build the project:**
3523
```bash
36-
JAVA_HOME=$(/usr/libexec/java_home -v 11) mvn clean install
24+
mvn verify
3725
```
3826

3927
**Run tests:**
4028
```bash
41-
JAVA_HOME=$(/usr/libexec/java_home -v 11) mvn test
29+
mvn test
4230
```
4331

44-
**Apply code formatting (Spotless):**
32+
**Apply code formatting:**
4533
```bash
46-
JAVA_HOME=$(/usr/libexec/java_home -v 11) mvn spotless:apply
34+
mvn spotless:apply
4735
```
4836

49-
**Check code formatting:**
37+
**Check code formatting without applying changes:**
5038
```bash
51-
JAVA_HOME=$(/usr/libexec/java_home -v 11) mvn spotless:check
39+
mvn spotless:check
5240
```
5341

5442
## Code Formatting
5543

56-
This project uses [Spotless](https://github.com/diffplug/spotless) with google-java-format for code formatting.
44+
This project uses [Spotless](https://github.com/diffplug/spotless) with google-java-format for code
45+
formatting.
5746

5847
- All Java code must be formatted before committing
5948
- Run `mvn spotless:apply` to format code automatically
@@ -71,14 +60,4 @@ Key dependencies include:
7160
- Jackson for JSON serialization/deserialization
7261
- SLF4J for logging
7362
- JUnit 4 for testing
74-
- WireMock for HTTP mocking in tests
75-
76-
## Enforcement Rules
77-
78-
The project uses Maven Enforcer Plugin to ensure:
79-
- Bytecode version matches Java 11
80-
- **API compatibility with Java 8 (via animal-sniffer)** - This is enforced at build time and will fail if Java 9+ APIs are used
81-
82-
### Why Java 8 API Compatibility?
83-
84-
This library is designed to be usable by applications running on Java 8 JVMs, even though it's built with Java 11 tooling. This is a common pattern for libraries that want maximum compatibility while benefiting from modern build tools.
63+
- WireMock for HTTP mocking in tests

0 commit comments

Comments
 (0)