Skip to content

Commit da686f6

Browse files
brunoborgesCopilot
andcommitted
Use Maven Wrapper (./mvnw) in Java workshop docs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 5f4bf9a commit da686f6

25 files changed

Lines changed: 49 additions & 46 deletions

‎finished/java/accessibility-report/src/main/java/workshop/AccessibilityReport.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private static RunOptions parseRunOptions(String[] args) throws URISyntaxExcepti
123123
}
124124

125125
private static String usage() {
126-
return "Usage: mvn compile exec:java -Dexec.args=\"["
126+
return "Usage: ./mvnw compile exec:java -Dexec.args=\"["
127127
+ LOCAL_DEMO_MCP_FLAG + "] <http-or-https-url>\"";
128128
}
129129

‎finished/java/museum-exhibit-studio/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ This Maven CLI sample uses the GitHub Copilot SDK as a focused museum-curation a
77
From this directory:
88

99
```bash
10-
mvn compile exec:java
10+
./mvnw compile exec:java
1111
```
1212

1313
Set `COPILOT_MODEL` to select a model; otherwise the Copilot runtime chooses its default. The sample requires an authenticated GitHub Copilot CLI.
1414

1515
Compile without contacting a model:
1616

1717
```bash
18-
mvn compile
18+
./mvnw compile
1919
```
2020

2121
## What it demonstrates
@@ -41,7 +41,7 @@ When prompted, answer yes to generate `exhibit.html`. The default Java permissio
4141
Current Java SDK releases may not surface those write-request fields (see <https://github.com/github/copilot-sdk/issues/2273>). For the controlled local workshop only, run with:
4242

4343
```bash
44-
mvn compile exec:java -Dexec.args="--allow-local-demo-write"
44+
./mvnw compile exec:java -Dexec.args="--allow-local-demo-write"
4545
```
4646

4747
That fallback is limited by the app to the `write` permission kind while only `builtin:apply_patch` is available, but it cannot enforce the output path. Do not use the fallback for production, shared, or untrusted worktrees.

‎finished/java/museum-exhibit-studio/src/main/java/workshop/MuseumExhibitStudio.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ private static RunOptions parseRunOptions(String[] args) {
303303
}
304304

305305
private static String usage() {
306-
return "Usage: mvn compile exec:java -Dexec.args=\"[" + LOCAL_DEMO_WRITE_FLAG + "]\"";
306+
return "Usage: ./mvnw compile exec:java -Dexec.args=\"[" + LOCAL_DEMO_WRITE_FLAG + "]\"";
307307
}
308308

309309
private static boolean isTimeout(Throwable error) {

‎scripts/validate_workshop.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
),
9999
"java": (
100100
"src/main/java/",
101-
"mvn compile",
101+
"./mvnw compile",
102102
"```java",
103103
"finished/java/",
104104
),
@@ -109,7 +109,7 @@
109109
"python": ("workshop.py", '@define_tool(', "python main.py"),
110110
"go": ("main.go", "copilot.DefineTool(", "go run ."),
111111
"rust": ("src/main.rs", 'Tool::new("accessibility_rule_lookup")', "cargo run"),
112-
"java": ("AccessibilityReport.java", "ToolDefinition.from(", "mvn compile exec:java"),
112+
"java": ("AccessibilityReport.java", "ToolDefinition.from(", "./mvnw compile exec:java"),
113113
}
114114
# Every command runs from inside the starter directory the learner already sits in.
115115
# No lesson may reintroduce a copied sibling project.
@@ -119,15 +119,15 @@
119119
"python": "python main.py",
120120
"go": "go run .",
121121
"rust": "cargo run",
122-
"java": "mvn compile exec:java",
122+
"java": "./mvnw compile exec:java",
123123
}
124124
STEP_9_RUN_COMMAND_MARKERS = {
125125
"dotnet": "dotnet run",
126126
"nodejs": "npm start",
127127
"python": "python main.py",
128128
"go": "go run .",
129129
"rust": "cargo run --",
130-
"java": "mvn compile exec:java",
130+
"java": "./mvnw compile exec:java",
131131
}
132132
MUSEUM_COMMAND_MARKERS = {
133133
"dotnet": (
@@ -146,7 +146,7 @@
146146
"cargo run",
147147
),
148148
"java": (
149-
"mvn compile exec:java",
149+
"./mvnw compile exec:java",
150150
),
151151
}
152152
MUSEUM_ENTRYPOINTS = {
@@ -166,6 +166,7 @@
166166
"go mod init",
167167
"npm init ",
168168
"mvn archetype:generate",
169+
"./mvnw archetype:generate",
169170
)
170171
IN_PLACE_FORBIDDEN_MARKERS = (
171172
"workshop-app",
@@ -178,6 +179,7 @@
178179
"go test",
179180
"cargo test",
180181
"mvn test",
182+
"./mvnw test",
181183
"python -m unittest",
182184
"unittest",
183185
"mock-wikipedia",

‎start-accessibility/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ local tool, MCP server, or report until the corresponding step.
1515
| Python | [Python 3.11+](https://www.python.org/downloads/) | `cd start-accessibility/python && python -m pip install -r requirements.txt && python -m py_compile *.py` |
1616
| Go | [Go 1.24+](https://go.dev/dl/) | `cd start-accessibility/go && go build -mod=readonly ./...` |
1717
| Rust | [Rust 1.94+](https://rustup.rs/) | `cd start-accessibility/rust && cargo check --locked` |
18-
| Java | [Java 17+](https://adoptium.net/) and [Maven](https://maven.apache.org/install.html) | `cd start-accessibility/java && mvn compile` |
18+
| Java | [Java 17+](https://adoptium.net/) (Maven Wrapper included) | `cd start-accessibility/java && ./mvnw compile` |
1919

2020
Because you edit these files in place, your work shows up in `git status`. That is expected. Run
2121
`git checkout -- .` from the repository root to restore a clean starter. Go, Rust, and Java tracks

‎start-museum/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ step's code goes. Start at [`workshop/museum-00-preflight.md`](../workshop/museu
2323
| Python | `curator.py` | `cd start-museum/python && python -m venv .venv && .venv/bin/python -m pip install -r requirements.txt && .venv/bin/python main.py` |
2424
| Go | `curator.go` | `cd start-museum/go && go build -mod=readonly ./... && go run .` |
2525
| Rust | `src/lib.rs` | `cd start-museum/rust && cargo check --locked && cargo run --locked` |
26-
| Java | `src/main/java/workshop/Curator*.java` | `cd start-museum/java && mvn compile && mvn exec:java` |
26+
| Java | `src/main/java/workshop/Curator*.java` | `cd start-museum/java && ./mvnw compile && ./mvnw exec:java` |
2727

2828
Running the starter prints its identity and does not start Copilot or require authentication.
2929
Because you edit these files in place, your work shows up in `git status`. That is expected. Run

‎workshop/00-preflight.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ See the official
145145
| Requirement | Why the workshop needs it | Verify |
146146
|---|---|---|
147147
| [Java 17 or newer](https://adoptium.net/) (JDK) | Compiles and runs the Maven workshop app | `java -version` |
148-
| [Apache Maven 3.9+](https://maven.apache.org/install.html) | Builds the project and launches `exec:java` | `mvn -version` |
149148
| [Node.js 22 or newer](https://nodejs.org/) | Runs the Playwright MCP server | `node --version` |
150149
| [GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/set-up/install-copilot-cli) | Required on `PATH` for the Java SDK runtime | `copilot --version` |
151150
| [GitHub Copilot access](https://github.com/features/copilot) | Authorizes Copilot requests | `copilot login` |
@@ -156,15 +155,15 @@ Your commands should return output in this shape:
156155
```text
157156
$ java -version
158157
openjdk version "17.x.x" ...
159-
$ mvn -version
160-
Apache Maven 3.9.x
161158
$ node --version
162159
v22.x.x
163160
$ copilot --version
164161
GitHub Copilot CLI ...
165162
```
166163

167-
Use Maven for this track. Do not substitute JBang or Gradle. See the official
164+
No separate Maven install is needed: each Java project includes the Maven Wrapper (`./mvnw`),
165+
which downloads the right Maven version on first use. On Windows, run `mvnw.cmd` instead of
166+
`./mvnw`. Use Maven for this track. Do not substitute JBang or Gradle. See the official
168167
[Java SDK installation guide](https://github.com/github/copilot-sdk/tree/main/java).
169168
:::
170169

@@ -535,7 +534,7 @@ Change into the Java starter and compile with Maven. Stay in this directory for
535534

536535
```bash
537536
cd start-accessibility/java
538-
mvn compile
537+
./mvnw compile
539538
```
540539

541540
A successful compile ends with:
@@ -561,9 +560,10 @@ Open the controlled target page once to make sure you can reach it:
561560

562561
| Symptom | Fix |
563562
|---|---|
564-
| `java` or `mvn` is not recognized | Install JDK 17+ and Maven, then restart the terminal. |
563+
| `java` is not recognized | Install JDK 17+, then restart the terminal. |
564+
| `./mvnw: Permission denied` | Run `chmod +x mvnw`, or use `sh mvnw` instead. On Windows, use `mvnw.cmd`. |
565565
| Compiler release errors | Confirm `java -version` reports 17 or newer; the POM sets `maven.compiler.release` to 17. |
566-
| Dependency download fails | Check Maven Central / proxy settings, then rerun `mvn compile`. |
566+
| Dependency download fails | Check Maven Central / proxy settings, then rerun `./mvnw compile`. |
567567
| Tempted to switch tools | Do not replace Maven with JBang or Gradle for this workshop. |
568568
| `copilot` is not recognized | Install the CLI, restart the terminal, and verify `copilot --version`. |
569569
| Copilot asks you to authenticate | Run `copilot login`, finish the browser flow, then retry. |
@@ -572,7 +572,7 @@ Open the controlled target page once to make sure you can reach it:
572572

573573
</details>
574574

575-
> **Start Step 1 when:** `mvn compile` prints `BUILD SUCCESS`, `copilot login` is complete, and the
575+
> **Start Step 1 when:** `./mvnw compile` prints `BUILD SUCCESS`, `copilot login` is complete, and the
576576
> target page opens.
577577
578578
Compare with

‎workshop/01-first-session.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ cargo run
390390
:::
391391
:::language java
392392
```bash
393-
mvn compile exec:java
393+
./mvnw compile exec:java
394394
```
395395
:::
396396

‎workshop/02-streaming.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ finishes.
878878
## Run it
879879

880880
```bash
881-
mvn compile exec:java
881+
./mvnw compile exec:java
882882
```
883883

884884
The completed response should print before the process exits:
@@ -896,7 +896,7 @@ The completed response should print before the process exits:
896896
|---|---|
897897
| No response is printed | Confirm `setStreaming(true)` is on `SessionConfig` and you call `sendAndWait`. |
898898
| The process fails with a null response | Keep the `response == null` guard and throw when the turn completes without a message. |
899-
| Maven cannot find the main class | Run from the starter directory with `mvn compile exec:java`. |
899+
| Maven cannot find the main class | Run from the starter directory with `./mvnw compile exec:java`. |
900900

901901
</details>
902902

‎workshop/03-local-tool.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ completed response when the turn finishes.
894894
## Run it
895895

896896
```bash
897-
mvn compile exec:java
897+
./mvnw compile exec:java
898898
```
899899

900900
The response should use the lookup result for WCAG 4.1.2:

0 commit comments

Comments
 (0)