Skip to content

Commit 33dc04d

Browse files
authored
Fix #401 - Eclipse based formater M2 cache path contains URL escapes
1 parent ed4a02b commit 33dc04d

File tree

19 files changed

+36
-19
lines changed

19 files changed

+36
-19
lines changed

_ext/eclipse-base/CHANGES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# spotless-eclipse-base
22

3-
### Version 3.2.0 - TBD
3+
### Version 3.1.1 - June 4th 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-base)))
4+
5+
* Fixed problem handling URL escaped characters in JAR file location. ([#401](https://github.com/diffplug/spotless/issues/401))
46

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

_ext/eclipse-base/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Mayor versions correspond to the supported Eclipse core version.
22
# Minor version is incremented for features or incompatible changes (including changes to supported dependency versions).
33
# Patch version is incremented for backward compatible patches of this library.
4-
ext_version=3.2.0
4+
ext_version=3.1.1
55
ext_artifactId=spotless-eclipse-base
66
ext_description=Eclipse bundle controller and services for Spotless
77

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ResourceAccessor.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import java.io.File;
1919
import java.io.IOException;
20+
import java.net.URI;
21+
import java.net.URISyntaxException;
2022
import java.net.URL;
2123
import java.util.Enumeration;
2224
import java.util.jar.JarFile;
@@ -69,10 +71,10 @@ class ResourceAccessor {
6971
}
7072

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

86+
private static URI getBundleUri(Class<?> clazz) throws BundleException {
87+
URL objUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
88+
try {
89+
return objUrl.toURI();
90+
} catch (URISyntaxException e) {
91+
throw new BundleException(String.format("Path '%s' for '%s' is invalid.", objUrl, clazz.getName()), BundleException.READ_ERROR, e);
92+
}
93+
}
94+
8495
/** Get the manifest name from the resources. */
8596
String getManifestName() throws BundleException {
8697
URL manifestUrl = getEntry(JarFile.MANIFEST_NAME);

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_cdt_formatter/v4.11.0.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Spotless formatter based on CDT version 9.7.0 (see https://www.eclipse.org/cdt/)
22
com.diffplug.spotless:spotless-eclipse-cdt:9.7.0
3-
com.diffplug.spotless:spotless-eclipse-base:3.1.0
3+
com.diffplug.spotless:spotless-eclipse-base:3.1.1
44
com.google.code.findbugs:annotations:3.0.0
55
com.google.code.findbugs:jsr305:3.0.0
66
com.ibm.icu:icu4j:61.1

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_cdt_formatter/v4.7.3a.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Spotless formatter based on CDT version 9.4.3 (see https://www.eclipse.org/cdt/)
22
com.diffplug.spotless:spotless-eclipse-cdt:9.4.5
3-
com.diffplug.spotless:spotless-eclipse-base:3.0.0
3+
com.diffplug.spotless:spotless-eclipse-base:3.1.1
44
com.google.code.findbugs:annotations:3.0.0
55
com.google.code.findbugs:jsr305:3.0.0
66
com.ibm.icu:icu4j:61.1

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter/v4.10.0.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Spotless formatter based on JDT version 4.10.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
22
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tag/?h=R4_10 to determine core version.
33
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
4-
com.diffplug.spotless:spotless-eclipse-base:3.0.0
4+
com.diffplug.spotless:spotless-eclipse-base:3.1.1
55
com.google.code.findbugs:annotations:3.0.0
66
com.google.code.findbugs:jsr305:3.0.0
77
org.eclipse.jdt:org.eclipse.jdt.core:3.16.0

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter/v4.11.0.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Spotless formatter based on JDT version 4.11.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
22
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tag/?h=R4_11 to determine core version.
33
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
4-
com.diffplug.spotless:spotless-eclipse-base:3.0.0
4+
com.diffplug.spotless:spotless-eclipse-base:3.1.1
55
com.google.code.findbugs:annotations:3.0.0
66
com.google.code.findbugs:jsr305:3.0.0
77
org.eclipse.jdt:org.eclipse.jdt.core:3.17.0

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter/v4.6.2.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Spotless formatter based on JDT version 4.6.2 (see https://projects.eclipse.org/projects/eclipse.jdt)
22
# 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.
33
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
4-
com.diffplug.spotless:spotless-eclipse-base:3.0.0
4+
com.diffplug.spotless:spotless-eclipse-base:3.1.1
55
com.google.code.findbugs:annotations:3.0.0
66
com.google.code.findbugs:jsr305:3.0.0
77
org.eclipse.jdt:org.eclipse.jdt.core:3.12.2

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter/v4.7.3a.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Spotless formatter based on JDT version 4.7.3a (see https://projects.eclipse.org/projects/eclipse.jdt)
22
# 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.
33
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
4-
com.diffplug.spotless:spotless-eclipse-base:3.0.0
4+
com.diffplug.spotless:spotless-eclipse-base:3.1.1
55
com.google.code.findbugs:annotations:3.0.0
66
com.google.code.findbugs:jsr305:3.0.0
77
org.eclipse.jdt:org.eclipse.jdt.core:3.13.101

lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter/v4.8.0.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Spotless formatter based on JDT version 4.8.0 (see https://projects.eclipse.org/projects/eclipse.jdt)
22
# Compare tag in M2 pom with https://git.eclipse.org/c/jdt/eclipse.jdt.core.git/tag/?h=R4_8 to determine core version.
33
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
4-
com.diffplug.spotless:spotless-eclipse-base:3.0.0
4+
com.diffplug.spotless:spotless-eclipse-base:3.1.1
55
com.google.code.findbugs:annotations:3.0.0
66
com.google.code.findbugs:jsr305:3.0.0
77
org.eclipse.jdt:org.eclipse.jdt.core:3.14.0

0 commit comments

Comments
 (0)