Skip to content

Commit

Permalink
Fix diffplug#401 - Eclipse based formater M2 cache path contains URL …
Browse files Browse the repository at this point in the history
…escapes
  • Loading branch information
fvgh authored Jun 6, 2019
1 parent ed4a02b commit 33dc04d
Show file tree
Hide file tree
Showing 19 changed files with 36 additions and 19 deletions.
4 changes: 3 additions & 1 deletion _ext/eclipse-base/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# spotless-eclipse-base

### Version 3.2.0 - TBD
### Version 3.1.1 - June 4th 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-base)))

* Fixed problem handling URL escaped characters in JAR file location. ([#401](https://github.com/diffplug/spotless/issues/401))

### Version 3.1.0 - February 10th 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-base)))

Expand Down
2 changes: 1 addition & 1 deletion _ext/eclipse-base/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Mayor versions correspond to the supported Eclipse core version.
# Minor version is incremented for features or incompatible changes (including changes to supported dependency versions).
# Patch version is incremented for backward compatible patches of this library.
ext_version=3.2.0
ext_version=3.1.1
ext_artifactId=spotless-eclipse-base
ext_description=Eclipse bundle controller and services for Spotless

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.JarFile;
Expand Down Expand Up @@ -69,10 +71,10 @@ class ResourceAccessor {
}

private static BundleFile getBundlFile(Class<?> clazz) throws BundleException {
URL objUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
File jarOrDirectory = new File(objUrl.getPath());
URI objUri = getBundleUri(clazz);
File jarOrDirectory = new File(objUri.getPath());
if (!(jarOrDirectory.exists() && jarOrDirectory.canRead())) {
throw new BundleException(String.format("Path '%s' for '%s' is not accessible exist on local file system.", objUrl, clazz.getName()), BundleException.READ_ERROR);
throw new BundleException(String.format("Path '%s' for '%s' is not accessible exist on local file system.", objUri, clazz.getName()), BundleException.READ_ERROR);
}
try {
return jarOrDirectory.isDirectory() ? new DirBundleFile(jarOrDirectory, false) : new ZipBundleFile(jarOrDirectory, null, null, null);
Expand All @@ -81,6 +83,15 @@ private static BundleFile getBundlFile(Class<?> clazz) throws BundleException {
}
}

private static URI getBundleUri(Class<?> clazz) throws BundleException {
URL objUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
try {
return objUrl.toURI();
} catch (URISyntaxException e) {
throw new BundleException(String.format("Path '%s' for '%s' is invalid.", objUrl, clazz.getName()), BundleException.READ_ERROR, e);
}
}

/** Get the manifest name from the resources. */
String getManifestName() throws BundleException {
URL manifestUrl = getEntry(JarFile.MANIFEST_NAME);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on CDT version 9.7.0 (see https://www.eclipse.org/cdt/)
com.diffplug.spotless:spotless-eclipse-cdt:9.7.0
com.diffplug.spotless:spotless-eclipse-base:3.1.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
com.ibm.icu:icu4j:61.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on CDT version 9.4.3 (see https://www.eclipse.org/cdt/)
com.diffplug.spotless:spotless-eclipse-cdt:9.4.5
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
com.ibm.icu:icu4j:61.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Spotless formatter based on JDT version 4.10.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tag/?h=R4_10 to determine core version.
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
org.eclipse.jdt:org.eclipse.jdt.core:3.16.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Spotless formatter based on JDT version 4.11.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tag/?h=R4_11 to determine core version.
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
org.eclipse.jdt:org.eclipse.jdt.core:3.17.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Spotless formatter based on JDT version 4.6.2 (see https://projects.eclipse.org/projects/eclipse.jdt)
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/log/?h=R4_6_maintenance to determine core version.
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
org.eclipse.jdt:org.eclipse.jdt.core:3.12.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Spotless formatter based on JDT version 4.7.3a (see https://projects.eclipse.org/projects/eclipse.jdt)
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/log/?h=R4_7_maintenance to determine core version.
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
org.eclipse.jdt:org.eclipse.jdt.core:3.13.101
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Spotless formatter based on JDT version 4.8.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tag/?h=R4_8 to determine core version.
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
org.eclipse.jdt:org.eclipse.jdt.core:3.14.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Spotless formatter based on JDT version 4.9.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tag/?h=R4_9 to determine core version.
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
org.eclipse.jdt:org.eclipse.jdt.core:3.15.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on Eclipse-WTP version 3.9.5 (see https://www.eclipse.org/webtools/)
com.diffplug.spotless:spotless-eclipse-wtp:3.9.7
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
com.ibm.icu:icu4j:61.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on Eclipse-WTP version 3.9.5 (see https://www.eclipse.org/webtools/)
com.diffplug.spotless:spotless-eclipse-wtp:3.9.8
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
com.ibm.icu:icu4j:61.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on Eclipse-WTP version 3.9.5 (see https://www.eclipse.org/webtools/)
com.diffplug.spotless:spotless-eclipse-wtp:3.10.0
com.diffplug.spotless:spotless-eclipse-base:3.1.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
com.ibm.icu:icu4j:61.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on Groovy-Eclipse version 3.0.0 (see https://github.com/groovy/groovy-eclipse/releases)
com.diffplug.spotless:spotless-eclipse-groovy:3.2.0
com.diffplug.spotless:spotless-eclipse-base:3.1.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
org.eclipse.platform:org.eclipse.core.commands:3.9.300
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on Groovy-Eclipse version 2.9.2 (see https://github.com/groovy/groovy-eclipse/releases)
com.diffplug.spotless:spotless-eclipse-groovy:2.9.2
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
org.eclipse.platform:org.eclipse.core.commands:3.9.100
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spotless formatter based on Groovy-Eclipse version 3.0.0 (see https://github.com/groovy/groovy-eclipse/releases)
com.diffplug.spotless:spotless-eclipse-groovy:3.0.1
com.diffplug.spotless:spotless-eclipse-base:3.0.0
com.diffplug.spotless:spotless-eclipse-base:3.1.1
com.google.code.findbugs:annotations:3.0.0
com.google.code.findbugs:jsr305:3.0.0
org.eclipse.platform:org.eclipse.core.commands:3.9.100
Expand Down
2 changes: 2 additions & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Version 3.24.0-SNAPSHOT - TBD ([javadoc](https://diffplug.github.io/spotless/javadoc/snapshot/), [snapshot](https://oss.sonatype.org/content/repositories/snapshots/com/diffplug/spotless/spotless-plugin-gradle/))

* Fixes incorrect M2 cache directory path handling of Eclipse based formatters ([#401](https://github.com/diffplug/spotless/issues/401))

### Version 3.23.0 - April 24th 2019 ([javadoc](https://diffplug.github.io/spotless/javadoc/spotless-plugin-gradle/3.23.0/), [jcenter](https://bintray.com/diffplug/opensource/spotless-plugin-gradle/3.23.0))

* Updated default ktlint from 0.21.0 to 0.32.0, and Maven coords to com.pinterest ([#394](https://github.com/diffplug/spotless/pull/394))
Expand Down
2 changes: 2 additions & 0 deletions plugin-maven/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Version 1.24.0-SNAPSHOT - TBD ([javadoc](https://diffplug.github.io/spotless/javadoc/spotless-maven-plugin/snapshot/), [snapshot](https://oss.sonatype.org/content/repositories/snapshots/com/diffplug/spotless/spotless-maven-plugin/))

* Fixes incorrect M2 cache directory path handling of Eclipse based formatters ([#401](https://github.com/diffplug/spotless/issues/401))

### Version 1.23.0 - April 24th 2019 ([javadoc](https://diffplug.github.io/spotless/javadoc/spotless-maven-plugin/1.23.0/), [jcenter](https://bintray.com/diffplug/opensource/spotless-maven-plugin/1.23.0))

* Updated default ktlint from 0.21.0 to 0.32.0, and Maven coords to com.pinterest ([#394](https://github.com/diffplug/spotless/pull/394))
Expand Down

0 comments on commit 33dc04d

Please sign in to comment.