Skip to content

Commit 528e708

Browse files
authored
Merge branch 'master' into master
2 parents 588aa43 + 64849c8 commit 528e708

File tree

18 files changed

+134
-35
lines changed

18 files changed

+134
-35
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
1212
## [Unreleased]
1313
### Added
1414
* Tsfmt Maven Plugin ([#548](https://github.com/diffplug/spotless/pull/548))
15+
### Fixed
16+
* Javadoc for the `ext/eclipse-*` projects.
17+
* Replace the deprecated `compile` with `implementation` for the `ext/eclipse-*` projects.
1518

1619
## [1.28.0] - 2020-03-20
1720
### Added

_ext/eclipse-base/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ ext {
88
}
99

1010
dependencies {
11-
compile("org.eclipse.platform:org.eclipse.core.resources:${VER_ECLIPSE_CORE_RESOURCES}") {
11+
implementation("org.eclipse.platform:org.eclipse.core.resources:${VER_ECLIPSE_CORE_RESOURCES}") {
1212
exclude group: 'org.eclipse.platform', module: 'org.eclipse.ant.core'
1313
exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.expressions'
1414
exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.filesystem'
1515
}
16-
compile("org.slf4j:slf4j-api:${VER_SLF4J}")
16+
implementation("org.slf4j:slf4j-api:${VER_SLF4J}")
1717

1818
testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}")
1919
}

_ext/eclipse-cdt/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ apply from: rootProject.file('gradle/java-publish.gradle')
1717

1818

1919
dependencies {
20-
compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
20+
implementation "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
2121
// Provides text partitioners for formatters
22-
compile ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
22+
implementation ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
2323
exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt'
2424
}
2525
// Required to by CCorePlugin calling CDTLogWriter
26-
compile "com.ibm.icu:icu4j:${VER_IBM_ICU}"
26+
implementation "com.ibm.icu:icu4j:${VER_IBM_ICU}"
2727
// Required to by CCorePlugin calling PositionTrackerManager
28-
compile "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLISPE_PLATFORM}"
28+
implementation "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLISPE_PLATFORM}"
2929

3030
testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}")
3131
}

_ext/eclipse-groovy/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ext {
44
]
55

66
p2Repository = "https://dist.springsource.org/release/GRECLIPSE/${VER_GRECLIPSE}/e${VER_ECLIPSE}"
7-
7+
88
p2Dependencies = [
99
'org.codehaus.groovy.eclipse.refactoring':'+', // GroovyFormatter and related
1010

@@ -38,9 +38,9 @@ apply from: rootProject.file('_ext/gradle/p2-fat-jar-setup.gradle')
3838
apply from: rootProject.file('gradle/java-publish.gradle')
3939

4040
dependencies {
41-
compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
41+
implementation "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
4242
// Provides text partitioners for formatters
43-
compile ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
43+
implementation ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
4444
exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt'
4545
}
4646
testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}")

_ext/eclipse-jdt/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ ext {
1010
}
1111

1212
dependencies {
13-
compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
14-
compile("org.eclipse.jdt:org.eclipse.jdt.core:${VER_ECLIPSE_JDT_CORE}") {
13+
implementation "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
14+
implementation("org.eclipse.jdt:org.eclipse.jdt.core:${VER_ECLIPSE_JDT_CORE}") {
1515
exclude group: 'org.eclipse.platform', module: 'org.eclipse.ant.core'
1616
exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.expressions'
1717
exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.filesystem'

_ext/eclipse-wtp/CHANGES.md

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

55
## [Unreleased]
66

7+
## [3.15.3] - 2020-03-26
8+
### Fixed
9+
* Handling of character encodings on OS with non-unicode default file encoding format. CSS, HTML and JSON formatter steps encoded intermediately the input using the default file encoding, which was not lossless if the default file encoding did not support the full unicode character set. ([#545](https://github.com/diffplug/spotless/issues/545)).
10+
711
## [3.15.2] - 2020-03-04
812
### Fixed
913
* Racing conditions in WTP formatter configurations. Multiple configurations within the same project are no longer supported. ([#492](https://github.com/diffplug/spotless/pull/492)).

_ext/eclipse-wtp/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ext {
44
]
55

66
p2Repository = "https://download.eclipse.org/webtools/repository/${VER_ECLIPSE_WTP}"
7-
7+
88
p2Dependencies = [
99
// XML/HTML Formatter - Dependencies
1010
'org.eclipse.wst.xml.core':'+', // DefaultXMLPartitionFormatter and XMLAssociationProvider
@@ -60,24 +60,24 @@ apply from: rootProject.file('_ext/gradle/p2-fat-jar-setup.gradle')
6060
apply from: rootProject.file('gradle/java-publish.gradle')
6161

6262
dependencies {
63-
compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
63+
implementation "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}"
6464
// Required by most WPT formatters
65-
compile "com.ibm.icu:icu4j:${VER_IBM_ICU}"
65+
implementation "com.ibm.icu:icu4j:${VER_IBM_ICU}"
6666
// The XSD/DTD and other models are defined with EMF.
67-
compile "org.eclipse.emf:org.eclipse.emf.common:${VER_ECLISPE_EMF}"
68-
compile "org.eclipse.emf:org.eclipse.emf.ecore:${VER_ECLISPE_EMF}"
67+
implementation "org.eclipse.emf:org.eclipse.emf.common:${VER_ECLISPE_EMF}"
68+
implementation "org.eclipse.emf:org.eclipse.emf.ecore:${VER_ECLISPE_EMF}"
6969
// Some WPT plugins requires OSGI bundle interfaces (but not effectively used)
70-
compile "org.eclipse.platform:org.eclipse.osgi.services:${VER_ECLIPSE_OSGI_SERVICES}"
70+
implementation "org.eclipse.platform:org.eclipse.osgi.services:${VER_ECLIPSE_OSGI_SERVICES}"
7171
// Provides document data structure and file buffers for formatters
72-
compile "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLIPSE_FILE_BUFFERS}"
72+
implementation "org.eclipse.platform:org.eclipse.core.filebuffers:${VER_ECLIPSE_FILE_BUFFERS}"
7373
// Provides text partitioners for formatters
74-
compile ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
74+
implementation ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") {
7575
exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt'
7676
}
7777
// Some WPT plugins use the EFS for storing temporary worspace data
78-
compile "org.eclipse.platform:org.eclipse.core.filesystem:${VER_ECLISPE_EFS}"
78+
implementation "org.eclipse.platform:org.eclipse.core.filesystem:${VER_ECLISPE_EFS}"
7979
// Required by org.eclipse.wst.xsd.core
80-
compile "org.eclipse.xsd:org.eclipse.xsd:${VER_ECLISPE_XSD}"
80+
implementation "org.eclipse.xsd:org.eclipse.xsd:${VER_ECLISPE_XSD}"
8181

8282
testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}")
8383
}

_ext/eclipse-wtp/src/main/java/com/diffplug/spotless/extra/eclipse/wtp/sse/ContentTypeManager.java

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,34 @@
3636
import com.diffplug.spotless.extra.eclipse.base.service.NoContentTypeSpecificHandling;
3737

3838
/**
39-
* For some embedded formatters, the WTP uses the content type ID for
40-
* preferences lookup.
39+
40+
* WTP ModelHandlerRegistry uses the content type mamanger clean-up formatters
41+
* to provide association of content to content type related functionality.
4142
* <p>
42-
* The preference lookup is accomplished via the Eclipse preference service,
43-
* which must be provided in combination with this service.
44-
* For cleanup tasks, the ID mapping is also used by the model handler
45-
* to determine the model which a string stream requires.
43+
* Preference lookup per content type is accomplished via the
44+
* Eclipse PreferencesService, which must be provided in combination with
45+
* this service.
4646
* </p>
47+
* The input byte steam encoding detection is accomplished by the
48+
* content type manager. Normally the encoding is bount do a document/file.
49+
* Spotless applies the formatting on strings already decoded.
50+
* The WTP AbstractStructuredCleanupProcessor provides for non-documents
51+
* a clean-up function converting the decoded string into an UTF-8 encoded byte stream.
52+
* WTP AbstractDocumentLoader uses content type mamanger to determine the encoding
53+
* of the input stream.
54+
* Only the steps are affected that are using the
55+
* AbstractStructuredCleanupProcessor. All other steps creating an empty document
56+
* (e.g. via WTP AbstractDocumentLoader) and setting the textual content of the new document.
57+
*
58+
* @see org.eclipse.core.internal.preferences.PreferencesService
59+
* @see org.eclipse.wst.sse.core.internal.cleanup.AbstractStructuredCleanupProcessor
60+
* @see org.eclipse.wst.sse.core.internal.document.AbstractDocumentLoader
4761
* @see org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry
4862
*/
4963
class ContentTypeManager extends NoContentTypeSpecificHandling {
5064
private final Map<String, IContentType> id2Object;
5165
private final IContentType processorStepType;
66+
private final IContentDescription processorStepDescription;
5267

5368
/**
5469
* Content type manager as required for cleanup steps.
@@ -66,6 +81,7 @@ class ContentTypeManager extends NoContentTypeSpecificHandling {
6681
if (null == processorStepType) {
6782
throw new IllegalArgumentException("The manager does not support content type " + formatterContentTypeID);
6883
}
84+
processorStepDescription = new StringDescription(processorStepType);
6985
}
7086

7187
@Override
@@ -83,8 +99,48 @@ public IContentType findContentTypeFor(InputStream contents, String fileName) th
8399
return processorStepType;
84100
}
85101

102+
@Override
103+
public IContentDescription getDescriptionFor(InputStream contents, String fileName, QualifiedName[] options) throws IOException {
104+
return processorStepDescription;
105+
}
106+
107+
private static class StringDescription implements IContentDescription {
108+
109+
private final IContentType type;
110+
111+
public StringDescription(IContentType type) {
112+
this.type = type;
113+
}
114+
115+
@Override
116+
public boolean isRequested(QualifiedName key) {
117+
return false; //Don't use set Property
118+
}
119+
120+
@Override
121+
public String getCharset() {
122+
//Called by AbstractDocumentLoader.readInputStream
123+
return "UTF-8"; //UTF-8 encoded by AbstractStructuredCleanupProcessor.cleanupContent
124+
}
125+
126+
@Override
127+
public IContentType getContentType() {
128+
return type;
129+
}
130+
131+
@Override
132+
public Object getProperty(QualifiedName key) {
133+
return null; //Assume that the property map is empty
134+
}
135+
136+
@Override
137+
public void setProperty(QualifiedName key, Object value) {
138+
throw new IllegalArgumentException("Content description key cannot be set: " + key);
139+
}
140+
}
141+
86142
/**
87-
* The WTP uses the manager only for ID mapping, so most of the methods are not used.
143+
* The WTP uses the manager mainly for ID mapping, so most of the methods are not used.
88144
* Actually it has a hand stitched way for transforming the content type ID
89145
* {@code org.eclipse.wst...source} to the plugin ID {@code org.eclipse.wst...core}.
90146
* @see org.eclipse.wst.sse.core.internal.encoding.ContentBasedPreferenceGateway

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseHtmlFormatterStepImplTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,26 @@ public void formatCSS() throws Exception {
8989
testData.expected("css.html"), output);
9090
}
9191

92+
@Test
93+
public void checkCleanupForNonUtf8() throws Exception {
94+
String osEncoding = System.getProperty("file.encoding");
95+
System.setProperty("file.encoding", "ISO-8859-1"); //Simulate a non UTF-8 OS
96+
String[] input = testData.input("utf-8.html");
97+
String output = formatter.format(input[0]);
98+
System.setProperty("file.encoding", osEncoding);
99+
assertEquals("Unexpected formatting of UTF-8", testData.expected("utf-8.html"), output);
100+
}
101+
102+
@Test
103+
public void checkBOMisStripped() throws Exception {
104+
String[] input = testData.input("bom.html");
105+
String[] inputWithoutBom = testData.input("utf-8.html");
106+
//The UTF-8 BOM is interpreted as on UTF-16 character.
107+
assertEquals("BOM input invalid", input[0].length() - 1, inputWithoutBom[0].length());
108+
String output = formatter.format(input[0]);
109+
assertEquals("BOM is not stripped", testData.expected("utf-8.html"), output);
110+
}
111+
92112
@Test(expected = IllegalArgumentException.class)
93113
public void configurationChange() throws Exception {
94114
new EclipseHtmlFormatterStepImpl(new Properties());
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE html>
2+
<HTML>
3+
<HEAD>
4+
<META charset="UTF-8">
5+
<TITLE>ÄÜ€</TITLE>
6+
</HEAD>
7+
</HTML>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!DOCTYPE html>
2+
<html><head><meta charset="UTF-8"><title>ÄÜ€</title></head></html>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!DOCTYPE html>
2+
<html><head><meta charset="UTF-8"><title>ÄÜ€</title></head></html>

_ext/gradle/p2-fat-jar-setup.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ dependencies {
7373
embeddedJars "p2:${groupArtifact}:${version}"
7474
}
7575
// Includes the classes from P2 JARs during compilation
76-
compile files(embeddedClassesDir)
76+
implementation files(embeddedClassesDir)
7777
}
7878

7979
jar {

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
// https://github.com/diffplug/goomph/blob/master/CHANGES.md
33
id 'com.diffplug.eclipse.resourcefilters' version '3.21.0'
44
// https://plugins.gradle.org/plugin/com.gradle.plugin-publish
5-
id 'com.gradle.plugin-publish' version '0.10.1' apply false
5+
id 'com.gradle.plugin-publish' version '0.11.0' apply false
66
// https://github.com/bintray/gradle-bintray-plugin/releases
77
id 'com.jfrog.bintray' version '1.8.4' apply false
88
// https://github.com/mnlipp/jdrupes-mdoclet/releases

gradle/java-publish.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def makeLink = { url, text -> "<a href=\"${url}\" style=\"text-transform: none;\
2222
def javadocInfo = '<h2>' + makeLink("https://github.com/${org}/${name}", "${group}:${project.ext.artifactId}:${version}") +
2323
' by ' + makeLink('https://www.diffplug.com', 'DiffPlug') + '</h2>'
2424

25+
String dotdotGradle = project.name.startsWith('eclipse-') ? '../../gradle' : '../gradle'
2526
apply plugin: 'org.jdrupes.mdoclet'
2627
javadoc {
2728
// Where it's possible to name parameters and methods clearly enough
@@ -33,12 +34,12 @@ javadoc {
3334
options.header javadocInfo
3435
options.footer javadocInfo
3536
// setup links
36-
options.linksOffline('https://docs.oracle.com/javase/8/docs/api/', '../gradle/javadoc/java8')
37-
options.linksOffline('https://docs.gradle.org/2.14/javadoc/', '../gradle/javadoc/gradle')
37+
options.linksOffline('https://docs.oracle.com/javase/8/docs/api/', "${dotdotGradle}/javadoc/java8")
38+
options.linksOffline('https://docs.gradle.org/2.14/javadoc/', "${dotdotGradle}/javadoc/gradle")
3839

3940
// links to javadoc from the other versions
40-
options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib/${rootProject.spotlessChangelog.versionLast}", "../gradle/javadoc/spotless-lib")
41-
options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib-extra/${rootProject.spotlessChangelog.versionLast}", "../gradle/javadoc/spotless-lib-extra")
41+
options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib/${rootProject.spotlessChangelog.versionLast}", "${dotdotGradle}/javadoc/spotless-lib")
42+
options.linksOffline("https://javadoc.io/static/com.diffplug.spotless/spotless-lib-extra/${rootProject.spotlessChangelog.versionLast}", "${dotdotGradle}/javadoc/spotless-lib-extra")
4243
}
4344

4445
task javadocJar(type: Jar, dependsOn: javadoc) {

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_wtp_formatters/v4.13.0.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Spotless formatter based on Eclipse-WTP version 3.15 (see https://www.eclipse.org/webtools/)
2-
com.diffplug.spotless:spotless-eclipse-wtp:3.15.2
2+
com.diffplug.spotless:spotless-eclipse-wtp:3.15.3
33
com.diffplug.spotless:spotless-eclipse-base:3.3.0
44
com.google.code.findbugs:annotations:3.0.0
55
com.google.code.findbugs:jsr305:3.0.0

plugin-gradle/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).
44

55
## [Unreleased]
6+
### Fixed
7+
* Eclipse-WTP formatter (web tools platform, not java) handles some character encodings incorrectly on OS with non-unicode default file encoding [#545](https://github.com/diffplug/spotless/issues/545). Fixed for Eclipse-WTP formatter Eclipse version 4.13.0 (default version).
68

79
## [3.28.0] - 2020-03-20
810
### Added

plugin-maven/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
55
## [Unreleased]
66
### Added
77
* Tsfmt Maven Plugin ([#548](https://github.com/diffplug/spotless/pull/548))
8+
### Fixed
9+
* Eclipse-WTP formatter (web tools platform, not java) handles some character encodings incorrectly on OS with non-unicode default file encoding [#545](https://github.com/diffplug/spotless/issues/545). Fixed for Eclipse-WTP formatter Eclipse version 4.13.0 (default version).
810

911
## [1.28.0] - 2020-03-20
1012
### Added

0 commit comments

Comments
 (0)