Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
fff0ff1
Make @SimpleBuilder @Inherited to match documentation (#244)
AndreasIgel Aug 15, 2026
13a8fc8
Rename to BuilderAnnotationInheritanceTest and cover Template inherit…
AndreasIgel Aug 15, 2026
105310a
Refactoring code to move assertNoBuilderGenerated to common asserts
AndreasIgel Aug 15, 2026
2c83b78
fixing codeformat
AndreasIgel Aug 15, 2026
aca9ef6
Document @Inherited behavior of @SimpleBuilder.Template
AndreasIgel Aug 15, 2026
bd3bf93
Document options-inheritance limitation for inherited subclass builders
AndreasIgel Aug 15, 2026
e8e0352
Fix issue reference: #245 -> #248
AndreasIgel Aug 15, 2026
9776343
Clarify @SimpleBuilder vs @SimpleBuilder.Template usage in docs
AndreasIgel Aug 15, 2026
4b7723a
Link issue #248 from @SimpleBuilder.Template inheritance Javadoc
AndreasIgel Aug 15, 2026
218ea79
Remove redundant troubleshooting item about @SimpleBuilder.Template t…
AndreasIgel Aug 15, 2026
bd6020d
Merge remote-tracking branch 'upstream/main'
devin-ai-integration[bot] Aug 16, 2026
62d1269
Merge remote-tracking branch 'upstream/main'
devin-ai-integration[bot] Aug 16, 2026
ec99605
Merge upstream main
devin-ai-integration[bot] Aug 22, 2026
640bc82
Merge branch 'java-helpers:main' into main
AndreasIgel Sep 2, 2026
ab8a052
feat: fall back to -D system properties for compiler options (#275)
devin-ai-integration[bot] Sep 5, 2026
e30c859
fix: let -D system property override -A compiler arguments (#275)
devin-ai-integration[bot] Sep 5, 2026
9f012cd
docs: clarify -D option wording (#275)
devin-ai-integration[bot] Sep 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Simple-builders supports fine-grained configuration through the `@SimpleBuilder.
- [Maven Configuration](#maven-configuration)
- [Gradle Configuration](#gradle-configuration)
- [IntelliJ IDEA Configuration](#intellij-idea-configuration)
- [Command Line (-D)](#command-line--d)
- [Configuration Options](#configuration-options)
- [Field Setter Generation](#field-setter-generation)
- [Conditional Logic](#conditional-logic)
Expand Down Expand Up @@ -221,6 +222,13 @@ compileJava {
-Asimplebuilder.generateFieldSupplier=true -Asimplebuilder.builderAccess=PUBLIC
```

### Command Line (-D)

Maven and Gradle accept the options as JVM system properties without a build-file change, for example `mvn compile -Dsimplebuilder.generateJavaDoc=DISABLED` or `gradle compileJava -Dsimplebuilder.generateJavaDoc=DISABLED`.
The precedence is `@SimpleBuilder.Options` > `-D` system property > `-A` compiler argument > default.
The system property wins so you can override options configured in the build file from the command line without editing it.
This relies on javac running in the build tool's JVM (the default for Maven and Gradle); use the `-A` form for forked compilation (`<fork>true</fork>` / `options.fork = true`) and IDE builds. Gradle also accepts `systemProp.simplebuilder.<option>=...` in `gradle.properties`; note that Gradle does not track the property as a task input, so run `clean` or `--rerun-tasks` after changing it.

## Configuration Options

All options use `OptionState` enum with values: `ENABLED`, `DISABLED`, or `UNSET` (uses default/compiler arg).
Expand Down Expand Up @@ -1264,7 +1272,7 @@ Or in compiler options:

### Compiler Options Not Working

1. **Check option names**: Ensure you're using the full option name (e.g., `-Asimplebuilder.generateFieldSupplier`)
1. **Check option names**: Ensure you're using the full option name (e.g., `-Asimplebuilder.generateFieldSupplier`); the same name also works as a JVM system property (`-Dsimplebuilder.<option>`), which takes precedence over `-A`
2. **Verify processor is running**: Ensure annotation processor is configured correctly
3. **Check IDE configuration**: Some IDEs need special configuration for compiler options
4. **Clean and rebuild**: Run `mvn clean compile` to ensure fresh build
Expand Down
4 changes: 3 additions & 1 deletion docs/DEBUG_LOGGING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ The Simple Builders annotation processor supports conditional debug logging that

## Enabling Debug Logging

Debug logging uses `Diagnostic.Kind.OTHER` but is only activated when explicitly enabled via the compiler argument `-Averbose=true`.
Debug logging uses `Diagnostic.Kind.OTHER` but is only activated when explicitly enabled via the compiler argument `-Averbose=true` or the Maven system property `-Dsimplebuilder.verbose=true`.

When Maven runs javac in-process, `mvn clean compile -Dsimplebuilder.verbose=true` works without an `-Averbose=${simplebuilder.verbose}` mapping in `pom.xml`, and the `-D` value overrides any `-A` mapping from the build file. Gradle also supports `-Dsimplebuilder.verbose=true` (or `systemProp.simplebuilder.verbose=true` in `gradle.properties`) with in-process compilation; use the `-A` mapping for forked compilation and IDE builds. Gradle does not track the property as a task input, so run `clean` or `--rerun-tasks` after changing it.

### Option 1: Via Maven Property (Recommended)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,25 @@ public CompilerArgumentsReader(ProcessingEnvironment processingEnv) {
/**
* Reads the value of a compiler argument.
*
* <p>The method looks up the compiler argument using both the full compiler argument name (with
* prefix) and the simple option name (without prefix) for backward compatibility.
* <p>The method checks the prefixed JVM system property first, then the prefixed compiler
* argument, and finally the bare option name for backward compatibility. The system property wins
* so a command-line {@code -D} can override options configured in the build file. The system
* property is available when the build tool runs javac in-process and is not available with
* {@code <fork>true</fork>}.
*
* @param argument the compiler argument enum to read
* @return the value of the compiler argument, or null if not set
*/
public String readValue(CompilerArgumentsEnum argument) {
// Try with full compiler argument name first (e.g., "simplebuilder.verbose")
String value = processingEnv.getOptions().get(argument.getCompilerArgument());
// Try the -D JVM system property first (e.g., -Dsimplebuilder.verbose)
String value = System.getProperty(argument.getCompilerArgument());

// Fall back to simple option name for backward compatibility (e.g., "verbose")
// Then the -A compiler argument (e.g., -Asimplebuilder.verbose)
if (value == null) {
value = processingEnv.getOptions().get(argument.getCompilerArgument());
}

// Finally the bare option name for backward compatibility (e.g., -Averbose)
if (value == null) {
value = processingEnv.getOptions().get(argument.getOptionName());
}
Expand Down Expand Up @@ -129,11 +137,18 @@ public AccessModifier readAccessModifier(CompilerArgumentsEnum argument) {
* <p>This method reads all configuration options from compiler arguments like:
*
* <ul>
* <li>{@code -Asimplebuilder.generateFieldSupplier=true}
* <li>{@code -Dsimplebuilder.generateFieldSupplier=true} (JVM system property, highest
* precedence)
* <li>{@code -Asimplebuilder.generateFieldSupplier=true} (compiler argument)
* <li>{@code -AgenerateFieldSupplier=true} (bare option name, backward compatibility)
* <li>{@code -Asimplebuilder.builderAccess=public}
* <li>etc.
* </ul>
*
* <p>Options set via {@code @SimpleBuilder.Options} on the annotated type are not handled here;
* they are read by {@link BuilderConfigurationReader} and merged on top of this global
* configuration.
*
* <p>All values default to UNSET or DEFAULT if not specified in compiler arguments.
*
* <p><b>Adding a new option:</b> every option in {@link CompilerArgumentsEnum} that represents a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,47 @@ void readValue_OnlySimpleNameSet_UsesSimpleName() {
"Should fall back to simple option name");
}

@Test
void readValue_SystemPropertySet_FallsBackToSystemProperty() {
System.setProperty("simplebuilder.verbose", "true");
try {
ProcessingEnvironment env = ProcessingEnvironmentStub.createEmpty();
CompilerArgumentsReader reader = new CompilerArgumentsReader(env);

assertEquals("true", reader.readValue(CompilerArgumentsEnum.VERBOSE));
assertTrue(reader.readBooleanValue(CompilerArgumentsEnum.VERBOSE));
} finally {
System.clearProperty("simplebuilder.verbose");
}
}

@Test
void readValue_CompilerArgAndSystemPropertySet_PrefersSystemProperty() {
System.setProperty("simplebuilder.verbose", "true");
try {
ProcessingEnvironment env =
ProcessingEnvironmentStub.builder().put("simplebuilder.verbose", "false").build();
CompilerArgumentsReader reader = new CompilerArgumentsReader(env);

assertEquals("true", reader.readValue(CompilerArgumentsEnum.VERBOSE));
} finally {
System.clearProperty("simplebuilder.verbose");
}
}

@Test
void readValue_BareNameSystemProperty_Ignored() {
System.setProperty("verbose", "true");
try {
ProcessingEnvironment env = ProcessingEnvironmentStub.createEmpty();
CompilerArgumentsReader reader = new CompilerArgumentsReader(env);

assertNull(reader.readValue(CompilerArgumentsEnum.VERBOSE));
} finally {
System.clearProperty("verbose");
}
}

/** Test: readBooleanValue returns false when value is null. */
@Test
void readBooleanValue_NullValue_ReturnsFalse() {
Expand Down