Skip to content

Commit

Permalink
Merge branch 'main' into feat/gson-support
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Feb 15, 2022
2 parents 0da1a1a + 7331070 commit 2b249b4
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 42 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Expand Up @@ -13,6 +13,10 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
### Added
* Added support for JSON formatting based on [Gson](https://github.com/google/gson) ([#1125](https://github.com/diffplug/spotless/pull/1125)).

### Changed

* Use SLF4J for logging ([#1116](https://github.com/diffplug/spotless/issues/1116))

## [2.22.2] - 2022-02-09
### Changed
* Bump default ktfmt `0.30` -> `0.31` ([#1118](https://github.com/diffplug/spotless/pull/1118)).
Expand Down
1 change: 0 additions & 1 deletion gradle/javadoc/java8/package-list
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/build.gradle
Expand Up @@ -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"
Expand All @@ -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'

Expand Down
@@ -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.
Expand All @@ -19,7 +19,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import com.pinterest.ktlint.core.KtLint;
import com.pinterest.ktlint.core.KtLint.Params;
Expand All @@ -33,7 +32,6 @@
import kotlin.jvm.functions.Function2;

public class KtlintFormatterFunc implements FormatterFunc.NeedsFile {
private static final Logger logger = Logger.getLogger(KtlintFormatterFunc.class.getName());

private final List<RuleSet> rulesets;
private final Map<String, String> userData;
Expand Down
@@ -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.
Expand All @@ -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);

@Override
public void handleError(Throwable e, FormatterStep step, String relativePath) {
Expand All @@ -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 '{}' found problem in '{}':\n{}", step.getName(), relativePath, 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 '{}' to '{}'", step.getName(), relativePath, e);
}
}
@@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -78,8 +80,8 @@ private static class State implements Serializable {
}

FormatterFunc createFormat() throws Exception {
Logger logger = Logger.getLogger(FreshMarkStep.class.getName());
Consumer<String> loggingStream = logger::warning;
Logger logger = LoggerFactory.getLogger(FreshMarkStep.class);
Consumer<String> loggingStream = logger::warn;

ClassLoader classLoader = jarState.getClassLoader();

Expand Down
@@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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);

private static final long serialVersionUID = 1460749955865959948L;

Expand Down Expand Up @@ -166,13 +168,15 @@ 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 <{}> and port <{}>",
serverPortFile.getParent(), 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 + ">");
logger.info("Force-Closing npm server in directory <{}> and port <{}>", serverPortFile.getParent(), 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 <{}> and port <{}> -- Finished", serverPortFile.getParent(), serverPort);
}
}
} finally {
Expand Down
@@ -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.
Expand All @@ -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;
Expand All @@ -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);

public static final String NAME = "prettier-format";

Expand Down Expand Up @@ -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();
}
Expand Down
@@ -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.
Expand All @@ -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;
Expand All @@ -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);

public static final String NAME = "tsfmt-format";

Expand Down Expand Up @@ -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();
}
Expand Down
@@ -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.
Expand All @@ -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;
Expand All @@ -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);
private final SortPomCfg cfg;

public SortPomFormatterFunc(SortPomCfg cfg) {
Expand Down Expand Up @@ -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
Expand All @@ -71,7 +72,7 @@ public void info(String content) {

@Override
public void error(String content) {
logger.severe(content);
logger.error(content);
}
}
}
4 changes: 4 additions & 0 deletions plugin-gradle/CHANGES.md
Expand Up @@ -6,6 +6,10 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
### Added
* Added support for JSON formatting based on [Gson](https://github.com/google/gson) ([#1125](https://github.com/diffplug/spotless/pull/1125)).

### Changed

* Use SLF4J for logging ([#1116](https://github.com/diffplug/spotless/issues/1116))

## [6.2.2] - 2022-02-09
### Changed
* Bump default ktfmt `0.30` -> `0.31` ([#1118](https://github.com/diffplug/spotless/pull/1118)).
Expand Down
@@ -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.
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -127,17 +127,17 @@ private static Provisioner forConfigurationContainer(Project project, Configurat
if (!projName.isEmpty()) {
projName = projName + "/";
}
logger.log(
Level.SEVERE,
"You need to add a repository containing the '" + mavenCoords + "' artifact in '" + projName + "build.gradle'.\n" +
logger.error(
"You need to add a repository containing the '{}' artifact in '{}build.gradle'.\n" +
"E.g.: 'repositories { mavenCentral() }'",
mavenCoords, projName,
e);
throw e;
}
};
}

private static final Logger logger = Logger.getLogger(GradleProvisioner.class.getName());
private static final Logger logger = LoggerFactory.getLogger(GradleProvisioner.class);

/** Models a request to the provisioner. */
private static class Request {
Expand Down
4 changes: 4 additions & 0 deletions plugin-maven/CHANGES.md
Expand Up @@ -4,6 +4,10 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (

## [Unreleased]

### Changed

* Use SLF4J for logging ([#1116](https://github.com/diffplug/spotless/issues/1116))

## [2.20.2] - 2022-02-09
### Changed
* Bump default ktfmt `0.30` -> `0.31` ([#1118](https://github.com/diffplug/spotless/pull/1118)).
Expand Down

0 comments on commit 2b249b4

Please sign in to comment.