Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Spotless Eclipse workspace cleanup and OSGI lock #451

Merged
merged 8 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions _ext/BUILD_INSTRUCTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

The `_ext` builds are currently tested only with gradle `4.4.1`. They are known not to work for the current wrapper version.

To install the correct version using [sdkman](https://sdkman.io/install):

- `sdk install gradle 4.4.1`
- `sdk default gradle 4.4.1`

Then you can do `gradle -b _ext/{DIR}/build.gradle publish`. `gradlew` will not work.
4 changes: 4 additions & 0 deletions _ext/eclipse-base/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# spotless-eclipse-base

### Version 3.2.1 - September 3rd 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-base)))

* Fixed deletion of temporary workspace. ([#447](https://github.com/diffplug/spotless/issues/447))

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

* Added support of Eclipse 4.12 framework wiring. ([#413](https://github.com/diffplug/spotless/issues/413))
Expand Down
6 changes: 1 addition & 5 deletions _ext/eclipse-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ is included in your formatter fat JAR, the directory structure should be:

```


## Build

```
gradlew -b _ext/eclipse-base/build.gradle publish
```

To publish a new version, update the `_ext/eclipse-base/gradle.properties` appropriately and see [BUILD_INSTRUCTIONS.md](../BUILD_INSTRUCTIONS).

## License

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.2.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 @@ -20,6 +20,7 @@
import java.util.Map;
import java.util.function.Function;

import org.eclipse.osgi.internal.location.LocationHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
Expand Down Expand Up @@ -48,9 +49,13 @@ public final class BundleController implements StaticBundleContext {

@SuppressWarnings("deprecation")
public BundleController() throws BundleException {
//OSGI locks are not required, since this framework does not allow changes after initialization.
System.setProperty(LocationHelper.PROP_OSGI_LOCKING, LocationHelper.LOCKING_NONE);

this.properties = new HashMap<String, String>();
//Don't activate all plugin bundles. Activation is triggered by this controller where needed.
properties.put(org.eclipse.core.internal.runtime.InternalPlatform.PROP_ACTIVATE_PLUGINS, Boolean.toString(false));

/*
* Used to set-up an internal member of the Eclipse runtime FindSupport,
* which is used during resources look-up from different version of bundles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/
package com.diffplug.spotless.extra.eclipse.base.service;

import java.io.File;
import java.io.IOError;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Comparator;

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

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

private static URL createTemporaryDirectory() {
try {
Path locationPath = Files.createTempDirectory(TEMP_PREFIX);
locationPath.toFile().deleteOnExit();
return locationPath.toUri().toURL();
Path location = Files.createTempDirectory(TEMP_PREFIX);
deleteDirectoryRecursivelyOnExit(location);
location.toFile().deleteOnExit();
return location.toUri().toURL();
} catch (IOException e) {
throw new IOError(e);
}
}

private static void deleteDirectoryRecursivelyOnExit(Path location) {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
Files.walk(location)
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
} catch (IOException e) {
//At shutdown everything is just done on best-efforts basis
}
}));
}

@Override
public boolean allowsDefault() {
return false;
Expand Down
6 changes: 2 additions & 4 deletions _ext/eclipse-cdt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

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.

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

```
gradlew -b _ext/eclipse-cdt/build.gradle publish
```
## License

Spotless at large is under the Apache 2.0 license, but this jar is under the EPL v1.
6 changes: 2 additions & 4 deletions _ext/eclipse-groovy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ To fix this, we publish Groovy-Eclipse's formatter and all its dependencies, alo

## Build

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

```
gradlew -b _ext/eclipse-groovy/build.gradle publish
```
## License

Spotless at large is under the Apache 2.0 license, but this jar is under the EPL v1.
6 changes: 2 additions & 4 deletions _ext/eclipse-jdt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ Eclipse JDT and its dependencies require a large amount of byte code.
Hence they should not be directly be required by the Spotless, but only be requested in case
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.

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

```
gradlew -b _ext/eclipse-jdt/build.gradle publish
```
## License

Spotless at large is under the Apache 2.0 license, but this jar is under the EPL v1.
6 changes: 2 additions & 4 deletions _ext/eclipse-wtp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

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.

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

```
gradlew -b _ext/eclipse-wtp/build.gradle publish
```
## License

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