The Problem
You want to run the same agent task with different providers without changing your Java code.Solution: Maven Profiles
Define one Maven profile per provider. Each profile puts a different starter on the classpath. Your Java code uses only the portableAgentClient API.
1. Define Profiles in pom.xml
2. Add Per-Provider Configuration
Create profile-specific YAML files alongside your mainapplication.yml:
- application-claude.yml
- application-codex.yml
- application-gemini.yml
application.yml:
3. Run with a Specific Provider
Use
-P'!claude' to deactivate the default Claude profile when switching to another provider. Only one provider starter should be on the classpath.Your Java Code Stays the Same
The key design principle: your Java code never imports provider-specific classes. It only uses:AgentClient/AgentClient.BuilderAgentClientResponseAgentOptions(for portable options)