diff --git a/gradle/javadoc/java8/package-list b/gradle/javadoc/java8/package-list index 351c186855..496d90dbfa 100644 --- a/gradle/javadoc/java8/package-list +++ b/gradle/javadoc/java8/package-list @@ -55,7 +55,6 @@ java.util.concurrent.atomic java.util.concurrent.locks java.util.function java.util.jar -java.util.logging java.util.prefs java.util.regex java.util.spi diff --git a/lib/build.gradle b/lib/build.gradle index 90d985ad69..b122cb42ee 100644 --- a/lib/build.gradle +++ b/lib/build.gradle @@ -21,6 +21,7 @@ for (glue in NEEDS_GLUE) { } dependencies { + compileOnly 'org.slf4j:slf4j-api:1.7.35' // zero runtime reqs is a hard requirements for spotless-lib // if you need a dep, put it in lib-extra testImplementation "org.junit.jupiter:junit-jupiter:$VER_JUNIT" @@ -29,6 +30,7 @@ dependencies { // used for pom sorting sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:3.0.0' + sortPomCompileOnly 'org.slf4j:slf4j-api:1.7.35' palantirJavaFormatCompileOnly 'com.palantir.javaformat:palantir-java-format:1.1.0' diff --git a/lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java b/lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java index 8aa7510dc3..061224a819 100644 --- a/lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java +++ b/lib/src/ktlint/java/com/diffplug/spotless/glue/ktlint/KtlintFormatterFunc.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 DiffPlug + * Copyright 2021-2022 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/src/main/java/com/diffplug/spotless/FormatExceptionPolicyLegacy.java b/lib/src/main/java/com/diffplug/spotless/FormatExceptionPolicyLegacy.java index df95542a44..14f36da94e 100644 --- a/lib/src/main/java/com/diffplug/spotless/FormatExceptionPolicyLegacy.java +++ b/lib/src/main/java/com/diffplug/spotless/FormatExceptionPolicyLegacy.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 DiffPlug + * Copyright 2016-2022 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,13 @@ */ package com.diffplug.spotless; -import java.util.logging.Level; -import java.util.logging.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; class FormatExceptionPolicyLegacy extends NoLambda.EqualityBasedOnSerialization implements FormatExceptionPolicy { private static final long serialVersionUID = 1L; - private static final Logger logger = Logger.getLogger(Formatter.class.getName()); + private static final Logger logger = LoggerFactory.getLogger(Formatter.class.getName()); @Override public void handleError(Throwable e, FormatterStep step, String relativePath) { @@ -34,10 +34,10 @@ public void handleError(Throwable e, FormatterStep step, String relativePath) { } static void error(Throwable e, FormatterStep step, String relativePath) { - logger.log(Level.SEVERE, "Step '" + step.getName() + "' found problem in '" + relativePath + "':\n" + e.getMessage(), e); + logger.error("Step '" + step.getName() + "' found problem in '" + relativePath + "':\n" + e.getMessage(), e); } static void warning(Throwable e, FormatterStep step, String relativePath) { - logger.log(Level.WARNING, "Unable to apply step '" + step.getName() + "' to '" + relativePath + "'", e); + logger.warn("Unable to apply step '" + step.getName() + "' to '" + relativePath + "'", e); } } diff --git a/lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java b/lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java index 2190af88e7..d972dd9480 100644 --- a/lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java +++ b/lib/src/main/java/com/diffplug/spotless/markdown/FreshMarkStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 DiffPlug + * Copyright 2016-2022 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,9 @@ import java.util.Objects; import java.util.TreeMap; import java.util.function.Consumer; -import java.util.logging.Logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.diffplug.spotless.FormatterFunc; import com.diffplug.spotless.FormatterStep; @@ -78,8 +80,8 @@ private static class State implements Serializable { } FormatterFunc createFormat() throws Exception { - Logger logger = Logger.getLogger(FreshMarkStep.class.getName()); - Consumer loggingStream = logger::warning; + Logger logger = LoggerFactory.getLogger(FreshMarkStep.class.getName()); + Consumer loggingStream = logger::warn; ClassLoader classLoader = jarState.getClassLoader(); diff --git a/lib/src/main/java/com/diffplug/spotless/npm/NpmFormatterStepStateBase.java b/lib/src/main/java/com/diffplug/spotless/npm/NpmFormatterStepStateBase.java index 48bec00c8f..d8127d10d2 100644 --- a/lib/src/main/java/com/diffplug/spotless/npm/NpmFormatterStepStateBase.java +++ b/lib/src/main/java/com/diffplug/spotless/npm/NpmFormatterStepStateBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 DiffPlug + * Copyright 2016-2022 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,9 @@ import java.util.Map.Entry; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.logging.Logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.diffplug.spotless.FileSignature; import com.diffplug.spotless.FormatterFunc; @@ -36,7 +38,7 @@ abstract class NpmFormatterStepStateBase implements Serializable { - private static final Logger logger = Logger.getLogger(NpmFormatterStepStateBase.class.getName()); + private static final Logger logger = LoggerFactory.getLogger(NpmFormatterStepStateBase.class.getName()); private static final long serialVersionUID = 1460749955865959948L; @@ -166,13 +168,13 @@ public String getBaseUrl() { @Override public void close() throws Exception { try { - logger.fine("Closing npm server in directory <" + serverPortFile.getParent() + "> and port <" + serverPort + ">"); + logger.trace("Closing npm server in directory <" + serverPortFile.getParent() + "> and port <" + serverPort + ">"); if (server.isAlive()) { boolean ended = server.waitFor(5, TimeUnit.SECONDS); if (!ended) { logger.info("Force-Closing npm server in directory <" + serverPortFile.getParent() + "> and port <" + serverPort + ">"); server.destroyForcibly().waitFor(); - logger.fine("Force-Closing npm server in directory <" + serverPortFile.getParent() + "> and port <" + serverPort + "> -- Finished"); + logger.trace("Force-Closing npm server in directory <" + serverPortFile.getParent() + "> and port <" + serverPort + "> -- Finished"); } } } finally { diff --git a/lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java b/lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java index 0cd0f5f558..a5183d2e9c 100644 --- a/lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java +++ b/lib/src/main/java/com/diffplug/spotless/npm/PrettierFormatterStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 DiffPlug + * Copyright 2016-2022 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,12 @@ import java.util.Collections; import java.util.Map; import java.util.TreeMap; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.annotation.Nonnull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.diffplug.spotless.FormatterFunc; import com.diffplug.spotless.FormatterFunc.Closeable; import com.diffplug.spotless.FormatterStep; @@ -36,7 +37,7 @@ public class PrettierFormatterStep { - private static final Logger logger = Logger.getLogger(PrettierFormatterStep.class.getName()); + private static final Logger logger = LoggerFactory.getLogger(PrettierFormatterStep.class.getName()); public static final String NAME = "prettier-format"; @@ -95,7 +96,7 @@ private void endServer(PrettierRestService restService, ServerProcessInfo restSe try { restService.shutdown(); } catch (Throwable t) { - logger.log(Level.INFO, "Failed to request shutdown of rest service via api. Trying via process.", t); + logger.info("Failed to request shutdown of rest service via api. Trying via process.", t); } restServer.close(); } diff --git a/lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java b/lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java index a87bc0ebae..045c8a0df3 100644 --- a/lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java +++ b/lib/src/main/java/com/diffplug/spotless/npm/TsFmtFormatterStep.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 DiffPlug + * Copyright 2016-2022 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +21,13 @@ import java.io.IOException; import java.io.Serializable; import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import com.diffplug.spotless.FormatterFunc; import com.diffplug.spotless.FormatterFunc.Closeable; import com.diffplug.spotless.FormatterStep; @@ -35,7 +36,7 @@ public class TsFmtFormatterStep { - private static final Logger logger = Logger.getLogger(TsFmtFormatterStep.class.getName()); + private static final Logger logger = LoggerFactory.getLogger(TsFmtFormatterStep.class.getName()); public static final String NAME = "tsfmt-format"; @@ -115,7 +116,7 @@ private void endServer(TsFmtRestService restService, ServerProcessInfo restServe try { restService.shutdown(); } catch (Throwable t) { - logger.log(Level.INFO, "Failed to request shutdown of rest service via api. Trying via process.", t); + logger.info("Failed to request shutdown of rest service via api. Trying via process.", t); } restServer.close(); } diff --git a/lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java b/lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java index 4a72c48fa9..909e04e589 100644 --- a/lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java +++ b/lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 DiffPlug + * Copyright 2021-2022 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,10 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; -import java.util.logging.Logger; import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.diffplug.spotless.FormatterFunc; import com.diffplug.spotless.pom.SortPomCfg; @@ -30,7 +31,7 @@ import sortpom.parameter.PluginParameters; public class SortPomFormatterFunc implements FormatterFunc { - private static final Logger logger = Logger.getLogger(SortPomFormatterFunc.class.getName()); + private static final Logger logger = LoggerFactory.getLogger(SortPomFormatterFunc.class.getName()); private final SortPomCfg cfg; public SortPomFormatterFunc(SortPomCfg cfg) { @@ -61,7 +62,7 @@ public String apply(String input) throws Exception { private static class MySortPomLogger implements SortPomLogger { @Override public void warn(String content) { - logger.warning(content); + logger.warn(content); } @Override @@ -71,7 +72,7 @@ public void info(String content) { @Override public void error(String content) { - logger.severe(content); + logger.error(content); } } } diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java index 240ffcdcdf..7c005cd471 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/GradleProvisioner.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 DiffPlug + * Copyright 2016-2022 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; import org.gradle.api.GradleException; import org.gradle.api.Project; @@ -30,6 +28,8 @@ import org.gradle.api.artifacts.dsl.DependencyHandler; import org.gradle.api.attributes.Bundling; import org.gradle.api.initialization.dsl.ScriptHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.diffplug.common.base.Unhandled; import com.diffplug.common.collect.ImmutableList; @@ -127,8 +127,7 @@ private static Provisioner forConfigurationContainer(Project project, Configurat if (!projName.isEmpty()) { projName = projName + "/"; } - logger.log( - Level.SEVERE, + logger.error( "You need to add a repository containing the '" + mavenCoords + "' artifact in '" + projName + "build.gradle'.\n" + "E.g.: 'repositories { mavenCentral() }'", e); @@ -137,7 +136,7 @@ private static Provisioner forConfigurationContainer(Project project, Configurat }; } - private static final Logger logger = Logger.getLogger(GradleProvisioner.class.getName()); + private static final Logger logger = LoggerFactory.getLogger(GradleProvisioner.class.getName()); /** Models a request to the provisioner. */ private static class Request {