Skip to content

Commit 0271efa

Browse files
committed
Polish "Avoid setting null compiler option"
See gh-36971
1 parent a0ad00c commit 0271efa

File tree

1 file changed

+10
-14
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven

1 file changed

+10
-14
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractAotMojo.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,16 @@ protected final void compileSourceFiles(URL[] classPath, File sourcesDirectory,
153153
options.add(releaseVersion);
154154
}
155155
else {
156-
setSourceAndTargetVersions(compilerConfiguration, options);
156+
String source = compilerConfiguration.getSourceMajorVersion();
157+
if (source != null) {
158+
options.add("--source");
159+
options.add(source);
160+
}
161+
String target = compilerConfiguration.getTargetMajorVersion();
162+
if (target != null) {
163+
options.add("--target");
164+
options.add(target);
165+
}
157166
}
158167
options.addAll(new RunArguments(this.compilerArguments).getArgs());
159168
Iterable<? extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjectsFromPaths(sourceFiles);
@@ -165,19 +174,6 @@ protected final void compileSourceFiles(URL[] classPath, File sourcesDirectory,
165174
}
166175
}
167176
}
168-
private static void setSourceAndTargetVersions(JavaCompilerPluginConfiguration compilerConfiguration,
169-
List<String> options) {
170-
String sourceMajorVersion = compilerConfiguration.getSourceMajorVersion();
171-
if (sourceMajorVersion != null && !sourceMajorVersion.isEmpty()) {
172-
options.add("--source");
173-
options.add(sourceMajorVersion);
174-
}
175-
String targetMajorVersion = compilerConfiguration.getTargetMajorVersion();
176-
if (targetMajorVersion != null && !targetMajorVersion.isEmpty()) {
177-
options.add("--target");
178-
options.add(targetMajorVersion);
179-
}
180-
}
181177

182178
protected final URL[] getClassPath(File[] directories, ArtifactsFilter... artifactFilters)
183179
throws MojoExecutionException {

0 commit comments

Comments
 (0)