|
|
@ -26,6 +26,7 @@ import java.nio.charset.StandardCharsets;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.TreeMap;
|
|
|
|
import java.util.TreeMap;
|
|
|
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
|
|
|
|
|
|
|
import io.spring.javaformat.gradle.FormatTask;
|
|
|
|
import io.spring.javaformat.gradle.FormatTask;
|
|
|
|
import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
|
|
|
|
import io.spring.javaformat.gradle.SpringJavaFormatPlugin;
|
|
|
@ -127,10 +128,11 @@ public class ConventionsPlugin implements Plugin<Project> {
|
|
|
|
project.setProperty("sourceCompatibility", "1.8");
|
|
|
|
project.setProperty("sourceCompatibility", "1.8");
|
|
|
|
project.getTasks().withType(JavaCompile.class, (compile) -> {
|
|
|
|
project.getTasks().withType(JavaCompile.class, (compile) -> {
|
|
|
|
compile.getOptions().setEncoding("UTF-8");
|
|
|
|
compile.getOptions().setEncoding("UTF-8");
|
|
|
|
if (hasCustomBuildJavaHome(project)) {
|
|
|
|
withOptionalBuildJavaHome(project, (javaHome) -> {
|
|
|
|
String javaExecutable = getCustomBuildJavaExecutable(project, "/bin/java");
|
|
|
|
compile.getOptions().setFork(true);
|
|
|
|
compile.getOptions().getForkOptions().setJavaHome(new File(javaExecutable));
|
|
|
|
compile.getOptions().getForkOptions().setJavaHome(new File(javaHome));
|
|
|
|
}
|
|
|
|
compile.getOptions().getForkOptions().setExecutable(javaHome + "/bin/javac");
|
|
|
|
|
|
|
|
});
|
|
|
|
List<String> args = compile.getOptions().getCompilerArgs();
|
|
|
|
List<String> args = compile.getOptions().getCompilerArgs();
|
|
|
|
if (!args.contains("-parameters")) {
|
|
|
|
if (!args.contains("-parameters")) {
|
|
|
|
args.add("-parameters");
|
|
|
|
args.add("-parameters");
|
|
|
@ -138,16 +140,10 @@ public class ConventionsPlugin implements Plugin<Project> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
project.getTasks().withType(Javadoc.class, (javadoc) -> {
|
|
|
|
project.getTasks().withType(Javadoc.class, (javadoc) -> {
|
|
|
|
javadoc.getOptions().source("1.8").encoding("UTF-8");
|
|
|
|
javadoc.getOptions().source("1.8").encoding("UTF-8");
|
|
|
|
if (hasCustomBuildJavaHome(project)) {
|
|
|
|
withOptionalBuildJavaHome(project, (javaHome) -> javadoc.setExecutable(javaHome + "/bin/javadoc"));
|
|
|
|
String javaExecutable = getCustomBuildJavaExecutable(project, "/bin/javadoc");
|
|
|
|
|
|
|
|
javadoc.setExecutable(javaExecutable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
project.getTasks().withType(Test.class, (test) -> {
|
|
|
|
project.getTasks().withType(Test.class, (test) -> {
|
|
|
|
if (hasCustomBuildJavaHome(project)) {
|
|
|
|
withOptionalBuildJavaHome(project, (javaHome) -> test.setExecutable(javaHome + "/bin/java"));
|
|
|
|
String javaExecutable = getCustomBuildJavaExecutable(project, "/bin/java");
|
|
|
|
|
|
|
|
test.setExecutable(javaExecutable);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
test.useJUnitPlatform();
|
|
|
|
test.useJUnitPlatform();
|
|
|
|
test.setMaxHeapSize("1024M");
|
|
|
|
test.setMaxHeapSize("1024M");
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -205,12 +201,11 @@ public class ConventionsPlugin implements Plugin<Project> {
|
|
|
|
return legalFile;
|
|
|
|
return legalFile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private boolean hasCustomBuildJavaHome(Project project) {
|
|
|
|
private void withOptionalBuildJavaHome(Project project, Consumer<String> consumer) {
|
|
|
|
return project.hasProperty("buildJavaHome") && !((String) project.property("buildJavaHome")).isEmpty();
|
|
|
|
String buildJavaHome = (String) project.findProperty("buildJavaHome");
|
|
|
|
}
|
|
|
|
if (buildJavaHome != null && !buildJavaHome.isEmpty()) {
|
|
|
|
|
|
|
|
consumer.accept(buildJavaHome);
|
|
|
|
private String getCustomBuildJavaExecutable(Project project, String executable) {
|
|
|
|
}
|
|
|
|
return project.property("buildJavaHome") + executable;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void configureSpringJavaFormat(Project project) {
|
|
|
|
private void configureSpringJavaFormat(Project project) {
|
|
|
|