diff --git a/_ext/eclipse-base/CHANGES.md b/_ext/eclipse-base/CHANGES.md
deleted file mode 100644
index 796ed584fd..0000000000
--- a/_ext/eclipse-base/CHANGES.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# spotless-eclipse-base
-
-We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.2.1`).
-
-## [Unreleased]
-
-## [3.5.2] - 2021-10-23
-### Fixed
-* Racing condition when cleaning up temporary workspace on JVM runtime shutdown (see [#967](https://github.com/diffplug/spotless/issues/967)). Can lead to error logs and remaining files in workspace.
-
-## [3.5.1] - 2021-10-16
-### Fixed
-* ~~Racing condition when cleaning up temporary workspace on JVM runtime shutdown (see [#967](https://github.com/diffplug/spotless/issues/967)). Can lead to error logs and remaining files in workspace.~~
-
-## [3.5.0] - 2021-06-20
-### Added
-* Support of `org.eclipse.core.resources` version `3.15.0` required by Eclipse `4.20`.
-* Minimum required Java version changed from 8 to 11.
-
-## [3.4.2] - 2020-12-26
-### Fixed
-* `org.eclipse.osgi` version `3.16.100` does not allow `null` as Debug service for `CloseableBundleFile`.
-
-## [3.4.1] - 2020-09-24
-### Fixed
-* Restored scope of transitive dependencies to 'compile'.
-
-## [3.4.0] - 2020-09-23
-### Added
-* Upgraded to `org.eclipse.osgi` version `3.16`.
-
-## [3.3.0] - 2020-03-04
-### Added
-* Added support of plugin extensions without activator ([#533](https://github.com/diffplug/spotless/issues/533)). Required since `org.eclipse.core.filesystem` version `1.7.600` (see
-[Bug 550548](https://bugs.eclipse.org/bugs/show_bug.cgi?id=550548))
-* Updated configuration via single interface implementation. Functional based configuration still supported.
-
-## [3.2.1] - 2019-09-03
-* Fixed deletion of temporary workspace. ([#447](https://github.com/diffplug/spotless/issues/447))
-
-## [3.2.0] - 2019-06-30
-* Added support of Eclipse 4.12 framework wiring. ([#413](https://github.com/diffplug/spotless/issues/413))
-
-## [3.1.1] - 2019-06-04
-* Fixed problem handling URL escaped characters in JAR file location. ([#401](https://github.com/diffplug/spotless/issues/401))
-
-## [3.1.0] - 2019-02-10
-* Added logging service based on SLF4J. ([#236](https://github.com/diffplug/spotless/issues/236))
-* Updated internal interfaces to support `org.eclipse.osgi` version 3.13.
-* Corrected documentation of version number usage in `gradle.properties`.
-
-## [3.0.0] - 2018-06-18
-* Initial release!
diff --git a/_ext/eclipse-base/LICENSE.txt b/_ext/eclipse-base/LICENSE.txt
deleted file mode 100644
index 3d967aee74..0000000000
--- a/_ext/eclipse-base/LICENSE.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-Eclipse Public License - v 1.0
-
-THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
-1. DEFINITIONS
-
-"Contribution" means:
-
-a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
-b) in the case of each subsequent Contributor:
-i) changes to the Program, and
-ii) additions to the Program;
-where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.
-"Contributor" means any person or entity that distributes the Program.
-
-"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.
-
-"Program" means the Contributions distributed in accordance with this Agreement.
-
-"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
-
-2. GRANT OF RIGHTS
-
-a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.
-b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
-c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.
-d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.
-3. REQUIREMENTS
-
-A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
-
-a) it complies with the terms and conditions of this Agreement; and
-b) its license agreement:
-i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;
-ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;
-iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and
-iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.
-When the Program is made available in source code form:
-
-a) it must be made available under this Agreement; and
-b) a copy of this Agreement must be included with each copy of the Program.
-Contributors may not remove or alter any copyright notices contained within the Program.
-
-Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.
-
-4. COMMERCIAL DISTRIBUTION
-
-Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.
-
-For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.
-
-5. NO WARRANTY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.
-
-6. DISCLAIMER OF LIABILITY
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-7. GENERAL
-
-If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
-
-If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.
-
-All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.
-
-Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
-
-This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
\ No newline at end of file
diff --git a/_ext/eclipse-base/README.md b/_ext/eclipse-base/README.md
deleted file mode 100644
index 39a03591ab..0000000000
--- a/_ext/eclipse-base/README.md
+++ /dev/null
@@ -1,62 +0,0 @@
-# spotless-eclipse-base
-
-Eclipse formatters are embedded in plugins serving multiple purposes and not necessarily supporting headless builds. Hence the plugin interfaces are depending on various Eclipse plugins and services not required for the formatting purpose.
-
-Spotless provides its own plugin framework with `com.diffplug.spotless.JarState`. This allows Spotless to use different Eclipse versions in parallel.
-
-
-The `com.diffplug.gradle.spotless:spotless-eclipse-base` artifact mocks the redundant Eclipse OSGI/plugin framework for Spotless. Furthermore it provides Eclipse services adapted for Spotless's own use, which avoids for example the creation of a permanent Eclipse workspace and reduces dependencies on Eclipse modules unused by the Eclipse code formatters.
-
-## Usage
-
-Include the artifact in your Spotless Eclipse formatter project, where the major version must match the Eclipse core version your formatter supports. The exact default version should be selected by the **lib-extra**.
-Minor versions indicate a change in the minimum Eclipse (core/resource) dependencies.
-Patch versions are always backward compatible.
-
-
-```Gradle
-dependencies {
- compile "com.diffplug.spotless:spotless-eclipse-base:3.+"
-}
-```
-
-In the constructor of your formatter, the Spotless Eclipse Framework can be configured depending on your formatter's requirements. For example the JDT formatter can be configured like:
-
-```Java
-public EclipseFormatterStepImpl(Properties settings) throws Exception {
- SpotlessEclipseFramework.setup(plugins -> {
- plugins.applyDefault();
- plugins.add(new org.eclipse.jdt.core.JavaCore());
- });
- ...
-```
-
-The framework also supports fat JARs, providing multiple plugins.
-In this cases the resources required by plugins, especially the `META-INF` and plugin information, must be located in locations unique to the plugin.
-For this purpose the framework expects that these resources are stored in a sub-directory
-which has the name of the package containing the plugin. For example in case the JDT plugin
-is included in your formatter fat JAR, the directory structure should be:
-
-```
-+ resources
-|
-+--+ org.eclipse.jdt.core
-| |
-| +--+ META-INF
-| | |
-| | +-- MANIFEST.MF
-| |
-| +--- plugin.properties
-| |
-| +--- plugin.xml
-
-```
-
-## Build
-
-To publish a new version, update the `_ext/eclipse-base/gradle.properties` appropriately and see [CONTRIBUTING.md](../../CONTRIBUTING.md) how to enable
-`_ext` projects.
-
-## License
-
-Spotless at large is under the Apache 2.0 license, but this jar is under the EPL v1.
diff --git a/_ext/eclipse-base/build.gradle b/_ext/eclipse-base/build.gradle
deleted file mode 100644
index 88255b57b3..0000000000
--- a/_ext/eclipse-base/build.gradle
+++ /dev/null
@@ -1,32 +0,0 @@
-apply from: rootProject.file('_ext/gradle/java-setup.gradle')
-apply from: rootProject.file('gradle/java-publish.gradle')
-
-ext {
- developers = [
- fvgh: [ name: 'Frank Vennemeyer', email: 'frankgh@zoho.com' ]
- ]
-}
-
-dependencies {
- api("org.eclipse.platform:org.eclipse.core.resources:${VER_ECLIPSE_CORE_RESOURCES}") {
- exclude group: 'org.eclipse.platform', module: 'org.eclipse.ant.core'
- exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.expressions'
- }
- api("org.slf4j:slf4j-api:${VER_SLF4J}")
-
- testImplementation("org.slf4j:slf4j-simple:${VER_SLF4J}")
-}
-
-jar {
- manifest {
- from 'src/main/resources/META-INF/MANIFEST.MF'
- }
-}
-
-//////////
-// Test //
-//////////
-sourceSets {
- // Use JAR file with all resources for Eclipse-Base integration-tests
- test.runtimeClasspath = jar.outputs.files + sourceSets.test.output + sourceSets.test.compileClasspath
-}
diff --git a/_ext/eclipse-base/gradle.properties b/_ext/eclipse-base/gradle.properties
deleted file mode 100644
index 9f8774a417..0000000000
--- a/_ext/eclipse-base/gradle.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-artifactId=spotless-eclipse-base
-description=Eclipse bundle controller and services for Spotless
-
-# Build requirements
-VER_JAVA=11
-
-# Compile dependencies
-VER_ECLIPSE_CORE_RESOURCES=[3.15.0,4.0.0[
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseConfig.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseConfig.java
deleted file mode 100644
index c8d1fb4db3..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseConfig.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2016 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base;
-
-/**
- * Obtain configuration for Eclipse framework setup
- *
- * The setup consitst of 4 phases:
- *
- *
Registration of framework bundles
- *
Registration of servicves
- *
Resitration of extension points, activation of bundles/plugins
- *
Customize bundle/plugin configuration
- *
- */
-public interface SpotlessEclipseConfig {
- default public void registerBundles(SpotlessEclipseCoreConfig config) {
- config.applyDefault();
- }
-
- default public void registerServices(SpotlessEclipseServiceConfig config) {
- config.applyDefault();
- }
-
- default public void activatePlugins(SpotlessEclipsePluginConfig config) {
- config.applyDefault();
- }
-
- default public void customize() {}
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseCoreConfig.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseCoreConfig.java
deleted file mode 100644
index 4f3aa9c2a2..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseCoreConfig.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2016 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base;
-
-import org.osgi.framework.BundleActivator;
-
-import com.diffplug.spotless.extra.eclipse.base.SpotlessEclipseFramework.DefaultBundles;
-import com.diffplug.spotless.extra.eclipse.base.osgi.BundleConfig;
-
-/**
- * Configuration of core bundles which shall be provided by the
- * {@link SpotlessEclipseFramework}.
- *
- * Core bundles are not accessed via the plugin registry, but by static methods.
- * Hence they do not require a registration, which allows a lightweight
- * setup.
- *
- * See {@code org.eclipse.core.internal.runtime.PlatformActivator} implementation for details.
- */
-public class SpotlessEclipseCoreConfig extends BundleConfig {
-
- /**
- * Don't instantiate and call {@link SpotlessEclipseConfig} directly.
- * Registered bundles should only be instantiated once, since
- * older bundles still abusing singletons for access.
- */
- SpotlessEclipseCoreConfig() {}
-
- @Override
- public void applyDefault() {
- add(SpotlessEclipseFramework.DefaultBundles.createAll());
- }
-
- @Override
- protected BundleActivator create(DefaultBundles bundle) {
- return bundle.create();
- }
-
- @Override
- protected int getDefaultState(DefaultBundles bundle) {
- return bundle.getDesiredState();
- }
-
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseFramework.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseFramework.java
deleted file mode 100644
index 2eaf9e568e..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseFramework.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright 2016-2021 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-import javax.xml.parsers.SAXParserFactory;
-
-import org.eclipse.core.internal.runtime.InternalPlatform;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-
-import com.diffplug.spotless.extra.eclipse.base.osgi.BundleConfig;
-import com.diffplug.spotless.extra.eclipse.base.osgi.BundleController;
-import com.diffplug.spotless.extra.eclipse.base.runtime.PluginRegistrar;
-
-/** Setup a framework for Spotless Eclipse based formatters */
-public final class SpotlessEclipseFramework {
- /** Spotless demands for internal formatter chains Unix (LF) line endings. */
- public static final String LINE_DELIMITER = "\n";
-
- /**
- * Default core bundles required by most plugins.
- */
- public enum DefaultBundles {
- /**
- * Plugins ask the platform whether core runtime bundle is in debug mode.
- *
- * Note that the bundle requires the
- * {@link org.eclipse.osgi.service.environment.EnvironmentInfo}
- * service.
- *
- *
- * Per default, the platform is not activated. Some plugins use this information
- * to determine whether they are running in a headless modes (without IDE).
- *
- */
- PLATFORM(org.eclipse.core.internal.runtime.PlatformActivator.class, Bundle.RESOLVED),
- /** The Spotless {@link BundleController} wraps the OSGi layer. But the plugin/extension look-up still uses the Eclipse OSGi registry.*/
- REGISTRY(org.eclipse.core.internal.registry.osgi.Activator.class),
- /** Eclipse preferences always check whether this bundle has been activated before preference are set.*/
- PREFERENCES(org.eclipse.core.internal.preferences.Activator.class),
- /** The common runtime provides common services, like log and service adapters registry. */
- COMMON(org.eclipse.core.internal.runtime.Activator.class);
-
- private final Class extends BundleActivator> activatorClass;
- private final int state;
-
- private DefaultBundles(Class extends BundleActivator> clazz) {
- this(clazz, Bundle.ACTIVE);
- }
-
- private DefaultBundles(Class extends BundleActivator> clazz, int state) {
- activatorClass = clazz;
- this.state = state;
- }
-
- /** Create new bundle activator instance. */
- public BundleActivator create() {
- return createInstance(activatorClass);
- }
-
- public int getDesiredState() {
- return state;
- }
-
- /** Create bundle activator instances for all enumerated values. */
- public static List createAll() {
- return Arrays.stream(values())
- .map(value -> new BundleConfig.Entry(value.create(), value.getDesiredState())).collect(Collectors.toList());
- }
- }
-
- /**
- * Default plugins required by most Spotless formatters.
- *
- * Eclipse plugins are OSGI bundles themselves and do not necessarily derive from the Eclipse Plugin class.
- * {@link BundleActivator} implementation may as well serve as plugins.
- * All plugins must provide a MANIFEST.MF, plugin.properties and plugin.xml description file,
- * required for the plugin registration.
- *
- */
- public enum DefaultPlugins {
- /**
- * The resources plugin initialized the Eclipse workspace and allows URL look-up.
- * Most formatters using the workspace to resolve URLs or create
- * file interfaces.
- * See {@code org.eclipse.core.resources.IFile} implementation for details.
- */
- RESOURCES(org.eclipse.core.resources.ResourcesPlugin.class);
-
- private final Class extends BundleActivator> pluginClass;
-
- DefaultPlugins(Class extends BundleActivator> clazz) {
- pluginClass = clazz;
- }
-
- /** Create new plugin instance. */
- public BundleActivator create() {
- return createInstance(pluginClass);
- }
-
- /** Create plugin instances for all enumerated values. */
- public static List createAll() {
- return Arrays.stream(values()).map(value -> value.create()).collect(Collectors.toList());
- }
- }
-
- private static T createInstance(Class extends T> clazz) {
- try {
- Constructor extends T> ctor = clazz.getConstructor();
- return ctor.newInstance(new Object[]{});
- } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
- throw new RuntimeException("Failed to create instance for: " + clazz.getCanonicalName(), e);
- }
- }
-
- private static SpotlessEclipseFramework INSTANCE = null;
-
- /**
- * Creates and configures a new {@link SpotlessEclipseFramework} using
- * {@link DefaultBundles}, {@link DefaultPlugins} and default {@link SpotlessEclipseServiceConfig}.
- * If there is already a an instance, the call is ignored.
- * @return False if the {@link SpotlessEclipseFramework} instance already exists, true otherwise.
- * @throws BundleException Throws exception in case the setup failed.
- * @deprecated Use {@link #setup(SpotlessEclipseConfig)} instead.
- */
- @Deprecated
- public synchronized static boolean setup() throws BundleException {
- return setup(plugins -> plugins.applyDefault());
- }
-
- /**
- * Creates and configures a new {@link SpotlessEclipseFramework} using
- * {@link DefaultBundles} and {@link DefaultPlugins}.
- * If there is already a an instance, the call is ignored.
- * @param plugins Eclipse plugins (which are also OSGi bundles) to start
- * @return False if the {@link SpotlessEclipseFramework} instance already exists, true otherwise.
- * @throws BundleException Throws exception in case the setup failed.
- * @deprecated Use {@link #setup(SpotlessEclipseConfig)} instead.
- */
- @Deprecated
- public synchronized static boolean setup(Consumer plugins) throws BundleException {
- return setup(config -> config.applyDefault(), plugins);
- }
-
- /**
- * Creates and configures a new {@link SpotlessEclipseFramework} using {@link DefaultBundles}.
- * If there is already a an instance, the call is ignored.
- * @param config Framework service configuration
- * @param plugins Eclipse plugins (which are also OSGi bundles) to start
- * @return False if the {@link SpotlessEclipseFramework} instance already exists, true otherwise.
- * @throws BundleException Throws exception in case the setup failed.
- * @deprecated Use {@link #setup(SpotlessEclipseConfig)} instead.
- */
- @Deprecated
- public synchronized static boolean setup(Consumer config, Consumer plugins) throws BundleException {
- return setup(core -> core.applyDefault(), config, plugins);
- }
-
- /**
- * Creates and configures a new {@link SpotlessEclipseFramework} if there is none.
- * If there is already a an instance, the call is ignored.
- * @param core Activators of core bundles
- * @param services Framework service configuration
- * @param plugins Eclipse plugins to start
- * @return False if the {@link SpotlessEclipseFramework} instance already exists, true otherwise.
- * @throws BundleException Throws exception in case the setup failed.
- * @deprecated Use {@link #setup(SpotlessEclipseConfig)} instead.
- */
- @Deprecated
- public synchronized static boolean setup(Consumer core, Consumer services, Consumer plugins) throws BundleException {
- if (null != INSTANCE) {
- return false;
- }
- setup(new SpotlessEclipseConfig() {
- @Override
- public void registerBundles(SpotlessEclipseCoreConfig config) {
- core.accept(config);
- }
-
- @Override
- public void registerServices(SpotlessEclipseServiceConfig config) {
- services.accept(config);
- }
-
- @Override
- public void activatePlugins(SpotlessEclipsePluginConfig config) {
- plugins.accept(config);
- }
- });
- return true;
- }
-
- /**
- * Creates and configures a new {@link SpotlessEclipseFramework} if there is none.
- * If there is already a an instance, the call is ignored.
- * @param config Configuration
- * @throws BundleException Throws exception in case the setup failed.
- */
- public synchronized static void setup(SpotlessEclipseConfig config) throws BundleException {
- if (null == INSTANCE) {
- INSTANCE = new SpotlessEclipseFramework();
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- try {
- INSTANCE.shutdown();
- } catch (Exception e) {
- //At shutdown everything is just done on best-efforts basis
- }
- }));
-
- config.registerServices(INSTANCE.getServiceConfig());
-
- SpotlessEclipseCoreConfig coreConfig = new SpotlessEclipseCoreConfig();
- config.registerBundles(coreConfig);
- INSTANCE.startCoreBundles(coreConfig);
-
- SpotlessEclipsePluginConfig pluginConfig = new SpotlessEclipsePluginConfig();
- config.activatePlugins(pluginConfig);
- for (Class> extension : pluginConfig.getExtensions()) {
- INSTANCE.addExtension(extension);
- }
- for (BundleConfig.Entry plugin : pluginConfig.get()) {
- INSTANCE.addPlugin(plugin.state, plugin.activator);
- }
-
- config.customize();
- }
- }
-
- private final Function registry;
- private final BundleController controller;
-
- private SpotlessEclipseFramework() throws BundleException {
-
- controller = new BundleController();
- registry = (pluginBundle) -> {
- return PluginRegistrar.register(pluginBundle);
- };
- }
-
- void shutdown() {
- controller.shutdown();
- }
-
- private SpotlessEclipseServiceConfig getServiceConfig() {
- return controller.getServices();
- }
-
- private void addExtension(Class> clazzInBundleJar) throws BundleException {
- controller.addBundle(clazzInBundleJar, registry);
- }
-
- private void addPlugin(int state, BundleActivator plugin) throws BundleException {
- controller.addBundle(state, plugin, registry);
- }
-
- private void startCoreBundles(SpotlessEclipseCoreConfig coreConfig) throws BundleException {
- //The SAXParserFactory.class is required for parsing the plugin XML files
- addMandatoryServiceIfMissing(SAXParserFactory.class, SAXParserFactory.newInstance());
-
- /*
- * Since org.eclipse.core.runtime version 3.15.300, the Eclipse bundle look-up is accomplished
- * via the wiring framework, which requires starting the InternalPlatform.
- * The internal platform initialization is customized by the services
- * registered to the controller.
- */
- InternalPlatform.getDefault().start(controller);
-
- for (BundleConfig.Entry coreBundle : coreConfig.get()) {
- try {
- BundleContext context = controller.createContext(coreBundle.state);
- coreBundle.activator.start(context);
- } catch (Exception e) {
- throw new BundleException(String.format("Failed to start %s", coreBundle.activator.getClass().getName()), BundleException.ACTIVATOR_ERROR, e);
- }
- }
- }
-
- private void addMandatoryServiceIfMissing(Class interfaceClass, S service) {
- if (null == controller.getServiceReference(interfaceClass)) {
- controller.getServices().add(interfaceClass, service);
- }
- }
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipsePluginConfig.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipsePluginConfig.java
deleted file mode 100644
index 2569c12cd9..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipsePluginConfig.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2016 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-
-import com.diffplug.spotless.extra.eclipse.base.SpotlessEclipseFramework.DefaultPlugins;
-import com.diffplug.spotless.extra.eclipse.base.osgi.BundleConfig;
-
-/**
- * Configuration of plugins which shall be provided by the
- * {@link SpotlessEclipseFramework}.
- *
- * Plugins are registered via the Eclipse registry. Therefore they
- * required a {@code plugin.xml} configuration description.
- * Note that a plugin does not necessarily derive from the
- * Eclipse {@link org.eclipse.core.runtime.Plugin} class.
- *
- *
- * Some plugins are pure extensions without any activator.
- * For resource and plugin information lookup, a class can be
- * specified which is in the JAR containing the resources and
- * plugin information. This lookup procedure also supports
- * fat JAR lookups as described in the ReadMe.md.
- *
- * @see org.eclipse.core.runtime.RegistryFactory
- */
-public class SpotlessEclipsePluginConfig extends BundleConfig {
- private final List> extensions;
-
- /**
- * Don't instantiate and call {@link SpotlessEclipseConfig} directly.
- * Registered plugins and extensions should only be instantiated once, since
- * some still abusing singletons for access.
- */
- SpotlessEclipsePluginConfig() {
- extensions = new ArrayList<>();
- }
-
- /** Add an extension plugin, identified by a class of the plugin. */
- public void add(Class> extensionClass) {
- Objects.requireNonNull(extensionClass, "Plugin extension class must nor be null");
- extensions.add(extensionClass);
- }
-
- /** Add a set of default bundles with their default states */
- public void add(Class>... extensionClasses) {
- Arrays.asList(extensionClasses).forEach(extensionClass -> add(extensionClass));
- }
-
- /** Returns the current configuration */
- public List> getExtensions() {
- return extensions;
- }
-
- @Override
- public void applyDefault() {
- add(SpotlessEclipseFramework.DefaultPlugins.createAll());
- }
-
- @Override
- protected BundleActivator create(DefaultPlugins bundle) {
- return bundle.create();
- }
-
- @Override
- protected int getDefaultState(DefaultPlugins bundle) {
- return Bundle.ACTIVE;
- }
-
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseServiceConfig.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseServiceConfig.java
deleted file mode 100644
index f0b9a97cc4..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseServiceConfig.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2016 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base;
-
-import static com.diffplug.spotless.extra.eclipse.base.SpotlessEclipseFramework.LINE_DELIMITER;
-
-import java.util.Map;
-import java.util.function.BiFunction;
-
-import org.eclipse.core.runtime.content.IContentTypeManager;
-import org.eclipse.core.runtime.preferences.IPreferencesService;
-import org.eclipse.equinox.log.ExtendedLogReaderService;
-import org.eclipse.equinox.log.ExtendedLogService;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.service.debug.DebugOptions;
-import org.eclipse.osgi.service.environment.EnvironmentInfo;
-import org.osgi.framework.ServiceException;
-import org.osgi.service.log.LogLevel;
-
-import com.diffplug.spotless.extra.eclipse.base.service.*;
-
-/**
- * Configuration/Provision of services which shall be provided by the {@link SpotlessEclipseFramework}.
- *
- * The services provide basic functions/configuration to the {@link SpotlessEclipseFramework} bundles use the services.
- * Hence the services can be used to customize the behavior of core bundles and plugins configured
- * in the {@link SpotlessEclipseCoreConfig} and {@link SpotlessEclipsePluginConfig}.
- *
- */
-public interface SpotlessEclipseServiceConfig {
-
- /** Sets property/preference value available to all bundles, plugins and services. */
- void set(String key, String value);
-
- /** Sets property/preference values available to all bundles, plugins and services. */
- default void set(Map properties) {
- properties.forEach((k, v) -> this.set(k, v));
- }
-
- /**
- * Add custom service to collection.
- *
- * Only one service per interface is allowed.
- * A service instance implementing multiple interfaces, can be added for each interface.
- *
- * Please refer to the default method implementation for examples.
- *
- * @param interfaceClass Service interface
- * @param service Service instance
- * @throws ServiceException in case service has already been configured
- */
- public void add(Class interfaceClass, S service) throws ServiceException;
-
- /**
- * Spotless formatters should not be configured by environment variables, and
- * they shall be OS independent.
- * @throws ServiceException in case service has already been configured
- */
- default public void hideEnvironment() throws ServiceException {
- add(EnvironmentInfo.class, new HiddenEnvironment());
- }
-
- /**
- * Eclipse provides means to lookup the file content type, e.g. by file name extensions.
- * This possibility is not required by most Spotless formatters.
- * @throws ServiceException in case service has already been configured
- */
- default public void ignoreContentType() throws ServiceException {
- add(IContentTypeManager.class, new NoContentTypeSpecificHandling());
- }
-
- /**
- * Disable Eclipse internal debugging.
- * @throws ServiceException in case service has already been configured
- */
- default public void disableDebugging() throws ServiceException {
- add(DebugOptions.class, new NoDebugging());
- }
-
- /**
- * Ignore accesses of unsupported preference.
- * @throws ServiceException in case service has already been configured
- */
- default public void ignoreUnsupportedPreferences() throws ServiceException {
- add(IPreferencesService.class, new NoEclipsePreferences());
- }
-
- /**
- * Use temporary locations in case plugins require to store file.
- * These files (for example workspace preferences) will be deleted
- * as soon as the application terminates.
- * @throws ServiceException in case service has already been configured
- */
- default public void useTemporaryLocations() throws ServiceException {
- add(Location.class, new TemporaryLocation());
- }
-
- /**
- * In case the string which will be formatted does not contain any
- * line delimiter (single line), Eclipse falls back to use the
- * system property.
- * Change the system default to the UNIX line separator as required
- * by Spotless.
- * @throws ServiceException in case service has already been configured
- */
- default public void changeSystemLineSeparator() throws ServiceException {
- System.setProperty("line.separator", LINE_DELIMITER);
- }
-
- /**
- * Adds Eclipse logging service Slf4J binding.
- * @throws ServiceException in case service has already been configured
- */
- default public void useSlf4J(String loggerName) {
- useSlf4J(loggerName, (s, l) -> s);
- }
-
- /**
- * Adds Eclipse logging service Slf4J binding with a message customizer function.
- * @throws ServiceException in case service has already been configured
- */
- default public void useSlf4J(String loggerName, BiFunction messageCustomizer) throws ServiceException {
- SingleSlf4JService slf4jServce = new SingleSlf4JService(loggerName, messageCustomizer);
- add(ExtendedLogService.class, slf4jServce);
- add(ExtendedLogReaderService.class, slf4jServce);
- slf4jServce.debug("Initialized Eclipse logging service.");
- }
-
- /**
- * Applies the default configurations.
- * @throws ServiceException in case a service has already been configured
- */
- default public void applyDefault() throws ServiceException {
- hideEnvironment();
- ignoreContentType();
- disableDebugging();
- ignoreUnsupportedPreferences();
- useTemporaryLocations();
- changeSystemLineSeparator();
- }
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleConfig.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleConfig.java
deleted file mode 100644
index 8e4b12c8d0..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleConfig.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2016 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base.osgi;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-
-/** A bundle configuration is given by its activator and the desired state */
-public abstract class BundleConfig> {
- public static class Entry {
- public final BundleActivator activator;
- public final int state;
-
- public Entry(BundleActivator activator, int state) {
- Objects.requireNonNull(activator, "activator");
- this.activator = activator;
- this.state = state;
- }
- }
-
- private final List config;
-
- protected BundleConfig() {
- config = new ArrayList();
- }
-
- /**
- * Activate a bundle with a certain state. A non-active state is used by
- * some bundles to allow a slim instantiation (for example in a headless
- * Eclipse).
- */
- public void add(BundleActivator activator, int state) {
- config.add(new Entry(activator, state));
- }
-
- /** Returns the current configuration */
- public List get() {
- return config;
- }
-
- /** Activate a set of bundles with certain states */
- public void add(List config) {
- this.config.addAll(config);
- }
-
- /** Activate a bundle in active state, which is the nominal choice */
- public void add(BundleActivator activator) {
- add(activator, Bundle.ACTIVE);
- }
-
- /** Activate a set of bundles with in active state */
- public void add(Collection config) {
- config.stream().forEach(entry -> add(entry));
- }
-
- /** Activate a default bundle with its default state */
- public void add(T bundle) {
- add(create(bundle), getDefaultState(bundle));
- }
-
- /** Activate a set of default bundles with their default states */
- @SuppressWarnings("unchecked")
- public void add(T... bundles) {
- Arrays.asList(bundles).forEach(bundle -> add(bundle));
- }
-
- /** Activate a default bundle with a custom state */
- public void add(T bundle, int state) {
- add(create(bundle), state);
- }
-
- /** Applies the default configurations. */
- public abstract void applyDefault();
-
- protected abstract BundleActivator create(T bundle);
-
- protected abstract int getDefaultState(T bundle);
-
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleController.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleController.java
deleted file mode 100644
index 3589bd7082..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleController.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright 2016-2021 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base.osgi;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.function.Function;
-
-import org.eclipse.core.internal.jobs.JobManager;
-import org.eclipse.osgi.internal.location.LocationHelper;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.wiring.FrameworkWiring;
-
-/**
- * OSGi bundle controller allowing a minimal Eclipse platform setup
- * by bypassing the Eclipse internal platform.
- *
- * Bundles are loaded by the same class loader, sharing the same context.
- * Services do not provide individual properties, but making use of the framework properties.
- * All bundles have a persistent state. The OSGi life-cycle is not supported.
- */
-public final class BundleController implements StaticBundleContext {
- private static final String ECLIPSE_LAUNCHER_SYMBOLIC_NAME = "org.eclipse.osgi";
-
- private final SimpleBundle systemBundle;
- private final Map properties;
- private final ServiceCollection services;
- private final BundleSet bundles;
-
- @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();
- //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.
- * Since the concept of the Spotless Eclipse framework does not allow multiple versions
- * for a bundle, this property is never used.
- */
- properties.put(org.eclipse.core.internal.runtime.FindSupport.PROP_NL, "");
-
- bundles = new BundleSet();
- systemBundle = new SimpleBundle(this, Bundle.ACTIVE);
- bundles.add(systemBundle);
-
- services = new ServiceCollection(systemBundle, properties);
-
- //Eclipse core (InternalPlatform) still uses PackageAdmin for looking up bundles
- EclipseBundleLookup bundleLookup = new EclipseBundleLookup(systemBundle, bundles);
- services.add(org.osgi.service.packageadmin.PackageAdmin.class, bundleLookup);
- services.add(FrameworkWiring.class, bundleLookup);
-
- //Redirect framework activator requests to the org.eclipse.osgi bundle to this instance.
- bundles.add(new SimpleBundle(systemBundle, ECLIPSE_LAUNCHER_SYMBOLIC_NAME, Bundle.ACTIVE));
- FrameworkBundleRegistry.initialize(this);
- }
-
- /**
- * Stop {@link org.eclipse.core.internal.jobs.JobManager} worker pool
- * and clean up resources of Spotless bundles and services.
- *
- * @implNote The {@link org.osgi.framework.BundleActivator}s
- * are not stopped, since they are not completely started.
- * For example services are suppressed by {@link StaticBundleContext}.
- */
- public void shutdown() {
- JobManager.shutdown();
- bundles.getAll().forEach(b -> {
- try {
- b.stop();
- } catch (IllegalStateException | BundleException e) {
- //Stop on best effort basis
- }
- });
- services.stop();
- }
-
- public ServiceCollection getServices() {
- return services;
- }
-
- /** Adds and starts a new bundle. */
- public void addBundle(int bundleState, BundleActivator activator, Function register) throws BundleException {
- BundleContext contextFacade = new BundleControllerContextFacade(this, bundleState, activator);
- bundles.add(contextFacade.getBundle());
- BundleException exception = register.apply(contextFacade.getBundle());
- if (null != exception)
- throw exception;
- try {
- activator.start(contextFacade);
- } catch (Exception e) {
- throw new BundleException(String.format("Failed do start %s.", activator.getClass().getName()), BundleException.ACTIVATOR_ERROR, e);
- }
- }
-
- /** Adds new bundel whithout activator (e.g. used for only for extensions) */
- public void addBundle(Class> clazzInBundleJar, Function register) throws BundleException {
- BundleContext contextFacade = new BundleControllerContextFacade(this, clazzInBundleJar);
- bundles.add(contextFacade.getBundle());
- BundleException exception = register.apply(contextFacade.getBundle());
- if (null != exception)
- throw exception;
- }
-
- /** Creates a context with an individual state if required. */
- public BundleContext createContext(int state) {
- if (state == systemBundle.getState()) {
- return this;
- }
- return new BundleControllerContextFacade(systemBundle, state);
- }
-
- @Override
- public String getProperty(String key) {
- return properties.get(key);
- }
-
- @Override
- public Bundle getBundle() {
- return systemBundle;
- }
-
- @Override
- public Bundle[] getBundles() {
- Collection shallowCopy = bundles.getAll();
- return shallowCopy.toArray(new Bundle[shallowCopy.size()]);
- }
-
- @Override
- public Bundle getBundle(long id) {
- return bundles.get(id);
- }
-
- @Override
- public Bundle getBundle(String location) {
- if (Constants.SYSTEM_BUNDLE_LOCATION.equals(location)) {
- return systemBundle;
- }
- return null;
- }
-
- @Override
- public ServiceReference>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
- //Filters are based on class names
- String interfaceClassName = (null == clazz) ? filter : clazz;
- return services.getReferences(interfaceClassName);
- }
-
- @Override
- public S getService(ServiceReference reference) {
- return services.getService(reference);
- }
-
- @Override
- public Filter createFilter(String filter) throws InvalidSyntaxException {
- return services.createFilter(filter);
- }
-
- /**
- * Facade providing access to an existing controller for a bundle
- *
- * All bundles have unrestricted access to the framework services and properties.
- * However, each bundle and its context needs to maintain its individual
- * symbolic name for look-up.
- *
- */
- private static class BundleControllerContextFacade implements StaticBundleContext {
-
- private final BundleContext context;
- private final Bundle bundle;
-
- private BundleControllerContextFacade(BundleContext context, int bundleState, BundleActivator activator) throws BundleException {
- this.context = context;
- bundle = new SimpleBundle(this, bundleState, activator);
- }
-
- private BundleControllerContextFacade(BundleContext context, Class> clazzInBundleJar) throws BundleException {
- this.context = context;
- bundle = new SimpleBundle(this, clazzInBundleJar);
- }
-
- /** Fakes an individual bundle state */
- private BundleControllerContextFacade(SimpleBundle bundle, int bundleState) {
- this.context = bundle.getBundleContext();
- this.bundle = new SimpleBundle(bundle, bundleState);
- }
-
- @Override
- public String getProperty(String key) {
- return context.getProperty(key);
- }
-
- @Override
- public Bundle getBundle() {
- return bundle;
- }
-
- @Override
- public Bundle[] getBundles() {
- return context.getBundles();
- }
-
- @Override
- public Bundle getBundle(long id) {
- return context.getBundle(id);
- }
-
- @Override
- public Bundle getBundle(String location) {
- return context.getBundle(location);
- }
-
- @Override
- public ServiceReference>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
- return context.getAllServiceReferences(clazz, filter);
- }
-
- @Override
- public S getService(ServiceReference reference) {
- return context.getService(reference);
- }
-
- @Override
- public Filter createFilter(String filter) throws InvalidSyntaxException {
- return context.createFilter(filter);
- }
-
- }
-
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleSet.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleSet.java
deleted file mode 100644
index 59e15929fd..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleSet.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2016 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base.osgi;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/** Thread save set of bundles, whereas each bundle has a unique symbolic name and a unique ID. */
-class BundleSet {
- private final Map symbolicName2bundle;
- private final Map id2bundle;
-
- BundleSet() {
- symbolicName2bundle = new ConcurrentHashMap();
- id2bundle = new ConcurrentHashMap();
- }
-
- /** Get all bundles in collection */
- Collection getAll() {
- return symbolicName2bundle.values();
- }
-
- /** Get bundle by symbolic name or null if collection does not contain the corresponding bundle. */
- Bundle get(String symbolicName) {
- return symbolicName2bundle.get(symbolicName);
- }
-
- /** Get bundle by its ID or null if collection does not contain the corresponding bundle. */
- Bundle get(long id) {
- return id2bundle.get(id);
- }
-
- /** Add bundle to collection.
- * @throws BundleException */
- void add(Bundle bundle) throws BundleException {
- Bundle existingBundle = symbolicName2bundle.put(bundle.getSymbolicName(), bundle);
- if (null != existingBundle) {
- throw new BundleException(
- String.format("Bundle '%s' (ID: %d) is already part of collection with ID %d.",
- bundle.getSymbolicName(), bundle.getBundleId(), existingBundle.getBundleId()),
- BundleException.DUPLICATE_BUNDLE_ERROR);
- }
- Bundle bundleWithSameID = id2bundle.put(bundle.getBundleId(), bundle);
- if (null != bundleWithSameID) {
- throw new BundleException(
- String.format("Bundle ID '%d' for '%s' is already used by '%s'.",
- bundle.getBundleId(),
- bundle.getSymbolicName(),
- bundleWithSameID.getSymbolicName()),
- BundleException.DUPLICATE_BUNDLE_ERROR);
- }
- }
-
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/EclipseBundleLookup.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/EclipseBundleLookup.java
deleted file mode 100644
index 0ec091a58b..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/EclipseBundleLookup.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2016 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base.osgi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.eclipse.osgi.internal.framework.FilterImpl;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.namespace.IdentityNamespace;
-import org.osgi.framework.wiring.BundleCapability;
-import org.osgi.framework.wiring.FrameworkWiring;
-import org.osgi.resource.Namespace;
-import org.osgi.resource.Requirement;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.service.packageadmin.RequiredBundle;
-
-/**
- *
- * {@link PackageAdmin} and {@link FrameworkWiring} service for bundle look-up.
- *
- * The wiring information will always claim that all required bundles are present, since
- * Spotlss does on purpose not provide all dependencies requested by plugins, since
- * only small parts of the plugins are used.
- * Removal and addition requests for bundles will always claim that there is nothing to do.
- *
- * PackageAdmin interface is deprecated, but might still be used by bundles.
- * It is kept for backward compatibility until removed from Eclipse.
- */
-@SuppressWarnings("deprecation")
-class EclipseBundleLookup implements FrameworkWiring, PackageAdmin {
-
- private static final Set OSGI_KEYS_FOR_SYMBOLIC_NAMES = Collections.unmodifiableSet(Stream.of(IdentityNamespace.IDENTITY_NAMESPACE, IdentityNamespace.TYPE_BUNDLE).collect(Collectors.toSet()));
- private final Bundle systemBundle;
- private final BundleSet bundles;
-
- EclipseBundleLookup(final Bundle systemBundle, final BundleSet bundles) {
- this.systemBundle = systemBundle;
- this.bundles = bundles;
- }
-
- @Override
- @Deprecated
- public ExportedPackage[] getExportedPackages(Bundle bundle) {
- return null;
- }
-
- @Override
- @Deprecated
- public ExportedPackage[] getExportedPackages(String name) {
- return null;
- }
-
- @Override
- @Deprecated
- public ExportedPackage getExportedPackage(String name) {
- return null;
- }
-
- @Override
- @Deprecated
- public void refreshPackages(Bundle[] bundles) {}
-
- @Override
- public boolean resolveBundles(Bundle[] bundles) {
- return true; //All required bundles can be considered available (to be confirmed by UT)
- }
-
- @Override
- public RequiredBundle[] getRequiredBundles(String symbolicName) {
- return null; // No unresolved required bundles exist
- }
-
- @Override
- public Bundle[] getBundles(String symbolicName, String versionRange) {
- //Bundles with different versions cannot be supported due to the usage of same class-loader
- Bundle bundle = bundles.get(symbolicName);
- return (null == bundle) ? null : new Bundle[]{bundle};
- }
-
- @Override
- public Bundle[] getFragments(Bundle bundle) {
- return null; //No fragments
- }
-
- @Override
- public Bundle[] getHosts(Bundle bundle) {
- return null; //No fragments
- }
-
- @Override
- public Bundle getBundle(@SuppressWarnings("rawtypes") Class clazz) {
- return bundles.get(clazz.getName());
- }
-
- @Override
- public int getBundleType(Bundle bundle) {
- return 0; //No fragments
- }
-
- @Override
- public Bundle getBundle() {
- return systemBundle;
- }
-
- @Override
- public void refreshBundles(Collection bundles, FrameworkListener... listeners) {
- //Spotless bundles cannot be loaded dynamically
- }
-
- @Override
- public boolean resolveBundles(Collection bundles) {
- return true;
- }
-
- @Override
- public Collection getRemovalPendingBundles() {
- return Collections.emptyList(); //Nothing to remove
- }
-
- @Override
- public Collection getDependencyClosure(Collection bundles) {
- return Collections.emptyList(); //No dependencies
- }
-
- @Override
- public Collection findProviders(Requirement requirement) {
- // requirement must not be null (according to interface description)!
- String filterSpec = requirement.getDirectives().get(Namespace.REQUIREMENT_FILTER_DIRECTIVE);
- if (null == filterSpec) {
- throw new IllegalArgumentException("Requirement filter diretive '" + Namespace.REQUIREMENT_FILTER_DIRECTIVE + "' not found.");
- }
- try {
- FilterImpl requirementFilter = FilterImpl.newInstance(filterSpec);
- Collection requiredSymbolicNames = getRequestedSymbolicNames(requirementFilter);
- Collection capabilities = new ArrayList(requiredSymbolicNames.size());
- requiredSymbolicNames.forEach(symbolicName -> {
- Bundle bundle = bundles.get(symbolicName);
- if (bundle != null) {
- capabilities.add(new SimpleBundleCapability(bundle));
- }
- });
- return capabilities;
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Filter specifiation invalid:\n" + filterSpec, e);
- }
- }
-
- /**
- * Simplified parser irgnoreing the version.
- * Parser is incomplete since it ignores the filter operation.
- * It basicall implements the bespoke way Eclipse maps its old style bundle handling to OSGI.
- */
- private static Collection getRequestedSymbolicNames(FilterImpl filter) {
- List symbolicNames = filter.getStandardOSGiAttributes().entrySet().stream().filter(entry -> OSGI_KEYS_FOR_SYMBOLIC_NAMES.contains(entry.getKey())).map(entry -> entry.getValue()).collect(Collectors.toList());
- filter.getChildren().forEach(childFilter -> {
- symbolicNames.addAll(getRequestedSymbolicNames(childFilter));
- });
- return symbolicNames;
- }
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/FrameworkBundleRegistry.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/FrameworkBundleRegistry.java
deleted file mode 100644
index 18d5c4bed4..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/FrameworkBundleRegistry.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2016-2020 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base.osgi;
-
-import java.util.Optional;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.connect.FrameworkUtilHelper;
-
-/**
- * Framework bundle registry service for bundles which do not come with an activator.
- *
- * Instead of returning the system bundle, a new bundle is created
- * to provide an individual resource accessor, so that
- * the correct JAR is searched for relative resource paths.
- * Note that this can also be used to override
- * original resources by providing a resource in the
- * corresponding fat JAR location.
- */
-public class FrameworkBundleRegistry implements FrameworkUtilHelper {
- static BundleController INSTANCE = null;
-
- static void initialize(BundleController bundleController) {
- if (INSTANCE != null) {
- throw new RuntimeException(FrameworkBundleRegistry.class.getName() + " already initialized.");
- }
- INSTANCE = bundleController;
- }
-
- @Override
- public Optional getBundle(Class> classFromBundle) {
- try {
- return Optional.of(new SimpleBundle(INSTANCE, classFromBundle));
- } catch (BundleException e) {
- //If the class cannot be associated to a JAR or fat JAR resource location, just retun null
- }
- return Optional.empty();
- }
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ResourceAccessor.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ResourceAccessor.java
deleted file mode 100644
index b75a2835ac..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ResourceAccessor.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2016-2021 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base.osgi;
-
-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;
-import java.util.jar.Manifest;
-
-import org.eclipse.osgi.internal.debug.Debug;
-import org.eclipse.osgi.storage.bundlefile.BundleEntry;
-import org.eclipse.osgi.storage.bundlefile.BundleFile;
-import org.eclipse.osgi.storage.bundlefile.DirBundleFile;
-import org.eclipse.osgi.storage.bundlefile.ZipBundleFile;
-import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-
-import com.diffplug.spotless.extra.eclipse.base.service.NoDebugging;
-
-/**
- * Helper to access resources.
- *
- * Spotless Eclipse formatters using in many cases fat JARs, compressing multiple
- * bundles within one JAR. Their resources can get overridden in a fat JAR.
- * Hence they provided under the bundle activators path name.
- *
- *
- * The resource overriding prevention is required in case the Spotless
- * Eclipse formatters integrate third party JARs, not available via M2.
- * Additionally it can be used in case existing third party Eclipse plugins
- * are mocked by Spotless, requiring the provision of multiple customized
- * plugin information (META-INF, plugin.xml) within one JAR.
- *
- */
-class ResourceAccessor {
- private static final Debug NO_DEBUGGING = new Debug(new NoDebugging());
- private final String fatJarResourcePath;
- private final BundleFile bundleFile;
-
- /** Resources are located in the SpotlessFramework JAR */
- ResourceAccessor() throws BundleException {
- this(ResourceAccessor.class);
- }
-
- /** Resources are located in the JAR of the given class
- * @throws BundleException */
- ResourceAccessor(Class> clazz) throws BundleException {
- String bundleObjPath = clazz.getName();
- fatJarResourcePath = bundleObjPath.substring(0, bundleObjPath.lastIndexOf('.'));
- try {
- bundleFile = getBundlFile(clazz);
- } catch (BundleException e) {
- throw new BundleException(String.format("Failed to locate resources for bundle '%s'.", clazz.getName()), e);
- }
- }
-
- private static BundleFile getBundlFile(Class> clazz) throws BundleException {
- 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.", objUri, clazz.getName()), BundleException.READ_ERROR);
- }
- try {
- return jarOrDirectory.isDirectory() ? new DirBundleFile(jarOrDirectory, false) : new ZipBundleFile(jarOrDirectory, null, null, NO_DEBUGGING, false);
- } catch (IOException e) {
- throw new BundleException(String.format("Cannot access bundle at '%s'.", jarOrDirectory), BundleException.READ_ERROR, e);
- }
- }
-
- private static URI getBundleUri(Class> clazz) throws BundleException {
- try {
- URL objUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
- return objUrl.toURI();
- } catch (NullPointerException e) {
- //No bunlde should be used for RT classes lookup. See also org.eclipse.core.runtime.PerformanceStats.
- throw new BundleException(String.format("No code source can be located for class '%s'. Class is probably not within a bundle, but part of the RT.", clazz.getName()), BundleException.READ_ERROR, e);
- } catch (SecurityException e) {
- throw new BundleException(String.format("Access to class '%s' is denied.", clazz.getName()), BundleException.READ_ERROR, e);
- } catch (URISyntaxException e) {
- throw new BundleException(String.format("Path for '%s' is invalid.", clazz.getName()), BundleException.READ_ERROR, e);
- }
- }
-
- /** Get the manifest name from the resources. */
- String getManifestName() throws BundleException {
- URL manifestUrl = getEntry(JarFile.MANIFEST_NAME);
- if (null != manifestUrl) {
- try {
- Manifest manifest = new Manifest(manifestUrl.openStream());
- String headerValue = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
- if (null == headerValue) {
- throw new BundleException(String.format("Symbolic values not found in '%s'.", manifestUrl), BundleException.MANIFEST_ERROR);
- }
- ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_SYMBOLICNAME, headerValue);
- if (null == elements) {
- throw new BundleException(String.format("Symbolic name not found '%s'. Value is '%s'.", manifestUrl, headerValue), BundleException.MANIFEST_ERROR);
- }
- //The parser already checked that at least one value exists
- return elements[0].getValueComponents()[0];
-
- } catch (IOException e) {
- throw new BundleException(String.format("Failed to parse Manifest '%s' in '%s'.", manifestUrl, bundleFile.toString()), BundleException.MANIFEST_ERROR, e);
- }
- }
- throw new BundleException(String.format("'%s' in '%s' not found. Tried also fat JAR location '%s'.", JarFile.MANIFEST_NAME, bundleFile.toString(), fatJarResourcePath), BundleException.MANIFEST_ERROR);
- }
-
- /** Get resource URL for relative path, or null if the path is not present */
- URL getEntry(String path) {
- BundleEntry entry = bundleFile.getEntry(getFatJarPath(path));
- if (null == entry) {
- entry = bundleFile.getEntry(path);
- }
- return null == entry ? null : entry.getLocalURL();
- }
-
- /**
- * Enumeration of Strings that indicate the paths found or null if the path does not exist.
- */
- Enumeration getEntries(String path) {
- Enumeration entries = bundleFile.getEntryPaths(getFatJarPath(path));
- if (null == entries) {
- entries = bundleFile.getEntryPaths(path);
- }
- return entries;
- }
-
- private String getFatJarPath(String path) {
- return fatJarResourcePath + "/" + path;
- }
-
-}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ServiceCollection.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ServiceCollection.java
deleted file mode 100644
index 2ea67f712f..0000000000
--- a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ServiceCollection.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright 2016-2021 DiffPlug
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.diffplug.spotless.extra.eclipse.base.osgi;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-
-import org.eclipse.osgi.internal.framework.DTOBuilder;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.dto.ServiceReferenceDTO;
-
-import com.diffplug.spotless.extra.eclipse.base.SpotlessEclipseServiceConfig;
-
-/**
- * Collection of services.
- * Eclipse service are not expected to hold any resources. Spotless services
- * can implement AutoCloseable in case a resource release is required on shutdown.
- *
- * Note that the collection access is not thread save, since it is expected
- * that the collection is completed before starting any bundles.
- */
-public class ServiceCollection implements SpotlessEclipseServiceConfig {
- private final Map> className2Service;
- private final List servicesWithResources;
- private final Bundle systemBundle;
- private final Map properties;
-
- /**
- * Collection of services
- * @param systemBundle All services will belong to the system bundles
- * @param All services share the same properties
- */
- ServiceCollection(Bundle systemBundle, Map properties) {
- className2Service = new HashMap>();
- servicesWithResources = new ArrayList<>();
- this.systemBundle = systemBundle;
- this.properties = properties;
- }
-
- void stop() {
- servicesWithResources.stream().forEach(s -> {
- try {
- s.close();
- } catch (Exception e) {
- //Stop on best effort basis
- }
- });
- }
-
- @Override
- public void set(String key, String value) {
- properties.put(key, value);
- }
-
- @Override
- public void add(Class interfaceClass, S service) throws ServiceException {
- String className = interfaceClass.getName();
- if (null != className2Service.put(interfaceClass.getName(), new FrameworkServiceReference(className, service))) {
- throw new ServiceException(
- String.format("Service '%s' is already registered.", interfaceClass.getName()), ServiceException.FACTORY_ERROR);
- }
- if (service instanceof AutoCloseable) {
- servicesWithResources.add((AutoCloseable) service);
- }
- }
-
- /** Creates filter object suitable to lookup service by its interface name. */
- Filter createFilter(String filterDescr) {
- Optional serviceClassName = className2Service.keySet().stream().filter(serviceClazzName -> filterDescr.contains(serviceClazzName)).findFirst();
- return new ClassNameBasedFilter(serviceClassName);
- }
-
- /**
- * Get reference matching interface class name or all references
- * @param interfaceClassName Class name filter. All references are returned in case filter is null
- * @return Matching or all interfaces. If no interface is matching the filter, null is returned.
- */
- ServiceReference>[] getReferences(String interfaceClassName) {
- if (null == interfaceClassName) {
- Collection> allServices = className2Service.values();
- return allServices.toArray(new ServiceReference>[allServices.size()]);
- }
- ServiceReference> singleService = className2Service.get(interfaceClassName);
- return (null == singleService) ? null : new ServiceReference>[]{singleService};
- }
-
- /**
- * Return service for reference if it belongs to the system bundle.
- * @param reference Service reference
- * @return null, if service does not belong to the system bundle
- */
- S getService(ServiceReference reference) {
- if (systemBundle == reference.getBundle()) {
- return ((FrameworkServiceReference) reference).getService();
- }
- return null;
- }
-
- /** References to static services (not modifiable at run-time */
- private class FrameworkServiceReference implements ServiceReference {
-
- private final String className;
- private final S service;
-
- private FrameworkServiceReference(String className, S service) {
- this.className = className;
- this.service = service;
- }
-
- private S getService() {
- return service;
- }
-
- @Override
- public java.lang.Object getProperty(String key) {
- return properties.get(key);
- }
-
- @Override
- public String[] getPropertyKeys() {
- return properties.keySet().toArray(new String[properties.size()]);
- }
-
- @Override
- public Bundle getBundle() {
- return systemBundle;
- }
-
- @Override
- public Bundle[] getUsingBundles() {
- return new Bundle[]{systemBundle};
- }
-
- @Override
- public boolean isAssignableTo(Bundle bundle, String className) {
- // Since only one class loader is used, same class come from the same package
- return this.className.equals(className);
- }
-
- @Override
- @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EQ_COMPARETO_USE_OBJECT_EQUALS")
- public int compareTo(Object reference) {
- return (this == reference) ? 0 : 1;
- }
-
- @Override
- public Dictionary getProperties() {
- return new Hashtable(properties);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public A adapt(Class type) {
- if (ServiceReferenceDTO.class.equals(type)) {
- return (A) DTOBuilder.newServiceReferenceDTO(this);
- }
- return null;
- }
-
- }
-
- /**
- * Class name based service filter
- *