Skip to content

Commit c9cb551

Browse files
Copilotbrunoborges
andcommitted
Move cookbook to Maven site and add JBang support with version filtering
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent 218cb5d commit c9cb551

9 files changed

Lines changed: 50 additions & 2 deletions

File tree

.github/workflows/publish-maven.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,13 @@ jobs:
116116
# Update version in jbang-example.java
117117
sed -i "s|copilot-sdk:[0-9]*\.[0-9]*\.[0-9]*|copilot-sdk:${VERSION}|g" jbang-example.java
118118
119+
# Update version in cookbook files (Maven will filter ${project.version} during site generation,
120+
# but we also need the actual version for direct JBang usage)
121+
find src/site/markdown/cookbook -name "*.md" -type f -exec \
122+
sed -i "s|\${project.version}|${VERSION}|g" {} \;
123+
119124
# Commit the documentation changes before release:prepare (requires clean working directory)
120-
git add CHANGELOG.md README.md jbang-example.java
125+
git add CHANGELOG.md README.md jbang-example.java src/site/markdown/cookbook/
121126
git commit -m "docs: update version references to ${VERSION}"
122127
123128
# Save the commit SHA for potential rollback

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jbang https://github.com/copilot-community-sdk/copilot-sdk-java/blob/latest/jban
105105
- [Getting Started](https://copilot-community-sdk.github.io/copilot-sdk-java/documentation.html)
106106
- [Javadoc API Reference](https://copilot-community-sdk.github.io/copilot-sdk-java/apidocs/)
107107
- [MCP Servers Integration](https://copilot-community-sdk.github.io/copilot-sdk-java/mcp.html)
108-
- [Cookbook](cookbook/) — Practical recipes for common use cases
108+
- [Cookbook](https://copilot-community-sdk.github.io/copilot-sdk-java/cookbook/) — Practical recipes for common use cases
109109

110110
## Projects Using This SDK
111111

File renamed without changes.

cookbook/error-handling.md renamed to src/site/markdown/cookbook/error-handling.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ You need to handle various error conditions like connection failures, timeouts,
99
## Basic error handling
1010

1111
```java
12+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
1213
import com.github.copilot.sdk.*;
1314
import com.github.copilot.sdk.events.*;
1415
import com.github.copilot.sdk.json.*;
@@ -40,6 +41,10 @@ public class BasicErrorHandling {
4041
## Handling specific error types
4142

4243
```java
44+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
45+
import com.github.copilot.sdk.*;
46+
import com.github.copilot.sdk.events.*;
47+
import com.github.copilot.sdk.json.*;
4348
import java.io.IOException;
4449
import java.util.concurrent.ExecutionException;
4550
import java.util.concurrent.TimeoutException;
@@ -69,6 +74,10 @@ public class SpecificErrorHandling {
6974
## Timeout handling
7075

7176
```java
77+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
78+
import com.github.copilot.sdk.*;
79+
import com.github.copilot.sdk.events.*;
80+
import com.github.copilot.sdk.json.*;
7281
import java.util.concurrent.TimeUnit;
7382
import java.util.concurrent.TimeoutException;
7483

@@ -96,6 +105,10 @@ public class TimeoutHandling {
96105
## Aborting a request
97106

98107
```java
108+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
109+
import com.github.copilot.sdk.*;
110+
import com.github.copilot.sdk.events.*;
111+
import com.github.copilot.sdk.json.*;
99112
import java.util.concurrent.Executors;
100113
import java.util.concurrent.ScheduledExecutorService;
101114
import java.util.concurrent.TimeUnit;
@@ -123,6 +136,11 @@ public class AbortRequest {
123136
## Graceful shutdown
124137

125138
```java
139+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
140+
import com.github.copilot.sdk.*;
141+
import com.github.copilot.sdk.events.*;
142+
import com.github.copilot.sdk.json.*;
143+
126144
public class GracefulShutdown {
127145
public static void main(String[] args) {
128146
var client = new CopilotClient();
@@ -150,6 +168,11 @@ public class GracefulShutdown {
150168
## Try-with-resources pattern
151169

152170
```java
171+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
172+
import com.github.copilot.sdk.*;
173+
import com.github.copilot.sdk.events.*;
174+
import com.github.copilot.sdk.json.*;
175+
153176
public class TryWithResources {
154177
public static void doWork() throws Exception {
155178
try (var client = new CopilotClient()) {
@@ -175,6 +198,10 @@ public class TryWithResources {
175198
## Handling tool errors
176199

177200
```java
201+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
202+
import com.github.copilot.sdk.*;
203+
import com.github.copilot.sdk.events.*;
204+
import com.github.copilot.sdk.json.*;
178205
import java.util.Map;
179206
import java.util.List;
180207
import java.util.concurrent.CompletableFuture;

cookbook/managing-local-files.md renamed to src/site/markdown/cookbook/managing-local-files.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ You have a folder with many files and want to organize them into subfolders base
99
## Example code
1010

1111
```java
12+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
1213
import com.github.copilot.sdk.*;
1314
import com.github.copilot.sdk.events.*;
1415
import com.github.copilot.sdk.json.*;
@@ -130,6 +131,7 @@ session.send(new MessageOptions().setPrompt(prompt));
130131
## Interactive file organization
131132

132133
```java
134+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
133135
import java.io.BufferedReader;
134136
import java.io.InputStreamReader;
135137

cookbook/multiple-sessions.md renamed to src/site/markdown/cookbook/multiple-sessions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ You need to run multiple conversations in parallel, each with its own context an
99
## Java
1010

1111
```java
12+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
1213
import com.github.copilot.sdk.*;
1314
import com.github.copilot.sdk.events.*;
1415
import com.github.copilot.sdk.json.*;
@@ -99,6 +100,7 @@ try {
99100
## Managing session lifecycle with CompletableFuture
100101

101102
```java
103+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
102104
import java.util.concurrent.CompletableFuture;
103105
import java.util.List;
104106

cookbook/persisting-sessions.md renamed to src/site/markdown/cookbook/persisting-sessions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ You want users to be able to continue a conversation even after closing and reop
99
## Creating a session with a custom ID
1010

1111
```java
12+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
1213
import com.github.copilot.sdk.*;
1314
import com.github.copilot.sdk.events.*;
1415
import com.github.copilot.sdk.json.*;
@@ -127,6 +128,7 @@ public class SessionHistory {
127128
## Complete example with session management
128129

129130
```java
131+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
130132
import java.util.Scanner;
131133

132134
public class SessionManager {

cookbook/pr-visualization.md renamed to src/site/markdown/cookbook/pr-visualization.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ java PRVisualization.java github/copilot-sdk
3131
## Full example: PRVisualization.java
3232

3333
```java
34+
//DEPS io.github.copilot-community-sdk:copilot-sdk:${project.version}
3435
import com.github.copilot.sdk.*;
3536
import com.github.copilot.sdk.events.*;
3637
import com.github.copilot.sdk.json.*;

src/site/site.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@
6262
<item name="Session Hooks" href="hooks.html"/>
6363
</menu>
6464

65+
<menu name="Cookbook">
66+
<item name="Overview" href="cookbook/README.html"/>
67+
<item name="Error Handling" href="cookbook/error-handling.html"/>
68+
<item name="Multiple Sessions" href="cookbook/multiple-sessions.html"/>
69+
<item name="Managing Local Files" href="cookbook/managing-local-files.html"/>
70+
<item name="PR Visualization" href="cookbook/pr-visualization.html"/>
71+
<item name="Persisting Sessions" href="cookbook/persisting-sessions.html"/>
72+
</menu>
73+
6574
<menu ref="reports"/>
6675

6776
</body>

0 commit comments

Comments
 (0)