Skip to content

Commit 8dd9b34

Browse files
authored
Merge branch 'main' into js-ts-rome
2 parents b516c65 + f631f09 commit 8dd9b34

File tree

14 files changed

+75
-30
lines changed

14 files changed

+75
-30
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1313
### Added
1414
* `Jvm.Support` now accepts `-SNAPSHOT` versions, treated as the non`-SNAPSHOT`. ([#1583](https://github.com/diffplug/spotless/issues/1583))
1515
* Support Rome as a formatter for JavaScript and TypeScript code. Adds a new `rome` step to `javascript` and `typescript` formatter configurations. https://github.com/diffplug/spotless/pull/1663
16+
### Fixed
17+
* When P2 download fails, indicate the responsible formatter. ([#1698](https://github.com/diffplug/spotless/issues/1698))
18+
### Changes
19+
* Bump default sortpom version to latest `3.0.0` -> `3.2.1`. ([#1675](https://github.com/diffplug/spotless/pull/1675))
1620

1721
## [2.38.0] - 2023-04-06
1822
### Added

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ VER_DURIAN=1.2.0
3232
VER_JGIT=6.5.0.202303070854-r
3333
VER_JUNIT=5.9.2
3434
VER_ASSERTJ=3.24.2
35-
VER_MOCKITO=5.3.0
35+
VER_MOCKITO=5.3.1

lib-extra/src/main/java/com/diffplug/spotless/extra/EquoBasedStepBuilder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.diffplug.spotless.extra;
1717

1818
import java.io.File;
19+
import java.io.IOException;
1920
import java.io.Serializable;
2021
import java.util.ArrayList;
2122
import java.util.List;
@@ -36,6 +37,7 @@
3637
import dev.equo.solstice.p2.P2ClientCache;
3738
import dev.equo.solstice.p2.P2Model;
3839
import dev.equo.solstice.p2.P2QueryCache;
40+
import dev.equo.solstice.p2.P2QueryResult;
3941

4042
/**
4143
* Generic Eclipse based formatter step {@link State} builder.
@@ -100,7 +102,12 @@ protected void addPlatformRepo(P2Model model, String version) {
100102

101103
/** Creates the state of the configuration. */
102104
EquoBasedStepBuilder.State get() throws Exception {
103-
var query = createModelWithMirrors().query(P2ClientCache.PREFER_OFFLINE, P2QueryCache.ALLOW);
105+
P2QueryResult query;
106+
try {
107+
query = createModelWithMirrors().query(P2ClientCache.PREFER_OFFLINE, P2QueryCache.ALLOW);
108+
} catch (Exception x) {
109+
throw new IOException("Failed to load " + formatterName + ": " + x, x);
110+
}
104111
var classpath = new ArrayList<File>();
105112
var mavenDeps = new ArrayList<String>();
106113
mavenDeps.add("dev.equo.ide:solstice:1.0.3");

lib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ dependencies {
115115
// scalafmt
116116
scalafmtCompileOnly "org.scalameta:scalafmt-core_2.13:3.7.3"
117117
// sortPom
118-
sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:3.0.0'
118+
sortPomCompileOnly 'com.github.ekryd.sortpom:sortpom-sorter:3.2.1'
119119
sortPomCompileOnly 'org.slf4j:slf4j-api:2.0.0'
120120
}
121121

lib/src/main/java/com/diffplug/spotless/pom/SortPomCfg.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2021-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,8 @@
2121
public class SortPomCfg implements Serializable {
2222
private static final long serialVersionUID = 1L;
2323

24+
public String version = "3.2.1";
25+
2426
public String encoding = "UTF-8";
2527

2628
public String lineSeparator = System.getProperty("line.separator");
@@ -43,6 +45,8 @@ public class SortPomCfg implements Serializable {
4345

4446
public String sortDependencies = null;
4547

48+
public String sortDependencyManagement = null;
49+
4650
public String sortDependencyExclusions = null;
4751

4852
public String sortPlugins = null;

lib/src/main/java/com/diffplug/spotless/pom/SortPomStep.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2021-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@
2727

2828
public class SortPomStep {
2929
public static final String NAME = "sortPom";
30+
static final String PACKAGE = "com.github.ekryd.sortpom";
31+
static final String MAVEN_COORDINATE = PACKAGE + ":sortpom-sorter:";
3032

3133
private SortPomStep() {}
3234

@@ -42,7 +44,7 @@ static class State implements Serializable {
4244

4345
public State(SortPomCfg cfg, Provisioner provisioner) throws IOException {
4446
this.cfg = cfg;
45-
this.jarState = JarState.from("com.github.ekryd.sortpom:sortpom-sorter:3.0.0", provisioner);
47+
this.jarState = JarState.from(MAVEN_COORDINATE + cfg.version, provisioner);
4648
}
4749

4850
FormatterFunc createFormat() throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {

lib/src/sortPom/java/com/diffplug/spotless/glue/pom/SortPomFormatterFunc.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2022 DiffPlug
2+
* Copyright 2021-2023 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
1515
*/
1616
package com.diffplug.spotless.glue.pom;
1717

18-
import java.io.File;
19-
import java.io.FileInputStream;
20-
import java.io.FileOutputStream;
18+
import java.io.*;
19+
import java.nio.charset.Charset;
20+
import java.nio.file.Files;
2121

22-
import org.apache.commons.io.IOUtils;
2322
import org.slf4j.Logger;
2423
import org.slf4j.LoggerFactory;
2524

@@ -40,10 +39,12 @@ public SortPomFormatterFunc(SortPomCfg cfg) {
4039

4140
@Override
4241
public String apply(String input) throws Exception {
43-
// SortPom expects a file to sort, so we write the inpout into a temporary file
42+
// SortPom expects a file to sort, so we write the input into a temporary file
4443
File pom = File.createTempFile("pom", ".xml");
4544
pom.deleteOnExit();
46-
IOUtils.write(input, new FileOutputStream(pom), cfg.encoding);
45+
try (BufferedWriter writer = new BufferedWriter(new FileWriter(pom, Charset.forName(cfg.encoding)))) {
46+
writer.write(input);
47+
}
4748
SortPomImpl sortPom = new SortPomImpl();
4849
sortPom.setup(new MySortPomLogger(), PluginParameters.builder()
4950
.setPomFile(pom)
@@ -52,11 +53,12 @@ public String apply(String input) throws Exception {
5253
.setFormatting(cfg.lineSeparator, cfg.expandEmptyElements, cfg.spaceBeforeCloseEmptyElement, cfg.keepBlankLines)
5354
.setIndent(cfg.nrOfIndentSpace, cfg.indentBlankLines, cfg.indentSchemaLocation)
5455
.setSortOrder(cfg.sortOrderFile, cfg.predefinedSortOrder)
55-
.setSortEntities(cfg.sortDependencies, cfg.sortDependencyExclusions, cfg.sortPlugins, cfg.sortProperties, cfg.sortModules, cfg.sortExecutions)
56-
.setTriggers(false)
56+
.setSortEntities(cfg.sortDependencies, cfg.sortDependencyExclusions, cfg.sortDependencyManagement,
57+
cfg.sortPlugins, cfg.sortProperties, cfg.sortModules, cfg.sortExecutions)
58+
.setIgnoreLineSeparators(false)
5759
.build());
5860
sortPom.sortPom();
59-
return IOUtils.toString(new FileInputStream(pom), cfg.encoding);
61+
return Files.readString(pom.toPath(), Charset.forName(cfg.encoding));
6062
}
6163

6264
private static class MySortPomLogger implements SortPomLogger {

plugin-gradle/CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
88

99
### Fixed
1010
* Added `@DisableCachingByDefault` to `RegisterDependenciesTask`.
11+
* When P2 download fails, indicate the responsible formatter. ([#1698](https://github.com/diffplug/spotless/issues/1698))
12+
### Changes
13+
* Bump default sortpom version to latest `3.0.0` -> `3.2.1`. ([#1675](https://github.com/diffplug/spotless/pull/1675))
1114

1215
## [6.18.0] - 2023-04-06
1316
### Added

plugin-gradle/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@ All the generic steps live in [`FormatExtension`](https://javadoc.io/doc/com.dif
133133

134134
### Requirements
135135

136-
Spotless requires JRE 8+, and Gradle 6.1.1+. Some steps require JRE 11+, `Unsupported major.minor version` means you're using a step that needs a newer JRE.
136+
Spotless requires JRE 11+ and Gradle 6.1.1 or newer.
137137

138-
If you're stuck on an older version of Gradle, `id 'com.diffplug.gradle.spotless' version '4.5.1'` supports all the way back to Gradle 2.x.
138+
- If you're stuck on JRE 8, use [`id 'com.diffplug.spotless' version '6.13.0'` or older](https://github.com/diffplug/spotless/blob/main/plugin-gradle/CHANGES.md#6130---2023-01-14).
139+
- If you're stuck on an older version of Gradle, [`id 'com.diffplug.gradle.spotless' version '4.5.1'` supports all the way back to Gradle 2.x](https://github.com/diffplug/spotless/blob/main/plugin-gradle/CHANGES.md#451---2020-07-04).
139140

140141
<a name="applying-to-java-source"></a>
141142

plugin-maven/CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
55
## [Unreleased]
66
### Added
77
* Support Rome as a formatter for JavaScript and TypeScript code. Adds a new `rome` step to `javascript` and `typescript` formatter configurations. https://github.com/diffplug/spotless/pull/1663### Fixed
8+
### Fixed
9+
* `palantir` step now accepts a `style` parameter, which is documentation had already claimed to do. ([#1694](https://github.com/diffplug/spotless/pull/1694))
10+
* When P2 download fails, indicate the responsible formatter. ([#1698](https://github.com/diffplug/spotless/issues/1698))
11+
### Changes
12+
* Bump default sortpom version to latest `3.0.0` -> `3.2.1`. ([#1675](https://github.com/diffplug/spotless/pull/1675))
813

914
## [2.36.0] - 2023-04-06
1015
### Added

0 commit comments

Comments
 (0)