Skip to content

Feature Request: Publish pbj-compiler JAR to Maven Central #649

@rbair23

Description

@rbair23

Feature Request: Publish pbj-compiler JAR to Maven Central

Summary

Request to publish pbj-compiler as a standalone JAR artifact to Maven Central, separate from the Gradle plugin, to enable usage in Maven builds and other build systems.

Current Situation

Currently, PBJ provides:

  • pbj-runtime published to Maven Central (version 0.11.15 available)
  • ✅ Gradle plugin com.hedera.pbj.pbj-compiler published to Gradle Plugin Portal
  • pbj-compiler JAR last published to Maven Central at version 0.7.5 (August 2023)

Problem

Projects using Maven or other build systems cannot easily use PBJ for code generation because:

  1. The pbj-compiler JAR is not published to Maven Central for recent versions (0.8.0+)
  2. The compiler is only available as a Gradle plugin
  3. This forces Maven projects to either:
    • Use outdated pbj-compiler (0.7.5)
    • Clone and build pbj-compiler from source using Gradle
    • Commit generated code to version control
    • Use Gradle just for code generation (mixing build tools)

Proposed Solution

Publish pbj-compiler as a standalone JAR artifact to Maven Central alongside pbj-runtime, similar to how protoc is published separately from protobuf-maven-plugin.

Benefits

  1. Build Tool Agnostic: Maven, Gradle, Ant, or any JVM build tool can use PBJ
  2. Direct Invocation: Can be invoked via java -jar or programmatically via PbjCompiler.compileFilesIn()
  3. Custom Integration: Users can integrate PBJ into custom build pipelines
  4. Consistent Versioning: Keep pbj-compiler and pbj-runtime versions in sync

Suggested Structure

com.hedera.pbj:pbj-compiler:0.11.15      (the compiler library JAR)
com.hedera.pbj:pbj-compiler-gradle-plugin:0.11.15  (optional: the Gradle plugin wrapper)
com.hedera.pbj:pbj-runtime:0.11.15       (already published)

Use Case

A small POC project is using Maven. We need PBJ code generation but cannot use the Gradle plugin. The PbjCompiler class already has a clean API:

PbjCompiler.compileFilesIn(
    sourceFiles,
    mainOutputDir,
    testOutputDir,
    javaPackageSuffix,
    generateTestClasses
);

This could easily be invoked from Maven via exec-maven-plugin if the JAR were published.

Alternative Workarounds

If publishing the JAR is not feasible, alternatives include:

  1. Provide a CLI wrapper with main() method
  2. Publish documentation on building pbj-compiler locally
  3. Provide Maven plugin alongside Gradle plugin

References


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions