Bugfix
This commit is contained in:
parent
9899f6cd95
commit
88b940dfa5
@ -2905,20 +2905,22 @@ public class SourcesGenerator {
|
|||||||
|
|
||||||
private void writeClass(Path outPath, String classPackage, Builder versionsClass) throws IOException {
|
private void writeClass(Path outPath, String classPackage, Builder versionsClass) throws IOException {
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
JavaFile.builder(classPackage, versionsClass.build()).build().writeTo(sb);
|
var typeSpec = versionsClass.build();
|
||||||
|
var outJavaFile = outPath.resolve(typeSpec.name + ".java");
|
||||||
|
JavaFile.builder(classPackage, typeSpec).build().writeTo(sb);
|
||||||
String newFile = sb.toString();
|
String newFile = sb.toString();
|
||||||
boolean mustWrite;
|
boolean mustWrite;
|
||||||
if (Files.isRegularFile(outPath) && Files.isReadable(outPath)) {
|
if (Files.isRegularFile(outJavaFile) && Files.isReadable(outJavaFile)) {
|
||||||
String oldFile = Files.readString(outPath, StandardCharsets.UTF_8);
|
String oldFile = Files.readString(outJavaFile, StandardCharsets.UTF_8);
|
||||||
mustWrite = !oldFile.equals(newFile);
|
mustWrite = !oldFile.equals(newFile);
|
||||||
} else {
|
} else {
|
||||||
mustWrite = true;
|
mustWrite = true;
|
||||||
}
|
}
|
||||||
if (mustWrite) {
|
if (mustWrite) {
|
||||||
logger.debug("File {} changed", outPath);
|
logger.debug("File {} changed", outJavaFile);
|
||||||
Files.writeString(outPath, newFile);
|
Files.writeString(outJavaFile, newFile);
|
||||||
} else {
|
} else {
|
||||||
logger.debug("File {} is the same, unchanged", outPath);
|
logger.debug("File {} is the same, unchanged", outJavaFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user