Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Java Profiles

The java profile generates a Maven project from your .proto files using protoc-gen-java and publishes it either to a Git repository or to Maven Central via the Sonatype Central Portal. Consumers depend on the artifact through a normal Maven (or Gradle) coordinate.

Available variants:

  • maven_central — Publish to Maven Central.
  • git — Push the generated Maven project to a Git remote.

Required tools

  • protoc — Protocol Buffers compiler.
  • java — A JDK (11 or newer recommended), used by Maven.
  • mvn — Apache Maven, used to compile and (for maven_central) deploy.
  • gpg — GnuPG, used to sign artifacts. Required for the maven_central variant; not used by the git variant.
  • git — Required only for the git variant.

buffy check verifies that the relevant tools are installed for the configured variant.

The maven_central variant

Generates a Maven project under target/<profile>/, runs mvn compile to verify, signs the artifacts with GPG, and uploads them to the Sonatype Central Portal via the central-publishing-maven-plugin.

The Sonatype namespace must be verified for your account before the first publish (e.g., io.github.<your-github-user> is verified by creating a public repository named after a verification code Sonatype gives you).

Example

# .buffy/java-example.toml
[java.maven_central]
group_id = "io.github.example"
artifact_id = "tomato"
url = "https://github.com/example/tomato"
auto_publish = false
wait_until = "uploaded"

[java.maven_central.scm]
connection = "scm:git:git://github.com/example/tomato.git"
url = "https://github.com/example/tomato"

Fields

  • group_id — Maven group ID.
  • artifact_id — Maven artifact ID.
  • url — Project URL embedded in the POM.
  • scm — Source-control coordinates required by Maven Central.
  • protobuf_version — Pin the protobuf-java runtime version.
  • auto_publish — Auto-release after upload validates.
  • wait_until — How far to wait in the publishing pipeline.

The group_id field

The Maven groupId of the published artifact. Must match a namespace verified for your Sonatype account.

group_id = "io.github.example"

The artifact_id field

The Maven artifactId of the published artifact.

artifact_id = "tomato"

The url field

A project URL written to the <url> tag in the generated POM. Maven Central requires this field to be present.

url = "https://github.com/example/tomato"

The scm section

Source-control coordinates required by Maven Central. Embedded in the <scm> block of the POM.

[java.maven_central.scm]
connection = "scm:git:git://github.com/example/tomato.git"
url = "https://github.com/example/tomato"
  • connection — The SCM connection string, conventionally scm:git:<git-url>.
  • url — A browsable URL for the source repository.

The protobuf_version field

Optional. Pin a specific version of the com.google.protobuf:protobuf-java runtime dependency. If omitted, Buffy queries Maven Central for the latest release version.

protobuf_version = "4.29.3"

The auto_publish field

When true, the Sonatype Central Portal automatically releases the artifact after validation succeeds. When false, the artifact lands in the “Validated” state in the portal and must be released manually.

auto_publish = false

Default: false. For first releases, leave this off so you can manually verify the upload.

The wait_until field

Controls how long the publish step waits before returning. One of:

ValueWaits forTypical duration
uploadedUpload to Sonatype completesseconds
validatedSonatype validation (schema, GPG, etc.)1–3 minutes
publishedIndexing into Maven Central completes10–30 minutes
wait_until = "uploaded"

Default: uploaded.

Required environment variables

VariablePurpose
MAVEN_USERNAMESonatype Central Portal username token
MAVEN_PASSWORDSonatype Central Portal password token
GPG_KEY_IDGPG key ID used to sign the artifacts
GPG_PASSPHRASEPassphrase for the GPG key
GPG_PRIVATE_KEYOptional: armored private key, for CI runners

See Environment Variables for details.

Example consumer usage

<dependency>
  <groupId>io.github.example</groupId>
  <artifactId>tomato</artifactId>
  <version>0.1.0</version>
</dependency>

The git variant

Generates the same Maven project as maven_central, but commits and tags it to a Git repository instead of uploading. No GPG signing, no Sonatype account. Useful for internal sharing or quick prototypes.

Example

# .buffy/java.toml
[java.git]
group_id = "com.example"
artifact_id = "tomato"
url = "https://github.com/example/tomato-java"
remote = "git@github.com:example/tomato-java.git"
branch = "main"
keep = ["README.md"]

[java.git.scm]
connection = "scm:git:git://github.com/example/tomato-java.git"
url = "https://github.com/example/tomato-java"

Fields

  • group_id — as in maven_central.
  • artifact_id — as in maven_central.
  • url — as in maven_central.
  • scm — as in maven_central.
  • protobuf_version — as in maven_central.
  • remote — Git URL the artifact is pushed to.
  • branch — Branch to push to.
  • keep — Files to preserve from the remote.

The remote field

The Git URL the generated Maven project is pushed to. SSH URLs are recommended because Buffy disables Git’s terminal prompt.

remote = "git@github.com:example/tomato-java.git"

The branch field

The branch to push to. Buffy force-pushes on every publish.

branch = "main"

The keep field

A list of file paths (relative to the repository root) to preserve across publishes by checking them out from the remote before committing.

keep = ["README.md"]

Default: [].

Example consumer usage

Maven projects can depend on a Git source via JitPack or by cloning and running mvn install locally. Example with JitPack:

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>

<dependency>
  <groupId>com.github.example</groupId>
  <artifactId>tomato-java</artifactId>
  <version>v0.1.0</version>
</dependency>