-
Notifications
You must be signed in to change notification settings - Fork 140
feat(spring-boot-starter-adk): Add Spring Boot Starter support #418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TomorJM
wants to merge
1
commit into
google:main
Choose a base branch
from
TomorJM:github_dev.springboot_starter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.google.adk</groupId> | ||
<artifactId>google-adk-parent</artifactId> | ||
<version>0.2.1-SNAPSHOT</version><!-- {x-version-update:google-adk:current} --> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>spring-boot-starter-adk</artifactId> | ||
<name>Agent Development Kit - Spring Boot Starter</name> | ||
<description>Spring Boot Starter for the Agent Development Kit.</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.google.adk</groupId> | ||
<artifactId>google-adk</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.adk</groupId> | ||
<artifactId>google-adk-dev</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<!-- Test dependencies --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
33 changes: 33 additions & 0 deletions
33
...-adk/src/main/java/com/google/adk/starters/springboot/AdkSpringbootAutoConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2025 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.adk.starters.springboot; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@ComponentScan("com.google.adk") | ||
public class AdkSpringbootAutoConfiguration { | ||
|
||
private static final Logger logger = | ||
LoggerFactory.getLogger(AdkSpringbootAutoConfiguration.class); | ||
|
||
public AdkSpringbootAutoConfiguration() { | ||
logger.info("AdkSpringbootAutoConfiguration initialized."); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.google.adk.starters.springboot.AdkSpringbootAutoConfiguration |
81 changes: 81 additions & 0 deletions
81
...tarter-adk/src/test/java/com/google/adk/starters/springboot/AdkSpringbootStarterTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright 2025 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.adk.starters.springboot; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
import com.google.adk.agents.BaseAgent; | ||
import com.google.adk.agents.LlmAgent; | ||
import com.google.adk.web.AgentStaticLoader; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
/** | ||
* Integration tests for the ADK Spring Boot Starter. | ||
* | ||
* <p>These tests use MockMvc to simulate HTTP requests and verify the expected responses from the | ||
* ADK API server, ensuring that the Spring Boot autoconfiguration works correctly. | ||
*/ | ||
@SpringBootTest(properties = "adk.agents.loader=static") | ||
@AutoConfigureMockMvc | ||
public class AdkSpringbootStarterTest { | ||
|
||
@Autowired private AgentStaticLoader agentStaticLoader; | ||
|
||
@Autowired private MockMvc mockMvc; | ||
|
||
@Test | ||
void testAgentStaticLoaderIsLoaded() throws Exception { | ||
assertNotNull(agentStaticLoader); | ||
mockMvc | ||
.perform(get("/list-apps")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().json("[\"test_agent\"]")); | ||
} | ||
|
||
@SpringBootApplication | ||
public static class TestApplication { | ||
public static void main(String[] args) { | ||
SpringApplication.run(TestApplication.class, args); | ||
} | ||
} | ||
|
||
@Configuration | ||
public static class AppConfig { | ||
@Bean("agentLoader") | ||
public AgentStaticLoader agentStaticLoader() { | ||
BaseAgent testAgent = | ||
LlmAgent.builder() | ||
.name("test_agent") | ||
.model("gemini-2.0-flash-lite") | ||
.description("Test agent for demonstrating AgentStaticLoader") | ||
.instruction("You are a test agent.") | ||
.build(); | ||
return new AgentStaticLoader(testAgent); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve the developer experience, it's a good practice for starters to include
spring-boot-configuration-processor
as an optional dependency. This enables IDEs to provide auto-completion and documentation for your custom configuration properties (like those defined foradk.web
).