Skip to content

Commit 6179497

Browse files
authored
Merge pull request #451 from diffplug/issue_447
Fix Spotless Eclipse workspace cleanup and OSGI lock
2 parents 80c36bf + fb85ed6 commit 6179497

File tree

17 files changed

+57
-29
lines changed

17 files changed

+57
-29
lines changed

Diff for: CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ You might be looking for:
77

88
### Version 1.25.0-SNAPSHOT - TBD (javadoc [lib](https://diffplug.github.io/spotless/javadoc/spotless-lib/snapshot/) [lib-extra](https://diffplug.github.io/spotless/javadoc/spotless-lib-extra/snapshot/), [snapshot repo](https://oss.sonatype.org/content/repositories/snapshots/com/diffplug/spotless/))
99

10+
* Eclipse-based formatters used to leave temporary files around ([#447](https://github.com/diffplug/spotless/issues/447)). This is now fixed, but only for eclipse 4.12+, no back-port to older Eclipse formatter versions is planned. ([#451](https://github.com/diffplug/spotless/issues/451))
11+
1012
### Version 1.24.1 - August 12th 2018 (javadoc [lib](https://diffplug.github.io/spotless/javadoc/spotless-lib/1.24.1/) [lib-extra](https://diffplug.github.io/spotless/javadoc/spotless-lib-extra/1.24.1/), artifact [lib]([jcenter](https://bintray.com/diffplug/opensource/spotless-lib), [lib-extra]([jcenter](https://bintray.com/diffplug/opensource/spotless-lib-extra)))
1113

1214
* Fixes class loading issue with Java 9+ ([#426](https://github.com/diffplug/spotless/pull/426)).

Diff for: _ext/BUILD_INSTRUCTIONS.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
The `_ext` builds are currently tested only with gradle `4.4.1`. They are known not to work for the current wrapper version.
3+
4+
To install the correct version using [sdkman](https://sdkman.io/install):
5+
6+
- `sdk install gradle 4.4.1`
7+
- `sdk default gradle 4.4.1`
8+
9+
Then you can do `gradle -b _ext/{DIR}/build.gradle publish`. `gradlew` will not work.

Diff for: _ext/eclipse-base/CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# spotless-eclipse-base
22

3+
### Version 3.2.1 - September 3rd 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-base)))
4+
5+
* Fixed deletion of temporary workspace. ([#447](https://github.com/diffplug/spotless/issues/447))
6+
37
### Version 3.2.0 - June 30th 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-base)))
48

59
* Added support of Eclipse 4.12 framework wiring. ([#413](https://github.com/diffplug/spotless/issues/413))

Diff for: _ext/eclipse-base/README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,9 @@ is included in your formatter fat JAR, the directory structure should be:
5353

5454
```
5555

56-
5756
## Build
5857

59-
```
60-
gradlew -b _ext/eclipse-base/build.gradle publish
61-
```
62-
58+
To publish a new version, update the `_ext/eclipse-base/gradle.properties` appropriately and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS).
6359

6460
## License
6561

Diff for: _ext/eclipse-base/gradle.properties

+1-1
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.2.1
55
ext_artifactId=spotless-eclipse-base
66
ext_description=Eclipse bundle controller and services for Spotless
77

Diff for: _ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleController.java

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Map;
2121
import java.util.function.Function;
2222

23+
import org.eclipse.osgi.internal.location.LocationHelper;
2324
import org.osgi.framework.Bundle;
2425
import org.osgi.framework.BundleActivator;
2526
import org.osgi.framework.BundleContext;
@@ -48,9 +49,13 @@ public final class BundleController implements StaticBundleContext {
4849

4950
@SuppressWarnings("deprecation")
5051
public BundleController() throws BundleException {
52+
//OSGI locks are not required, since this framework does not allow changes after initialization.
53+
System.setProperty(LocationHelper.PROP_OSGI_LOCKING, LocationHelper.LOCKING_NONE);
54+
5155
this.properties = new HashMap<String, String>();
5256
//Don't activate all plugin bundles. Activation is triggered by this controller where needed.
5357
properties.put(org.eclipse.core.internal.runtime.InternalPlatform.PROP_ACTIVATE_PLUGINS, Boolean.toString(false));
58+
5459
/*
5560
* Used to set-up an internal member of the Eclipse runtime FindSupport,
5661
* which is used during resources look-up from different version of bundles.

Diff for: _ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/TemporaryLocation.java

+19-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
*/
1616
package com.diffplug.spotless.extra.eclipse.base.service;
1717

18+
import java.io.File;
1819
import java.io.IOError;
1920
import java.io.IOException;
2021
import java.net.URISyntaxException;
2122
import java.net.URL;
2223
import java.nio.file.Files;
2324
import java.nio.file.Path;
2425
import java.nio.file.Paths;
26+
import java.util.Comparator;
2527

2628
import org.eclipse.osgi.service.datalocation.Location;
2729

@@ -42,14 +44,28 @@ private TemporaryLocation(Location parent, URL defaultValue) {
4244

4345
private static URL createTemporaryDirectory() {
4446
try {
45-
Path locationPath = Files.createTempDirectory(TEMP_PREFIX);
46-
locationPath.toFile().deleteOnExit();
47-
return locationPath.toUri().toURL();
47+
Path location = Files.createTempDirectory(TEMP_PREFIX);
48+
deleteDirectoryRecursivelyOnExit(location);
49+
location.toFile().deleteOnExit();
50+
return location.toUri().toURL();
4851
} catch (IOException e) {
4952
throw new IOError(e);
5053
}
5154
}
5255

56+
private static void deleteDirectoryRecursivelyOnExit(Path location) {
57+
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
58+
try {
59+
Files.walk(location)
60+
.sorted(Comparator.reverseOrder())
61+
.map(Path::toFile)
62+
.forEach(File::delete);
63+
} catch (IOException e) {
64+
//At shutdown everything is just done on best-efforts basis
65+
}
66+
}));
67+
}
68+
5369
@Override
5470
public boolean allowsDefault() {
5571
return false;

Diff for: _ext/eclipse-cdt/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
Eclipse CDT is not available in a form which can be easily consumed by maven or gradle. To fix this, we publish Eclipse's formatter and all its dependencies, along with a small amount of glue code, into the `com.diffplug.gradle.spotless:spotless-eclipse-cdt` artifact.
44

5-
To publish a new version, update the `_ext/eclipse-cdt/gradle.properties` appropriately and run this from the root directory:
5+
To publish a new version, update the `_ext/eclipse-cdt/gradle.properties` appropriately and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS).
66

7-
```
8-
gradlew -b _ext/eclipse-cdt/build.gradle publish
9-
```
7+
## License
108

119
Spotless at large is under the Apache 2.0 license, but this jar is under the EPL v1.

Diff for: _ext/eclipse-groovy/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ To fix this, we publish Groovy-Eclipse's formatter and all its dependencies, alo
55

66
## Build
77

8-
To publish a new version, update the `_ext/eclipse-groovy/gradle.properties` appropriately and run this from the root directory:
8+
To publish a new version, update the `_ext/eclipse-groovy/gradle.properties` appropriately and and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS).
99

10-
```
11-
gradlew -b _ext/eclipse-groovy/build.gradle publish
12-
```
10+
## License
1311

1412
Spotless at large is under the Apache 2.0 license, but this jar is under the EPL v1.

Diff for: _ext/eclipse-jdt/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ Eclipse JDT and its dependencies require a large amount of byte code.
44
Hence they should not be directly be required by the Spotless, but only be requested in case
55
they are configured by the Spotless configuration. Hence we publish Eclipse's formatter and all its dependencies, along with a small amount of glue code, into the `com.diffplug.gradle.spotless:spotless-eclipse-jdt` artifact.
66

7-
To publish a new version, update the `_ext/eclipse-jdt/gradle.properties` appropriately and run this from the root directory:
7+
To publish a new version, update the `_ext/eclipse-jdt/gradle.properties` appropriately and and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS).
88

9-
```
10-
gradlew -b _ext/eclipse-jdt/build.gradle publish
11-
```
9+
## License
1210

1311
Spotless at large is under the Apache 2.0 license, but this jar is under the EPL v1.

Diff for: _ext/eclipse-wtp/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
Eclipse WTP is not available in a form which can be easily consumed by maven or gradle. To fix this, we publish Eclipse's WTP formatters, along with a small amount of glue code, into the `com.diffplug.spotless.extra:spotless-eclipse-wtp` artifact.
44

5-
To publish a new version, update the `_ext/eclipse-wtp/gradle.properties` appropriately and run this from the root directory:
5+
To publish a new version, update the `_ext/eclipse-wtp/gradle.properties` appropriately and and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS).
66

7-
```
8-
gradlew -b _ext/eclipse-wtp/build.gradle publish
9-
```
7+
## License
108

119
Spotless at large is under the Apache 2.0 license, but this jar is under the EPL v1.

Diff for: lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_cdt_formatter/v4.12.0.lockfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Spotless formatter based on CDT version 9.8.0 (see https://www.eclipse.org/cdt/)
22
com.diffplug.spotless:spotless-eclipse-cdt:9.8.0
3-
com.diffplug.spotless:spotless-eclipse-base:3.2.0
3+
com.diffplug.spotless:spotless-eclipse-base:3.2.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.2

Diff for: lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_jdt_formatter/v4.12.0.lockfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Spotless formatter based on JDT version 4.12.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_12 to determine core version.
33
com.diffplug.spotless:spotless-eclipse-jdt:4.8.0
4-
com.diffplug.spotless:spotless-eclipse-base:3.2.0
4+
com.diffplug.spotless:spotless-eclipse-base:3.2.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.18.0

Diff for: lib-extra/src/main/resources/com/diffplug/spotless/extra/eclipse_wtp_formatters/v4.12.0.lockfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Spotless formatter based on Eclipse-WTP version 3.14 (see https://www.eclipse.org/webtools/)
22
com.diffplug.spotless:spotless-eclipse-wtp:3.14.0
3-
com.diffplug.spotless:spotless-eclipse-base:3.2.0
3+
com.diffplug.spotless:spotless-eclipse-base:3.2.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.2

Diff for: lib-extra/src/main/resources/com/diffplug/spotless/extra/groovy_eclipse_formatter/v4.12.0.lockfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Spotless formatter based on Groovy-Eclipse version 3.4.0 (see https://github.com/groovy/groovy-eclipse/releases)
22
com.diffplug.spotless:spotless-eclipse-groovy:3.4.0
3-
com.diffplug.spotless:spotless-eclipse-base:3.2.0
3+
com.diffplug.spotless:spotless-eclipse-base:3.2.1
44
com.google.code.findbugs:annotations:3.0.0
55
com.google.code.findbugs:jsr305:3.0.0
66
org.eclipse.platform:org.eclipse.core.commands:3.9.400

Diff for: plugin-gradle/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Version 3.25.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/))
44

5+
* Eclipse-based formatters used to leave temporary files around ([#447](https://github.com/diffplug/spotless/issues/447)). This is now fixed, but only for eclipse 4.12+, no back-port to older Eclipse formatter versions is planned. ([#451](https://github.com/diffplug/spotless/issues/451))
6+
57
### Version 3.24.2 - August 19th 2019 ([javadoc](https://diffplug.github.io/spotless/javadoc/spotless-plugin-gradle/3.24.1/), [jcenter](https://bintray.com/diffplug/opensource/spotless-plugin-gradle/3.24.1))
68

79
* Fixed `Warning deprecated usage found: Using the incremental task API without declaring any outputs has been deprecated.` that started appearing in Gradle 5.5 ([#434](https://github.com/diffplug/spotless/pull/434)).

Diff for: plugin-maven/CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Version 1.25.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/))
44

5+
* Eclipse-based formatters used to leave temporary files around ([#447](https://github.com/diffplug/spotless/issues/447)). This is now fixed, but only for eclipse 4.12+, no back-port to older Eclipse formatter versions is planned. ([#451](https://github.com/diffplug/spotless/issues/451))
6+
57
### Version 1.24.1 - August 12th 2019 ([javadoc](https://diffplug.github.io/spotless/javadoc/spotless-maven-plugin/1.24.1/), [jcenter](https://bintray.com/diffplug/opensource/spotless-maven-plugin/1.24.1))
68

79
* Fixes class loading issue with Java 9+ ([#426](https://github.com/diffplug/spotless/pull/426)).

0 commit comments

Comments
 (0)