BPJ is a Java 17+ interpolation library that lets you write readable placeholders like {name}, {product.value} and {user.getName()} in print, println, and format.
- Reduce Java boilerplate when building dynamic messages.
- Keep source code readable with template-style strings.
- Return interpolated strings with
BPJ.format(...). - Print interpolated text with
BPJ.print(...)/BPJ.println(...). - Choose between explicit runtime context or automatic build-time injection.
flowchart LR
A["BPJ.println('Hello {user.name}')"] --> B{"Plugin active?"}
B -->|No| C["Use explicit context overloads"]
B -->|Yes| D["Build rewrites source and injects context"]
C --> E["Resolved runtime output"]
D --> E
<dependency>
<groupId>io.github.oriontheprogrammer</groupId>
<artifactId>bpj</artifactId>
<version>0.3.0</version>
</dependency>implementation "io.github.oriontheprogrammer:bpj:0.3.0"Option A (bpj-starter-parent, easiest):
<parent>
<groupId>io.github.oriontheprogrammer</groupId>
<artifactId>bpj-starter-parent</artifactId>
<version>0.3.0</version>
</parent>Option B (bpj-spring-boot-parent, Spring Boot friendly):
<parent>
<groupId>io.github.oriontheprogrammer</groupId>
<artifactId>bpj-spring-boot-parent</artifactId>
<version>0.3.0</version>
</parent>Option C (manual plugin, for custom parent including spring-boot-starter-parent):
<build>
<plugins>
<plugin>
<groupId>io.github.oriontheprogrammer</groupId>
<artifactId>bpj-maven-plugin</artifactId>
<version>0.3.0</version>
<executions>
<execution>
<goals>
<goal>prepare</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>Recommended plugin DSL:
// settings.gradle
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}// build.gradle
plugins {
id "java"
id "io.github.oriontheprogrammer.bpj" version "0.3.0"
}
repositories {
mavenCentral()
}
dependencies {
implementation "io.github.oriontheprogrammer:bpj:0.3.0"
}Legacy buildscript mode is still supported. See docs below.
Use this section if you want one-argument BPJ calls like:
BPJ.println("Hello {name}");to resolve values automatically.
- Add BPJ runtime dependency in
pom.xml. - Activate one Maven option:
- Parent option:
bpj-starter-parentorbpj-spring-boot-parent. - Manual option: add
bpj-maven-pluginwith goalprepare.
- Parent option:
- Build through Maven:
mvn clean compileThen verify generated files exist in:
target/generated-sources/bpj
- Add BPJ runtime dependency in
build.gradle. - Add BPJ plugin id in
build.gradle:
plugins {
id "java"
id "io.github.oriontheprogrammer.bpj" version "0.3.0"
}- Ensure
pluginManagementincludesgradlePluginPortal()andmavenCentral()insettings.gradle. - Build through Gradle:
./gradlew clean compileJavaThen verify generated files exist in:
build/generated/sources/bpj/main
If you run main() directly from IDE without delegated Maven/Gradle build, transformation may be skipped.
Run from terminal or enable delegated build/run in your IDE.
| Mode | Example | Notes |
|---|---|---|
| Plugin OFF (explicit context) | BPJ.format("Hello {name}", Map.of("name", name)) |
Always works, no source rewrite needed |
| Plugin OFF (object root) | BPJ.format("User: {name}", this) |
Resolves from object fields/getters |
| Plugin ON (auto injection) | BPJ.format("Hello {name}") |
Build plugin injects context automatically |
| Plugin ON (print) | BPJ.println("Welcome {user.name}") |
Clean one-argument style |
String text = BPJ.format("Product value: {product.value}", Map.of("product", product));
String text2 = BPJ.format("Hello {name}, age {age}", "name", name, "age", age);
BPJ.println("Welcome {name}", this);BPJ.println("Hello {name}");
BPJ.println("Welcome {user.name}");
BPJ.println("Method call: {user.getName()}");
String text = BPJ.format("Final price: {finalPrice}");BPJ works for returned values, not only console output:
public String retornarTexto(String name, int edad) {
return BPJ.format("Hola {name}, tienes {edad}");
}Important:
- The no-extra-args form above requires plugin activation.
- If plugin is not active, use
BPJ.format("Hola {name}, tienes {edad}", this)or explicit map/key-values.
Maven:
mvn clean compileCheck generated sources:
target/generated-sources/bpj
Gradle:
./gradlew clean compileJavaCheck generated sources:
build/generated/sources/bpj/main
- Check latest published versions:
- Replace
0.3.0in yourpom.xml/build.gradle. - Rebuild:
- Maven:
mvn -B -ntp clean verify - Gradle:
./gradlew clean build
- Maven:
- API reference
- Plugin activation guide
- Maven plugin guide
- Gradle plugin guide
- Spring Boot parent guide
Badges and icons are powered by: