You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: update Java documentation to match actual implementation
Java docs incorrectly referenced codeflash.toml (which doesn't exist) and
omitted Java from several pages despite being fully implemented.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
description: "Configure Codeflash for Java projects using codeflash.toml"
3
+
description: "Configure Codeflash for Java projects"
4
4
icon: "java"
5
-
sidebarTitle: "Java (codeflash.toml)"
5
+
sidebarTitle: "Java"
6
6
keywords:
7
7
[
8
8
"configuration",
9
-
"codeflash.toml",
10
9
"java",
11
10
"maven",
12
11
"gradle",
13
12
"junit",
13
+
"pom.xml",
14
+
"gradle.properties",
14
15
]
15
16
---
16
17
17
18
# Java Configuration
18
19
19
-
Codeflash stores its configuration in `codeflash.toml` under the `[tool.codeflash]` section.
20
+
Codeflash stores its configuration inside your existing build file — `pom.xml` properties for Maven projects, or `gradle.properties` for Gradle projects. No separate config file is needed.
20
21
21
-
## Full Reference
22
+
## Maven Configuration
22
23
23
-
```toml
24
-
[tool.codeflash]
25
-
# Required
26
-
module-root = "src/main/java"
27
-
tests-root = "src/test/java"
28
-
language = "java"
24
+
For Maven projects, Codeflash writes properties under the `<properties>` section of your `pom.xml` with the `codeflash.` prefix:
29
25
30
-
# Optional
31
-
test-framework = "junit5"# "junit5", "junit4", or "testng"
All file paths are relative to the directory containing `codeflash.toml`.
38
+
## Gradle Configuration
39
+
40
+
For Gradle projects, Codeflash writes settings to `gradle.properties` with the `codeflash.` prefix:
41
+
42
+
```properties
43
+
codeflash.moduleRoot=src/main/java
44
+
codeflash.testsRoot=src/test/java
45
+
codeflash.gitRemote=origin
46
+
```
38
47
39
48
<Info>
40
-
Codeflash auto-detects most settings from your project structure. Running `codeflash init` will set up the correct config — manual configuration is usually not needed.
49
+
Codeflash auto-detects most settings from your project structure. Running `codeflash init` will set up the correct config — manual configuration is usually not needed. For standard Maven/Gradle layouts, Codeflash may write no config at all if all defaults are correct.
41
50
</Info>
42
51
43
52
## Auto-Detection
@@ -46,54 +55,42 @@ When you run `codeflash init`, Codeflash inspects your project and auto-detects:
46
55
47
56
| Setting | Detection logic |
48
57
|---------|----------------|
49
-
|`module-root`| Looks for `src/main/java` (Maven/Gradle standard layout) |
50
-
|`tests-root`| Looks for `src/test/java`, `test/`, `tests/`|
51
-
|`language`| Detected from build files (`pom.xml`, `build.gradle`) and `.java` files |
52
-
|`test-framework`| Checks build file dependencies for JUnit 5, JUnit 4, or TestNG |
53
-
54
-
## Required Options
58
+
|**Source root**| Looks for `src/main/java` (Maven/Gradle standard layout), falls back to pom.xml `sourceDirectory`|
59
+
|**Test root**| Looks for `src/test/java`, `test/`, `tests/`|
|`ignorePaths`| Paths within source root to skip during optimization | (none) |
55
73
56
-
-**`module-root`**: The source directory to optimize. Only code under this directory is discovered for optimization. For standard Maven/Gradle projects, this is `src/main/java`.
57
-
-**`tests-root`**: The directory where your tests are located. Codeflash discovers existing tests and places generated replay tests here.
58
-
-**`language`**: Must be set to `"java"` for Java projects.
59
-
60
-
## Optional Options
61
-
62
-
-**`test-framework`**: Test framework. Auto-detected from build dependencies. Supported values: `"junit5"` (default), `"junit4"`, `"testng"`.
63
-
-**`disable-telemetry`**: Disable anonymized telemetry. Defaults to `false`.
64
-
-**`git-remote`**: Git remote for pull requests. Defaults to `"origin"`.
65
-
-**`ignore-paths`**: Paths within `module-root` to skip during optimization.
74
+
<Info>
75
+
Only non-default values are written to the config. If your project uses the standard `src/main/java` and `src/test/java` layout with the default `origin` remote, Codeflash may not need to write any config properties at all.
76
+
</Info>
66
77
67
78
## Multi-Module Projects
68
79
69
-
For multi-module Maven/Gradle projects, place`codeflash.toml` at the project root and set `module-root`to the module you want to optimize:
80
+
For multi-module Maven/Gradle projects, run`codeflash init` from the module you want to optimize. The config is written to that module's `pom.xml` or `gradle.properties`:
70
81
71
82
```text
72
83
my-project/
73
84
|- client/
74
85
| |- src/main/java/com/example/client/
75
86
| |- src/test/java/com/example/client/
87
+
| |- pom.xml <-- run codeflash init here
76
88
|- server/
77
89
| |- src/main/java/com/example/server/
78
90
|- pom.xml
79
-
|- codeflash.toml
80
-
```
81
-
82
-
```toml
83
-
[tool.codeflash]
84
-
module-root = "client/src/main/java"
85
-
tests-root = "client/src/test/java"
86
-
language = "java"
87
91
```
88
92
89
-
For non-standard layouts (like the Aerospike client where source is under `client/src/`), adjust paths accordingly:
90
-
91
-
```toml
92
-
[tool.codeflash]
93
-
module-root = "client/src"
94
-
tests-root = "test/src"
95
-
language = "java"
96
-
```
93
+
For non-standard layouts (like the Aerospike client where source is under `client/src/`), `codeflash init` will prompt you to override the detected paths.
97
94
98
95
## Tracer Options
99
96
@@ -124,15 +121,9 @@ my-app/
124
121
| |- test/java/com/example/
125
122
| |- AppTest.java
126
123
|- pom.xml
127
-
|- codeflash.toml
128
124
```
129
125
130
-
```toml
131
-
[tool.codeflash]
132
-
module-root = "src/main/java"
133
-
tests-root = "src/test/java"
134
-
language = "java"
135
-
```
126
+
Standard layout — no extra config needed. `codeflash init` detects everything automatically.
136
127
137
128
### Gradle project
138
129
@@ -142,12 +133,7 @@ my-lib/
142
133
| |- main/java/com/example/
143
134
| |- test/java/com/example/
144
135
|- build.gradle
145
-
|- codeflash.toml
136
+
|- gradle.properties <-- codeflash config written here if overrides needed
146
137
```
147
138
148
-
```toml
149
-
[tool.codeflash]
150
-
module-root = "src/main/java"
151
-
tests-root = "src/test/java"
152
-
language = "java"
153
-
```
139
+
Standard layout — no extra config needed. `codeflash init` detects everything automatically.
Codeflash speeds up your code by figuring out the best way to rewrite it while verifying that the behavior is unchanged, and verifying real speed
9
-
gains through performance benchmarking. It supports **Python**, **JavaScript**, and **TypeScript**.
9
+
gains through performance benchmarking. It supports **Python**, **JavaScript**, **TypeScript**, and **Java**.
10
10
11
11
The optimizations Codeflash finds are generally better algorithms, opportunities to remove wasteful compute, better logic, utilizing caching and utilization of more efficient library methods. Codeflash
12
12
does not modify the system architecture of your code, but it tries to find the most efficient implementation of your current architecture.
@@ -15,18 +15,21 @@ does not modify the system architecture of your code, but it tries to find the m
15
15
16
16
Pick your language to install and configure Codeflash:
Codeflash can optimize your entire codebase by analyzing all the functions in your project and generating optimized versions of them.
12
-
It iterates through all the functions in your codebase and optimizes them one by one. This works for Python, JavaScript, and TypeScript projects.
12
+
It iterates through all the functions in your codebase and optimizes them one by one. This works for Python, JavaScript, TypeScript, and Java projects.
13
13
14
14
To optimize your entire codebase, run the following command in your project directory:
0 commit comments