hashgraph / hashgraph/pbj

Feature Request: Publish pbj-compiler JAR to Maven Central

Open
#649 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
44
Forks
15
Avg merge
1d 15h
Merged PRs (30d)
12

Description

# 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:

```java
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

- Gradle Plugin: https://plugins.gradle.org/plugin/com.hedera.pbj.pbj-compiler
- Maven Central pbj-runtime: https://repo1.maven.org/maven2/com/hedera/pbj/pbj-runtime/
- Maven Central pbj-compiler (outdated): https://repo1.maven.org/maven2/com/hedera/pbj/pbj-compiler/

---

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.