diff --git a/Plan/common/build.gradle b/Plan/common/build.gradle index b9c29fe52..75c02e52f 100644 --- a/Plan/common/build.gradle +++ b/Plan/common/build.gradle @@ -30,33 +30,35 @@ task updateVersion(type: Copy) { } task determineWebAssetModifications { - def versionFile = file("build/resources/main/assets/plan/WebAssetVersion.yml") - versionFile.parentFile.mkdirs() - versionFile.text = "" // Clear previous build - ConfigurableFileTree tree = fileTree(dir: 'src/main/resources/assets/plan/web') - tree.forEach { File f -> - def gitModified = new ByteArrayOutputStream() - exec { - commandLine 'git', 'log', '-1', '--pretty=%ct', f.toString() - standardOutput = gitModified + doLast { + mkdir "build/resources/main/assets/plan" + def versionFile = file("build/resources/main/assets/plan/WebAssetVersion.yml") + versionFile.text = "" // Clear previous build + ConfigurableFileTree tree = fileTree(dir: 'src/main/resources/assets/plan/web') + tree.forEach { File f -> + def gitModified = new ByteArrayOutputStream() + exec { + commandLine 'git', 'log', '-1', '--pretty=%ct', f.toString() + standardOutput = gitModified + } + // git returns UNIX time in seconds, but most things in Java use UNIX time in milliseconds + def modified = Long.parseLong(gitModified.toString().strip()) * 1000 + def relativePath = tree.getDir().toPath().relativize(f.toPath()) // File path relative to the tree + versionFile.text += String.format( // writing YAML as raw text probably isn't the best idea + "%s: %s\n", relativePath.toString().replace('.', ','), modified + ) } - // git returns UNIX time in seconds, but most things in Java use UNIX time in milliseconds - def modified = Long.parseLong(gitModified.toString().strip()) * 1000 - def relativePath = tree.getDir().toPath().relativize(f.toPath()) // File path relative to the tree - versionFile.text += String.format( // writing YAML as raw text probably isn't the best idea - "%s: %s\n", relativePath.toString().replace('.', ','), modified - ) } } processResources { + dependsOn determineWebAssetModifications duplicatesStrategy = DuplicatesStrategy.INCLUDE dependsOn updateVersion from 'build/sources/resources' } shadowJar { - dependsOn determineWebAssetModifications dependsOn processResources // Exclude these files diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/web/WebAssetVersionCheckTask.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/web/WebAssetVersionCheckTask.java index 05271872e..ec4c3c401 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/web/WebAssetVersionCheckTask.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/web/WebAssetVersionCheckTask.java @@ -72,7 +72,7 @@ public class WebAssetVersionCheckTask extends TaskSystem.Task { try { webAssetVersions.prepare(); } catch (IOException e) { - logger.warn("Could not read web asset versions, ", e); + logger.warn(String.format("Could not read web asset versions, %s", e.toString())); logger.warn("Web asset version check will be skipped!"); return; } @@ -92,27 +92,27 @@ public class WebAssetVersionCheckTask extends TaskSystem.Task { } for (AssetInfo asset : outdated) { logger.warn(String.format("- %s was modified %s, but the plugin contains a version from %s", - asset.filename, - formatters.secondLong().apply(asset.modifiedAt), - formatters.secondLong().apply(asset.expectedModifiedAt) + asset.filename, + formatters.secondLong().apply(asset.modifiedAt), + formatters.secondLong().apply(asset.expectedModifiedAt) )); } } } private Optional findOutdatedResource(String resource) { - Optional resourceFile = files.attemptToFind(resource); - Optional webAssetVersion = webAssetVersions.getWebAssetVersion(resource); - if (resourceFile.isPresent() && webAssetVersion.isPresent()) { - if (webAssetVersion.get() > resourceFile.get().lastModified()) { - return Optional.of(new AssetInfo( - resource, - resourceFile.get().lastModified(), - webAssetVersion.get() - )); - } - } - return Optional.empty(); + Optional resourceFile = files.attemptToFind(resource); + Optional webAssetVersion = webAssetVersions.getWebAssetVersion(resource); + if (resourceFile.isPresent() && webAssetVersion.isPresent()) { + if (webAssetVersion.get() > resourceFile.get().lastModified()) { + return Optional.of(new AssetInfo( + resource, + resourceFile.get().lastModified(), + webAssetVersion.get() + )); + } + } + return Optional.empty(); } private Optional getPlanCustomizationNode() {