bpj-maven-plugin enables ergonomic one-argument BPJ calls by rewriting source code during build.
For end-to-end activation steps (including IDE behavior), see:
docs/PLUGIN_ACTIVATION_GUIDE.md
Use bpj-starter-parent and you get this plugin preconfigured automatically.
<parent>
<groupId>io.github.oriontheprogrammer</groupId>
<artifactId>bpj-starter-parent</artifactId>
<version>0.3.1</version>
</parent>For Spring Boot projects that need BPJ auto-start without manual plugin wiring, use:
<parent>
<groupId>io.github.oriontheprogrammer</groupId>
<artifactId>bpj-spring-boot-parent</artifactId>
<version>0.3.1</version>
</parent>prepare
- Default phase:
generate-sources - Thread-safe: yes
Supported method names:
formatformatStrictprintprintlnformatHighlightedprintHighlightedprintlnHighlighted
Supported call styles:
BPJ.println("Hello {name}")io.github.bpj.BPJ.println("Hello {name}")println("Hello {name}")when statically imported fromio.github.bpj.BPJ- Compatibility in static methods:
BPJ.print("El error es: {e}", this)is rewritten to generated map context
Conditions:
- Exactly one argument
- Argument is string literal or text block
- At least one BPJ placeholder exists
Input:
BPJ.println("Welcome {user.name}");Generated:
BPJ.println("Welcome {user.name}", java.util.Map.of("user", user));For each placeholder:
{user.name}-> root variable isuser{price}-> root variable isprice
Repeated roots are de-duplicated in insertion order.
Generated map strategy:
- Up to 10 roots:
java.util.Map.of(...) - More than 10 roots:
java.util.Map.ofEntries(...)
Default: ${project.build.sourceDirectory}
Source root to read from.
Default: ${project.build.directory}/generated-sources/bpj
Generated source root.
Default: true
When enabled:
- removes original
src/main/javacompile root - compiles only generated source root
This prevents duplicate class compilation.
Default: true
If true, transformation errors fail the build.
If false, plugin logs a warning and build continues.
Default: false
When true, BPJ fails the build if a placeholder root cannot be resolved from the current source scope.
Example:
- Template:
"Hello {name} {missing}" - In-scope variable:
name - Missing variable:
missing - Result with
failOnUnresolved=true: plugin throws a clear error before compilation.
Default: false
Logs transformed files and replacement counts.
Default: false
When enabled, the plugin writes a per-file transformation report.
Default: ${project.build.directory}/reports/bpj-transform-report.txt
Destination file for the transformation report when writeReport=true.
<build>
<plugins>
<plugin>
<groupId>io.github.oriontheprogrammer</groupId>
<artifactId>bpj-maven-plugin</artifactId>
<version>0.3.1</version>
<executions>
<execution>
<goals>
<goal>prepare</goal>
</goals>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<failOnUnresolved>true</failOnUnresolved>
<writeReport>true</writeReport>
</configuration>
</plugin>
</plugins>
</build>- Does not rewrite calls with non-literal template arguments.
- Does not evaluate arbitrary Java expressions inside placeholders.
- Does not transform methods other than BPJ public formatting/printing APIs.
- Operates at source level, not bytecode level.
- Add
bpjdependency. - Add
bpj-maven-pluginexecution (prepare). - Write simple BPJ calls with placeholders.
- Let build-time transformation inject context maps automatically.