Skip to content

Commit 4cb4add

Browse files
committed
file based session service
1 parent 30573e5 commit 4cb4add

10 files changed

Lines changed: 629 additions & 9 deletions

File tree

Justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env just --justfile
2+
3+
run-code-format:
4+
mvn com.spotify.fmt:fmt-maven-plugin:format

artifact/file/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</parent>
1111

1212
<artifactId>artifact-file</artifactId>
13+
<name>Artifact :: File</name>
1314

1415
<properties>
1516
<maven.compiler.source>17</maven.compiler.source>

artifact/file/src/main/java/com/javaaidev/adk/artifact/file/FileBasedArtifactService.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import java.nio.file.Path;
1414
import java.util.ArrayList;
1515
import java.util.List;
16+
import java.util.Objects;
1617
import java.util.Optional;
1718
import org.slf4j.Logger;
1819
import org.slf4j.LoggerFactory;
@@ -24,12 +25,16 @@ public class FileBasedArtifactService implements BaseArtifactService {
2425
private final Path root;
2526

2627
public FileBasedArtifactService(Path root) {
27-
this.root = root;
28-
try {
29-
Files.createDirectories(root);
30-
} catch (IOException e) {
31-
LOGGER.error("Failed to create artifacts directory", e);
28+
Objects.requireNonNull(root, "root path cannot be null");
29+
if (!Files.exists(root)) {
30+
try {
31+
Files.createDirectories(root);
32+
} catch (IOException e) {
33+
LOGGER.error("Failed to create artifacts directory", e);
34+
}
3235
}
36+
this.root = root.normalize().toAbsolutePath();
37+
LOGGER.info("Artifacts saved to {}", this.root);
3338
}
3439

3540
@Override
@@ -140,7 +145,5 @@ private boolean fileHasUserNamespace(String filename) {
140145
return filename != null && filename.startsWith("user:");
141146
}
142147

143-
record PathAndVersion(Path path, Integer version) {
144-
145-
}
148+
record PathAndVersion(Path path, Integer version) {}
146149
}

artifact/file/src/test/java/com/javaaidev/adk/artifact/file/FileBasedArtifactServiceTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.javaaidev.adk.artifact.file;
22

3-
43
import static org.assertj.core.api.Assertions.assertThat;
54

65
import com.google.genai.types.Part;

artifact/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</parent>
1111

1212
<artifactId>artifact</artifactId>
13+
<name>Artifact</name>
1314
<packaging>pom</packaging>
1415
<modules>
1516
<module>file</module>

pom.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343

4444
<modules>
4545
<module>artifact</module>
46+
<module>session</module>
47+
<module>session/file</module>
4648
</modules>
4749

4850
<properties>
@@ -60,6 +62,11 @@
6062
<artifactId>google-adk</artifactId>
6163
<version>${adk.version}</version>
6264
</dependency>
65+
<dependency>
66+
<groupId>ch.qos.logback</groupId>
67+
<artifactId>logback-classic</artifactId>
68+
<version>1.5.22</version>
69+
</dependency>
6370
<dependency>
6471
<groupId>org.junit.jupiter</groupId>
6572
<artifactId>junit-jupiter-api</artifactId>
@@ -75,6 +82,30 @@
7582
</dependencies>
7683
</dependencyManagement>
7784

85+
<build>
86+
<plugins>
87+
<plugin>
88+
<groupId>com.spotify.fmt</groupId>
89+
<artifactId>fmt-maven-plugin</artifactId>
90+
<version>2.29</version>
91+
<dependencies>
92+
<dependency>
93+
<groupId>com.google.googlejavaformat</groupId>
94+
<artifactId>google-java-format</artifactId>
95+
<version>1.33.0</version>
96+
</dependency>
97+
</dependencies>
98+
<executions>
99+
<execution>
100+
<goals>
101+
<goal>format</goal>
102+
</goals>
103+
</execution>
104+
</executions>
105+
</plugin>
106+
</plugins>
107+
</build>
108+
78109
<profiles>
79110
<profile>
80111
<id>publish</id>

session/file/pom.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>com.javaaidev.adk</groupId>
8+
<artifactId>adk-extra</artifactId>
9+
<version>0.1.0</version>
10+
<relativePath>../../pom.xml</relativePath>
11+
</parent>
12+
13+
<artifactId>session-file</artifactId>
14+
<name>Session :: File</name>
15+
16+
<properties>
17+
<maven.compiler.source>17</maven.compiler.source>
18+
<maven.compiler.target>17</maven.compiler.target>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>com.google.adk</groupId>
25+
<artifactId>google-adk</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.junit.jupiter</groupId>
29+
<artifactId>junit-jupiter-api</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.assertj</groupId>
33+
<artifactId>assertj-core</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>ch.qos.logback</groupId>
37+
<artifactId>logback-classic</artifactId>
38+
<scope>test</scope>
39+
</dependency>
40+
</dependencies>
41+
42+
</project>

0 commit comments

Comments
 (0)