Polish "Avoid setting null compiler option"

See gh-36971
pull/37018/head
Stephane Nicoll 1 year ago
parent a0ad00c542
commit 0271efae4c

@ -153,7 +153,16 @@ public abstract class AbstractAotMojo extends AbstractDependencyFilterMojo {
options.add(releaseVersion);
}
else {
setSourceAndTargetVersions(compilerConfiguration, options);
String source = compilerConfiguration.getSourceMajorVersion();
if (source != null) {
options.add("--source");
options.add(source);
}
String target = compilerConfiguration.getTargetMajorVersion();
if (target != null) {
options.add("--target");
options.add(target);
}
}
options.addAll(new RunArguments(this.compilerArguments).getArgs());
Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromPaths(sourceFiles);
@ -165,19 +174,6 @@ public abstract class AbstractAotMojo extends AbstractDependencyFilterMojo {
}
}
}
private static void setSourceAndTargetVersions(JavaCompilerPluginConfiguration compilerConfiguration,
List<String> options) {
String sourceMajorVersion = compilerConfiguration.getSourceMajorVersion();
if (sourceMajorVersion != null && !sourceMajorVersion.isEmpty()) {
options.add("--source");
options.add(sourceMajorVersion);
}
String targetMajorVersion = compilerConfiguration.getTargetMajorVersion();
if (targetMajorVersion != null && !targetMajorVersion.isEmpty()) {
options.add("--target");
options.add(targetMajorVersion);
}
}
protected final URL[] getClassPath(File[] directories, ArtifactsFilter... artifactFilters)
throws MojoExecutionException {

Loading…
Cancel
Save