From d7e9850f9a663dba7d16923f78461adf63e6b202 Mon Sep 17 00:00:00 2001 From: Gravita Date: Thu, 22 Dec 2022 19:48:31 +0700 Subject: [PATCH] [ANY] IDEA code inspection --- LaunchServer/build.gradle | 18 ++++----- Launcher/build.gradle | 8 ++-- .../launcher/BasicLauncherEventHandler.java | 9 ++--- .../pro/gravit/launcher/LauncherEngine.java | 12 +++--- .../launcher/api/CertificateService.java | 22 ++++------- .../launcher/utils/ApiBridgeService.java | 3 +- LauncherAPI/build.gradle | 4 +- .../pro/gravit/launcher/LauncherConfig.java | 4 +- .../websockets/StdWebSocketService.java | 3 +- .../websockets/WebSocketClientHandler.java | 6 +-- LauncherCore/build.gradle | 4 +- .../pro/gravit/launcher/hasher/HashedDir.java | 37 ++++++++----------- .../pro/gravit/launcher/serialize/HInput.java | 13 +++---- .../pro/gravit/utils/helper/CommonHelper.java | 13 +++---- .../pro/gravit/utils/helper/FormatHelper.java | 17 +++------ .../pro/gravit/utils/helper/IOHelper.java | 5 +-- .../utils/logging/Slf4jLogHelperImpl.java | 20 +++------- ServerWrapper/build.gradle | 4 +- .../gravit/launcher/server/ServerWrapper.java | 17 +++------ .../server/authlib/InstallAuthlib.java | 4 +- build.gradle | 10 +++-- 21 files changed, 93 insertions(+), 140 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index d57c46c5..d92c5c52 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -50,17 +50,17 @@ } } -task sourcesJar(type: Jar) { +tasks.register('sourcesJar') { from sourceSets.main.allJava archiveClassifier.set('sources') } -task javadocJar(type: Jar) { +tasks.register('javadocJar') { from javadoc archiveClassifier.set('javadoc') } -task cleanjar(type: Jar, dependsOn: jar) { +tasks.register('cleanjar') { archiveClassifier.set('clean') manifest.attributes("Main-Class": mainClassName, "Premain-Class": mainAgentName, @@ -117,13 +117,13 @@ pack project(':LauncherAPI') compileOnlyA 'org.apache.logging.log4j:log4j-core:2.14.1' } -task hikari(type: Copy) { +tasks.register('hikari') { duplicatesStrategy = 'EXCLUDE' into "$buildDir/libs/libraries/hikaricp" from configurations.hikari } -task launch4j(type: Copy) { +tasks.register('launch4j') { duplicatesStrategy = 'EXCLUDE' into "$buildDir/libs/libraries/launch4j" from(configurations.launch4j.collect { @@ -141,20 +141,20 @@ task launch4j(type: Copy) { } } -task dumpLibs(type: Copy) { +tasks.register('dumpLibs') { duplicatesStrategy = 'EXCLUDE' dependsOn tasks.hikari, tasks.launch4j into "$buildDir/libs/libraries" from configurations.bundleOnly } -task dumpCompileOnlyLibs(type: Copy) { +tasks.register('dumpCompileOnlyLibs') { duplicatesStrategy = 'EXCLUDE' into "$buildDir/libs/launcher-libraries-compile" from configurations.compileOnlyA } -task bundle(type: Zip) { +tasks.register('bundle') { duplicatesStrategy = 'EXCLUDE' dependsOn parent.childProjects.Launcher.tasks.build, tasks.dumpLibs, tasks.dumpCompileOnlyLibs, tasks.jar archiveFileName = 'LaunchServer.zip' @@ -165,7 +165,7 @@ task bundle(type: Zip) { from(parent.childProjects.Launcher.tasks.dumpLibs) { into 'launcher-libraries' } } -task dumpClientLibs(type: Copy) { +tasks.register('dumpClientLibs') { dependsOn parent.childProjects.Launcher.tasks.build into "$buildDir/libs/launcher-libraries" from parent.childProjects.Launcher.tasks.dumpLibs diff --git a/Launcher/build.gradle b/Launcher/build.gradle index 70c6e99a..c11055a0 100644 --- a/Launcher/build.gradle +++ b/Launcher/build.gradle @@ -29,12 +29,12 @@ "Multi-Release": "true") } -task sourcesJar(type: Jar) { +tasks.register('sourcesJar') { from sourceSets.main.allJava archiveClassifier.set('sources') } -task javadocJar(type: Jar) { +tasks.register('javadocJar') { from javadoc archiveClassifier.set('javadoc') } @@ -53,14 +53,14 @@ pack project(':LauncherAPI') pack group: 'io.netty', name: 'netty-codec-http', version: rootProject['verNetty'] } -task genRuntimeJS(type: Zip) { +tasks.register('genRuntimeJS') { duplicatesStrategy = 'EXCLUDE' archiveFileName = "runtime.zip" destinationDirectory = file("${buildDir}/tmp") from "runtime/" } -task dumpLibs(type: Copy) { +tasks.register('dumpLibs') { duplicatesStrategy = 'EXCLUDE' into "$buildDir/libs/libraries" from configurations.bundle diff --git a/Launcher/src/main/java/pro/gravit/launcher/BasicLauncherEventHandler.java b/Launcher/src/main/java/pro/gravit/launcher/BasicLauncherEventHandler.java index c02deec7..2c8f834d 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/BasicLauncherEventHandler.java +++ b/Launcher/src/main/java/pro/gravit/launcher/BasicLauncherEventHandler.java @@ -13,8 +13,7 @@ public class BasicLauncherEventHandler implements RequestService.EventHandler { @Override public boolean eventHandle(T event) { - if (event instanceof SecurityReportRequestEvent) { - SecurityReportRequestEvent event1 = (SecurityReportRequestEvent) event; + if (event instanceof SecurityReportRequestEvent event1) { if (event1.action == SecurityReportRequestEvent.ReportAction.CRASH) { LauncherEngine.exitLauncher(80); } else if (event1.action == SecurityReportRequestEvent.ReportAction.TOKEN_EXPIRED) { @@ -24,14 +23,12 @@ public boolean eventHandle(T event) { LogHelper.error(e); } } - } else if (event instanceof ExtendedTokenRequestEvent) { - ExtendedTokenRequestEvent event1 = (ExtendedTokenRequestEvent) event; + } else if (event instanceof ExtendedTokenRequestEvent event1) { String token = event1.getExtendedToken(); if (token != null) { Request.addExtendedToken(event1.getExtendedTokenName(), token); } - } else if (event instanceof NotificationEvent) { - NotificationEvent n = (NotificationEvent) event; + } else if (event instanceof NotificationEvent n) { if (DialogService.isNotificationsAvailable()) { DialogService.createNotification(n.icon, n.head, n.message); } diff --git a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java index 0294860b..0ffb0a6c 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java +++ b/Launcher/src/main/java/pro/gravit/launcher/LauncherEngine.java @@ -154,13 +154,11 @@ public static void verifyNoAgent() { } public static LauncherGuard tryGetStdGuard() { - switch (Launcher.getConfig().guardType) { - case "no": - return new LauncherNoGuard(); - case "wrapper": - return new LauncherWrapperGuard(); - } - return null; + return switch (Launcher.getConfig().guardType) { + case "no" -> new LauncherNoGuard(); + case "wrapper" -> new LauncherWrapperGuard(); + default -> null; + }; } public static RequestService initOffline() { diff --git a/Launcher/src/main/java/pro/gravit/launcher/api/CertificateService.java b/Launcher/src/main/java/pro/gravit/launcher/api/CertificateService.java index 4bf651fd..9b1a3566 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/api/CertificateService.java +++ b/Launcher/src/main/java/pro/gravit/launcher/api/CertificateService.java @@ -79,20 +79,14 @@ private static CheckClassResultApi fromCheckClassResult(LauncherTrustManager.Che private static CheckClassResultTypeApi fromType(LauncherTrustManager.CheckClassResultType type) { if (type == null) return null; - switch (type) { - case NOT_SIGNED: - return CheckClassResultTypeApi.NOT_SIGNED; - case SUCCESS: - return CheckClassResultTypeApi.SUCCESS; - case UNTRUSTED: - return CheckClassResultTypeApi.UNTRUSTED; - case UNVERIFED: - return CheckClassResultTypeApi.UNVERIFED; - case UNCOMPAT: - return CheckClassResultTypeApi.UNCOMPAT; - default: - return CheckClassResultTypeApi.UNKNOWN; - } + return switch (type) { + case NOT_SIGNED -> CheckClassResultTypeApi.NOT_SIGNED; + case SUCCESS -> CheckClassResultTypeApi.SUCCESS; + case UNTRUSTED -> CheckClassResultTypeApi.UNTRUSTED; + case UNVERIFED -> CheckClassResultTypeApi.UNVERIFED; + case UNCOMPAT -> CheckClassResultTypeApi.UNCOMPAT; + default -> CheckClassResultTypeApi.UNKNOWN; + }; } } } diff --git a/Launcher/src/main/java/pro/gravit/launcher/utils/ApiBridgeService.java b/Launcher/src/main/java/pro/gravit/launcher/utils/ApiBridgeService.java index 76cb77d9..68fc94c1 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/utils/ApiBridgeService.java +++ b/Launcher/src/main/java/pro/gravit/launcher/utils/ApiBridgeService.java @@ -18,8 +18,7 @@ public static void checkCertificatesSuccess(X509Certificate[] certs) throws Exce } public static String findLibrary(ClassLoader classLoader, String library) { - if (classLoader instanceof ClientClassLoader) { - ClientClassLoader clientClassLoader = (ClientClassLoader) classLoader; + if (classLoader instanceof ClientClassLoader clientClassLoader) { return clientClassLoader.findLibrary(library); } return null; diff --git a/LauncherAPI/build.gradle b/LauncherAPI/build.gradle index 413a4c21..d8674f53 100644 --- a/LauncherAPI/build.gradle +++ b/LauncherAPI/build.gradle @@ -21,12 +21,12 @@ api project(':LauncherCore') archiveClassifier.set('clean') } -task sourcesJar(type: Jar) { +tasks.register('sourcesJar') { from sourceSets.main.allJava archiveClassifier.set('sources') } -task javadocJar(type: Jar) { +tasks.register('javadocJar') { from javadoc archiveClassifier.set('javadoc') } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java index 290d64e3..63fba7c7 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/LauncherConfig.java @@ -88,7 +88,7 @@ public LauncherConfig(String address, ECPublicKey ecdsaPublicKey, RSAPublicKey r this.address = address; this.ecdsaPublicKey = ecdsaPublicKey; this.rsaPublicKey = rsaPublicKey; - this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime)); + this.runtime = Map.copyOf(runtime); this.projectName = projectName; this.clientPort = 32148; guardType = "no"; @@ -102,7 +102,7 @@ public LauncherConfig(String address, ECPublicKey ecdsaPublicKey, RSAPublicKey r public LauncherConfig(String address, Map runtime, String projectName, LauncherEnvironment env, LauncherTrustManager trustManager) { this.address = address; - this.runtime = Collections.unmodifiableMap(new HashMap<>(runtime)); + this.runtime = Map.copyOf(runtime); this.projectName = projectName; this.clientPort = 32148; this.trustManager = trustManager; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java index ad6212e1..d56a5c6f 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/StdWebSocketService.java @@ -76,8 +76,7 @@ public void processEventHandlers(T event) { @SuppressWarnings({"unchecked", "deprecation"}) public void eventHandle(T webSocketEvent) { - if (webSocketEvent instanceof RequestEvent) { - RequestEvent event = (RequestEvent) webSocketEvent; + if (webSocketEvent instanceof RequestEvent event) { if (event.requestUUID == null) { LogHelper.warning("Request event type %s.requestUUID is null", event.getType() == null ? "null" : event.getType()); return; diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java index 58cd35be..45c61b41 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/websockets/WebSocketClientHandler.java @@ -51,15 +51,13 @@ protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Except return; } - if (msg instanceof FullHttpResponse) { - final FullHttpResponse response = (FullHttpResponse) msg; + if (msg instanceof final FullHttpResponse response) { throw new Exception("Unexpected FullHttpResponse (getStatus=" + response.status() + ", content=" + response.content().toString(CharsetUtil.UTF_8) + ')'); } final WebSocketFrame frame = (WebSocketFrame) msg; - if (frame instanceof TextWebSocketFrame) { - final TextWebSocketFrame textFrame = (TextWebSocketFrame) frame; + if (frame instanceof final TextWebSocketFrame textFrame) { if (LogHelper.isDevEnabled()) { LogHelper.dev("Message: %s", textFrame.text()); } diff --git a/LauncherCore/build.gradle b/LauncherCore/build.gradle index 244835ac..1ca2d911 100644 --- a/LauncherCore/build.gradle +++ b/LauncherCore/build.gradle @@ -27,12 +27,12 @@ archiveClassifier.set('clean') } -task sourcesJar(type: Jar) { +tasks.register('sourcesJar') { from sourceSets.main.allJava archiveClassifier.set('sources') } -task javadocJar(type: Jar) { +tasks.register('javadocJar') { from javadoc archiveClassifier.set('javadoc') } diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedDir.java b/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedDir.java index 71b28e17..ac01a6ac 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedDir.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/hasher/HashedDir.java @@ -30,16 +30,11 @@ public HashedDir(HInput input) throws IOException { // Read entry HashedEntry entry; Type type = Type.read(input); - switch (type) { - case FILE: - entry = new HashedFile(input); - break; - case DIR: - entry = new HashedDir(input); - break; - default: - throw new AssertionError("Unsupported hashed entry type: " + type.name()); - } + entry = switch (type) { + case FILE -> new HashedFile(input); + case DIR -> new HashedDir(input); + default -> throw new AssertionError("Unsupported hashed entry type: " + type.name()); + }; // Try add entry to map VerifyHelper.putIfAbsent(map, name, entry, String.format("Duplicate dir entry: '%s'", name)); @@ -157,13 +152,13 @@ private HashedDir sideDiff(HashedDir other, FileNameMatcher matcher, Deque { HashedFile file = (HashedFile) entry; HashedFile otherFile = (HashedFile) otherEntry; if (mismatchList && shouldUpdate && !file.isSame(otherFile)) diff.map.put(name, entry); - break; - case DIR: + } + case DIR -> { HashedDir dir = (HashedDir) entry; HashedDir otherDir = (HashedDir) otherEntry; if (mismatchList || shouldUpdate) { // Maybe isn't need to go deeper? @@ -171,9 +166,8 @@ private HashedDir sideDiff(HashedDir other, FileNameMatcher matcher, Deque throw new AssertionError("Unsupported hashed entry type: " + type.name()); } // Remove this path entry @@ -209,13 +203,13 @@ public HashedDir sideCompare(HashedDir other, FileNameMatcher matcher, Deque { HashedFile file = (HashedFile) entry; HashedFile otherFile = (HashedFile) otherEntry; if (mismatchList && shouldUpdate && file.isSame(otherFile)) diff.map.put(name, entry); - break; - case DIR: + } + case DIR -> { HashedDir dir = (HashedDir) entry; HashedDir otherDir = (HashedDir) otherEntry; if (mismatchList || shouldUpdate) { // Maybe isn't need to go deeper? @@ -223,9 +217,8 @@ public HashedDir sideCompare(HashedDir other, FileNameMatcher matcher, Deque throw new AssertionError("Unsupported hashed entry type: " + type.name()); } // Remove this path entry diff --git a/LauncherCore/src/main/java/pro/gravit/launcher/serialize/HInput.java b/LauncherCore/src/main/java/pro/gravit/launcher/serialize/HInput.java index 8e456425..537a8098 100644 --- a/LauncherCore/src/main/java/pro/gravit/launcher/serialize/HInput.java +++ b/LauncherCore/src/main/java/pro/gravit/launcher/serialize/HInput.java @@ -42,14 +42,11 @@ public BigInteger readBigInteger(int maxBytes) throws IOException { public boolean readBoolean() throws IOException { int b = readUnsignedByte(); - switch (b) { - case 0b0: - return false; - case 0b1: - return true; - default: - throw new IOException("Invalid boolean state: " + b); - } + return switch (b) { + case 0b0 -> false; + case 0b1 -> true; + default -> throw new IOException("Invalid boolean state: " + b); + }; } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java index ccaeb8ea..9950f6dd 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/CommonHelper.java @@ -84,20 +84,19 @@ public static String[] parseCommand(CharSequence line) throws CommandException { // Append next char switch (ch) { - case '"': // "abc"de, "abc""de" also allowed + case '"' -> { // "abc"de, "abc""de" also allowed quoted = !quoted; wasQuoted = true; - break; - case '\\': // All escapes, including spaces etc + } + case '\\' -> { // All escapes, including spaces etc if (i + 1 >= line.length()) throw new CommandException("Escape character is not specified"); char next = line.charAt(i + 1); builder.append(next); i++; - break; - default: // Default char, simply append - builder.append(ch); - break; + } + default -> // Default char, simply append + builder.append(ch); } } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/FormatHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/FormatHelper.java index a0229df0..8b195770 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/FormatHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/FormatHelper.java @@ -14,17 +14,12 @@ public class FormatHelper { public static Ansi rawAnsiFormat(LogHelper.Level level, String dateTime, boolean sub) { Ansi.Color levelColor; boolean bright = level != LogHelper.Level.DEBUG; - switch (level) { - case WARNING: - levelColor = Ansi.Color.YELLOW; - break; - case ERROR: - levelColor = Ansi.Color.RED; - break; - default: // INFO, DEBUG, Unknown - levelColor = Ansi.Color.WHITE; - break; - } + levelColor = switch (level) { + case WARNING -> Ansi.Color.YELLOW; + case ERROR -> Ansi.Color.RED; + default -> // INFO, DEBUG, Unknown + Ansi.Color.WHITE; + }; // Date-time Ansi ansi = new Ansi(); diff --git a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java index 2b1812a6..62a960bb 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/helper/IOHelper.java @@ -139,12 +139,11 @@ public static String getIP(SocketAddress address) { public static Path getRoot() { switch (JVMHelper.OS_TYPE) { - case MUSTDIE: { + case MUSTDIE -> { String drive = System.getenv("SystemDrive").concat("\\"); return Paths.get(drive); } - case LINUX: - case MACOSX: { + case LINUX, MACOSX -> { return Paths.get("/"); } } diff --git a/LauncherCore/src/main/java/pro/gravit/utils/logging/Slf4jLogHelperImpl.java b/LauncherCore/src/main/java/pro/gravit/utils/logging/Slf4jLogHelperImpl.java index a172b2d3..93e49bf1 100644 --- a/LauncherCore/src/main/java/pro/gravit/utils/logging/Slf4jLogHelperImpl.java +++ b/LauncherCore/src/main/java/pro/gravit/utils/logging/Slf4jLogHelperImpl.java @@ -33,21 +33,11 @@ public Slf4jLogHelperImpl() { @Override public void log(LogHelper.Level level, String message, boolean sub) { switch (level) { - case DEV: - logger.trace(message); - break; - case DEBUG: - logger.debug(message); - break; - case INFO: - logger.info(message); - break; - case WARNING: - logger.warn(message); - break; - case ERROR: - logger.error(message); - break; + case DEV -> logger.trace(message); + case DEBUG -> logger.debug(message); + case INFO -> logger.info(message); + case WARNING -> logger.warn(message); + case ERROR -> logger.error(message); } } diff --git a/ServerWrapper/build.gradle b/ServerWrapper/build.gradle index ad576237..35aa158d 100644 --- a/ServerWrapper/build.gradle +++ b/ServerWrapper/build.gradle @@ -30,12 +30,12 @@ "Multi-Release": "true") } -task sourcesJar(type: Jar) { +tasks.register('sourcesJar') { from sourceSets.main.allJava archiveClassifier.set('sources') } -task javadocJar(type: Jar) { +tasks.register('javadocJar') { from javadoc archiveClassifier.set('javadoc') } diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index fa77103e..995e2003 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -167,18 +167,11 @@ public void run(String... args) throws Throwable { real_args = new String[args.length - 1]; System.arraycopy(args, 1, real_args, 0, args.length - 1); } else real_args = args; - Launch launch; - switch (config.classLoaderConfig) { - case LAUNCHER: - launch = new ClasspathLaunch(); - break; - case MODULE: - launch = new ModuleLaunch(); - break; - default: - launch = new SimpleLaunch(); - break; - } + Launch launch = switch (config.classLoaderConfig) { + case LAUNCHER -> new ClasspathLaunch(); + case MODULE -> new ModuleLaunch(); + default -> new SimpleLaunch(); + }; LogHelper.info("Start Minecraft Server"); LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName()); try { diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/authlib/InstallAuthlib.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/authlib/InstallAuthlib.java index c671b706..9ade3ffa 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/authlib/InstallAuthlib.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/authlib/InstallAuthlib.java @@ -41,10 +41,10 @@ public void run(String... args) throws Exception { } context.workdir = IOHelper.WORKING_DIR; LogHelper.info("Search .jar files in %s", context.workdir.toAbsolutePath()); - IOHelper.walk(context.workdir, new SimpleFileVisitor() { + IOHelper.walk(context.workdir, new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if(file.getFileName().toString().endsWith(".jar")) { + if (file.getFileName().toString().endsWith(".jar")) { context.files.add(file); } return FileVisitResult.CONTINUE; diff --git a/build.gradle b/build.gradle index 8b09b683..28acec72 100644 --- a/build.gradle +++ b/build.gradle @@ -43,10 +43,12 @@ } } - tasks.withType(JavaCompile) { - options.encoding = "UTF-8" - options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" - options.incremental = true // one flag, and things will get MUCH faster + tasks.withType(JavaCompile).tap { + configureEach { + options.encoding = "UTF-8" + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" + options.incremental = true // one flag, and things will get MUCH faster + } } }