This file provides guidance to agents when working with code in this repository.
Java Maven library (com.ibm.cloud:sdk-core) — the core runtime for IBM Cloud Java SDKs. Compiles to Java 8 bytecode; requires JDK 11+ to build.
# Build + test + checkstyle (all-in-one)
mvn clean package
# Skip tests (build only)
mvn clean package -DskipTests
# Run all tests (with checkstyle)
mvn test
# Run a single test class
mvn test -Dtest=IamAuthenticatorTest
# Run a single test method
mvn test -Dtest=IamAuthenticatorTest#testSomeMethod
# Lint only (checkstyle)
mvn checkstyle:checkCheckstyle runs as part of the test phase — it will fail the build. Config is at build/checkstyle.xml; suppressions at build/checkstyle-suppressions.xml.
- No tabs — spaces only
- Max line length: 120 characters
- Max method length: 200 lines
- No wildcard imports (
import com.foo.*is rejected) - No unused imports (including those only referenced in Javadoc)
- Newline at end of file
- No trailing spaces
if (andfor (require a space before the parenthesis- Modifier order enforced; redundant modifiers rejected
- Utility classes (no instance state) must have a private constructor — checked by
HideUtilityClassConstructor - Array style:
String[] argsnotString args[]
- TestNG (not JUnit for test logic) — use
org.testng.annotations.Test,@BeforeMethod,@AfterMethod - Assert imports:
static org.testng.Assert.* - Unit tests that need an HTTP server extend
BaseServiceUnitTest, which starts/stops an OkHttpMockWebServer - JSON fixtures are loaded via
TestUtils.loadFixture(filename, Class)fromsrc/test/resources/— filenames passed as literal paths (e.g."src/test/resources/iam_token.json") - Live/integration tests are annotated
@Ignoreand are never run in CI; they require a hand-crafted.envfile at the project root
GsonSingleton— always use this instead ofnew Gson(). UsegetGson()(pretty-printed) orgetGsonWithoutPrettyPrinting()for serialization. Custom type adapters forDate,byte[],LazilyParsedNumber,DynamicModel, and discriminator-based types are already registered.CredentialUtils.getServiceProperties(serviceName)— reads config from credential file → env vars → VCAP_SERVICES → system properties (in that priority order). Service name is uppercased and-→_for env/file lookup but not for VCAP.Clockutility exists for time-based token expiry logic — mock it in tests instead of sleeping.
BaseService(abstract) → extended by generated SDK service classes. UsesOkHttpClient(viaHttpClientSingleton) for HTTP.Authenticatorinterface →AuthenticatorBase→ concrete implementations (IAM, CP4D, MCSP, etc.)- Token-based authenticators extend
TokenRequestBasedAuthenticator; they auto-refresh tokens before expiry. - Builder pattern used throughout authenticators (e.g.
new IamAuthenticator.Builder().apikey(...).build()). - All error messages for validation are constants on
AuthenticatorBase(e.g.ERRORMSG_PROP_MISSING).
Angular-style commit messages required — semantic-release uses them to determine version bumps and changelogs (e.g. fix(IAM): ... → patch, feat(BaseService): ... → minor, BREAKING CHANGE: footer → major).