Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public class JavaCompilerOptions {
*/
private String annotationProcessors;

/**
* Additional compiler arguments from maven-compiler-plugin's compilerArgs configuration.
*/
private List<String> compilerArgs;

/**
* Get list of options that can be passed to the compiler.
* Options with values are represented as multiple strings in the list
Expand All @@ -74,6 +79,12 @@ public List<String> getOptions() {
addStringOption(options, "-encoding", encoding);
addStringOption(options, "-processorpath", annotationProcessorPath);
addStringOption(options, "-processor", annotationProcessors);

// Add compiler arguments from <compilerArgs> configuration
if (compilerArgs != null && !compilerArgs.isEmpty()) {
options.addAll(compilerArgs);
}

return options;
}

Expand Down Expand Up @@ -140,4 +151,12 @@ public void setAnnotationProcessors(String annotationProcessors) {
this.annotationProcessors = annotationProcessors;
}

public List<String> getCompilerArgs() {
return compilerArgs;
}

public void setCompilerArgs(List<String> compilerArgs) {
this.compilerArgs = compilerArgs;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,19 @@ public void testAnnotationProcessorsEmpty() throws Exception {
assertTrue(result.contains("-nowarn"));
}

@Test
public void testCompilerArgs() throws Exception {
JavaCompilerOptions jco = new JavaCompilerOptions();
List<String> args = new java.util.ArrayList<>();
args.add("-parameters");
args.add("-Xlint:unchecked");
jco.setCompilerArgs(args);

List<String> result = jco.getOptions();
assertEquals(3, result.size());
assertTrue(result.contains("-nowarn"));
assertTrue(result.contains("-parameters"));
assertTrue(result.contains("-Xlint:unchecked"));
}

}
Loading