Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ docs/ Developer documentation (see below)
./gradlew :dd-java-agent:shadowJar # Build agent jar only (dd-java-agent/build/libs/)
./gradlew :path:to:module:test # Run tests for a specific module
./gradlew :path:to:module:test -PtestJvm=11 # Test on a specific JVM version
./gradlew spotlessApply # Auto-format code (google-java-format)
./gradlew spotlessApply # Auto-format code (Palantir Java Format, GOOGLE style)
./gradlew spotlessCheck # Verify formatting
```

## Code conventions

- **Formatting**: google-java-format enforced via Spotless. Run `./gradlew spotlessApply` before committing.
- **Formatting**: Palantir Java Format with `GOOGLE` style enforced via Spotless. Run `./gradlew spotlessApply` before committing.
- **Static imports**: Prefer static imports over class-qualified calls for call-style helpers, in both test (Assertions.assertEquals, Mockito.mock) and production code (Collections.emptyList). Wildcard imports disallowed — see CONTRIBUTING.md.
- **Documentation**: Use concise Javadoc comments (`/** ... */`) for class, method, and field documentation.
- **Instrumentation layout**: `dd-java-agent/instrumentation/{framework}/{framework}-{minVersion}/`
Expand Down
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ We have automatic code formatting enabled in Gradle configuration using [Spotles
Our main goal is to avoid extensive reformatting caused by different IDEs with different opinions about how things should
be formatted by establishing a single _point of truth_.

Java sources use [Palantir Java Format](https://github.com/palantir/palantir-java-format) with its `GOOGLE` style:
two-space indentation and a 100-character line width.

To reformat all the files that need reformatting:

```bash
Expand All @@ -55,13 +58,15 @@ For IntelliJ IDEA, we suggest the following settings and plugin.
* `Use single class import`: checked
* `Class count to use import with '*'`: `9999` (some number sufficiently large that is unlikely to matter)
* `Names count to use static import with '*'`: `9999`
* Use the following import layout to ensure consistency with google-java-format:
* Use the following import layout:
![import layout](https://user-images.githubusercontent.com/734411/43430811-28442636-94ae-11e8-86f1-f270ddcba023.png)
* top right Settings icon -> `Settings...` ->`Editor` > `Code Style` > `Groovy` > `Imports`
* `Class count to use import with '*'`: `9999` (some number sufficiently large that is unlikely to matter)
* `Names count to use static import with '*'`: `9999`
* To run test in a specific JDK use the `testJvm` property, e.g. `-PtestJvm=11`
* Install the [Google Java Format](https://plugins.jetbrains.com/plugin/8527-google-java-format) plugin
* Format Java sources with the Spotless Gradle tasks above. Do not enable the
[Palantir Java Format](https://plugins.jetbrains.com/plugin/13180-palantir-java-format) plugin for this project: it
currently exposes only the default `PALANTIR` style, while this project uses `GOOGLE`.

### Static imports

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ with(extensions["spotlessPredeclare"] as SpotlessExtension) {
removeUnusedImports()
forbidWildcardImports()

googleJavaFormat(libs.versions.google.java.format.get())
palantirJavaFormat(libs.versions.palantir.java.format.get()).style("GOOGLE")
tableTestFormatter(libs.versions.tabletest.formatter.get())
}
groovyGradle {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spotless {
targetExclude("src/test/resources/**")
removeUnusedImports()
forbidWildcardImports()
googleJavaFormat(libs.versions.google.java.format.get())
palantirJavaFormat(libs.versions.palantir.java.format.get()).style("GOOGLE")
}
}

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/modifiable-config-agent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spotless {
targetExclude("src/test/resources/**")
removeUnusedImports()
forbidWildcardImports()
googleJavaFormat(libs.versions.google.java.format.get())
palantirJavaFormat(libs.versions.palantir.java.format.get()).style("GOOGLE")
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ shadow = "9.4.2"
spotbugs_annotations = "4.10.3"

# Source code formatters
google-java-format = "1.36.1"
palantir-java-format = "2.97.0"
greclipse = "4.27" # Pinned. See: https://github.com/diffplug/spotless/issues/3013
ktlint = "1.8.0"
scalafmt = "3.11.5"
Expand Down
2 changes: 1 addition & 1 deletion gradle/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spotless {
targetExclude('src/test/resources/**', buildDirectory)
removeUnusedImports()
forbidWildcardImports()
googleJavaFormat(libs.versions.google.java.format.get())
palantirJavaFormat(libs.versions.palantir.java.format.get()).style("GOOGLE")
tableTestFormatter(libs.versions.tabletest.formatter.get())
}
}
Expand Down
2 changes: 1 addition & 1 deletion test-published-dependencies/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ allprojects {
target("src/**/*.java")
removeUnusedImports()
forbidWildcardImports()
googleJavaFormat(libs.versions.google.java.format.get())
palantirJavaFormat(libs.versions.palantir.java.format.get()).style("GOOGLE")
}
}
}
Expand Down
Loading