Skip to main content

Ballerina.toml Reference

The Ballerina.toml file is the project manifest for a Ballerina package. It defines package metadata, build options, dependencies, platform-specific libraries, and code generation tool configurations. This file must reside in the root directory of every Ballerina package.

[package]

Defines the core metadata for the package.

[package]
org = "wso2"
name = "healthcare_integration"
version = "1.2.0"
distribution = "2201.13.3"
visibility = "private"
readme = "README.md"
icon = "icon.png"
license = ["Apache-2.0"]
authors = ["WSO2 Inc."]
keywords = ["healthcare", "integration", "hl7"]
repository = "https://github.com/wso2/healthcare-integration"
include = ["resources/**", "data/*.json"]
FieldTypeRequiredDescription
orgstringYesOrganization name registered on Ballerina Central. Must be lowercase alphanumeric with underscores.
namestringYesPackage name. Defaults to the directory name if omitted. Must be lowercase alphanumeric with underscores.
versionstringYesSemantic version of the package (e.g., "1.0.0"). Defaults to "0.1.0".
distributionstringNoMinimum Ballerina distribution version required to build the package.
visibilitystringNoSet to "private" to restrict package access to organization members only on Ballerina Central.
readmestringNoPath to a custom README markdown file used in generated documentation.
iconstringNoPath to a PNG icon file (max 128x128 pixels) for package documentation.
licensestring[]NoArray of SPDX license identifiers (e.g., ["Apache-2.0"]).
authorsstring[]NoArray of author names.
keywordsstring[]NoArray of searchable keywords describing the package.
repositorystringNoURL of the source code repository.
includestring[]NoGlob patterns for additional files/directories to include in the .bala archive.

[build-options]

Configures build-time behavior. These options can also be passed as CLI flags to bal build.

[build-options]
observabilityIncluded = true
offline = false
skipTests = false
testReport = true
codeCoverage = true
cloud = "k8s"
graalvm = false
graalvmBuildOptions = "--no-fallback -H:+ReportExceptionStackTraces"
FieldTypeDefaultDescription
observabilityIncludedbooleanfalseInclude the observability module in the build to enable metrics and tracing.
offlinebooleanfalseBuild without downloading dependencies from Ballerina Central.
skipTestsbooleanfalseSkip test execution during the build.
testReportbooleanfalseGenerate an HTML test report after running tests.
codeCoveragebooleanfalseEnable code coverage analysis and generate a coverage report.
cloudstring""Cloud deployment target. Use "k8s" for Kubernetes, "docker" for Docker, or "choreo" for WSO2 Integration Platform.
graalvmbooleanfalseBuild a GraalVM native executable instead of a JAR file.
graalvmBuildOptionsstring""Additional arguments passed to the GraalVM native-image tool.

[[dependency]]

Declares explicit package dependencies. In most cases, dependencies are automatically resolved and recorded in Dependencies.toml. Use this section only when you need to pin a version or use a local repository.

[[dependency]]
org = "ballerinax"
name = "mysql"
version = "1.13.0"

[[dependency]]
org = "myorg"
name = "shared_utils"
version = "2.0.0"
repository = "local"
FieldTypeRequiredDescription
orgstringYesOrganization name of the dependency package.
namestringYesPackage name of the dependency.
versionstringYesMinimum required semantic version.
repositorystringNoSet to "local" to resolve from the local repository (~/.ballerina/repositories/local).

[[platform.java21.dependency]]

Declares Java platform dependencies (JAR files) required by the package at compile time or runtime. Use Maven coordinates or a direct file path.

# Maven dependency
[[platform.java21.dependency]]
groupId = "com.mysql"
artifactId = "mysql-connector-j"
version = "8.3.0"

# Local JAR file
[[platform.java21.dependency]]
path = "./libs/custom-codec-1.0.jar"
modules = ["healthcare_integration"]
scope = "provided"
graalvmCompatible = true

# Test-only dependency
[[platform.java21.dependency]]
groupId = "org.mockito"
artifactId = "mockito-core"
version = "5.11.0"
scope = "testOnly"
FieldTypeRequiredDescription
groupIdstringYes*Maven group ID. Required when using Maven coordinates.
artifactIdstringYes*Maven artifact ID. Required when using Maven coordinates.
versionstringYes*Maven version. Required when using Maven coordinates.
pathstringYes*Absolute or relative path to a JAR file. Required when not using Maven coordinates.
modulesstring[]NoRestrict JAR visibility to specific modules within the package.
scopestringNoDependency scope: "testOnly" (tests only) or "provided" (compile-time only, not packaged).
graalvmCompatiblebooleanNoMark this JAR as compatible with GraalVM native compilation.
info

Use platform.java17.dependency or platform.java21.dependency depending on the target Java platform version.

[[platform.java21.repository]]

Configures custom Maven repositories for resolving platform dependencies.

[[platform.java21.repository]]
id = "wso2-nexus"
url = "https://maven.wso2.org/nexus/content/repositories/releases/"
username = "user"
password = "pass"
FieldTypeRequiredDescription
idstringYesA unique identifier for the repository.
urlstringYesThe Maven repository URL.
usernamestringNoAuthentication username.
passwordstringNoAuthentication password.

[platform.java21]

Package-level platform settings.

[platform.java21]
graalvmCompatible = true
FieldTypeDefaultDescription
graalvmCompatiblebooleanfalseIndicates whether the entire package is compatible with GraalVM native compilation.

[[tool.<command>]]

Configures code generation tools (such as the OpenAPI, GraphQL, or gRPC tools) that run automatically during the build.

[[tool.openapi]]
id = "petstore"
filePath = "./openapi/petstore.yaml"
targetModule = "petstore_client"
options.mode = "client"
options.nullable = true

[[tool.grpc]]
id = "order_service"
filePath = "./proto/order.proto"
targetModule = "order_grpc"
FieldTypeRequiredDescription
idstringYesUnique identifier for the tool invocation.
filePathstringYesPath to the specification file (OpenAPI YAML, proto file, etc.).
targetModulestringNoDestination module for the generated code.
optionstableNoTool-specific configuration options.

Complete example

[package]
org = "wso2"
name = "order_management"
version = "1.0.0"
distribution = "2201.12.0"
license = ["Apache-2.0"]
authors = ["WSO2 Inc."]
keywords = ["orders", "integration"]
repository = "https://github.com/wso2/order-management"

[build-options]
observabilityIncluded = true
cloud = "k8s"
testReport = true
codeCoverage = true

[[dependency]]
org = "ballerinax"
name = "mysql"
version = "1.13.0"

[[platform.java21.dependency]]
groupId = "com.mysql"
artifactId = "mysql-connector-j"
version = "8.3.0"

[[tool.openapi]]
id = "inventory_api"
filePath = "./openapi/inventory.yaml"
targetModule = "inventory_client"
options.mode = "client"

What's next

  • Run locally — build and run the package you just configured.
  • Cloud.toml reference — add Kubernetes and Docker deployment descriptors when you deploy.
  • Configuration management — supply runtime values, override via environment variables, and target per-environment configuration.