diff --git a/.gitignore b/.gitignore index 622ef384ba..e820110b1b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,9 @@ gradle-app.setting # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) !gradle-wrapper.jar +#Gradle-Lock files in _ext just serving as an input for lib-extra +_ext/*/gradle/dependency-locks/compileClasspath.lockfile + ### Eclipse ### *.pydevproject .metadata diff --git a/_ext/eclipse-base/LICENSE.txt b/_ext/eclipse-base/LICENSE.txt new file mode 100644 index 0000000000..3d967aee74 --- /dev/null +++ b/_ext/eclipse-base/LICENSE.txt @@ -0,0 +1,70 @@ +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 new file mode 100644 index 0000000000..9f038db79a --- /dev/null +++ b/_ext/eclipse-base/README.md @@ -0,0 +1,66 @@ +# 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 + +``` +gradlew -b _ext/eclipse-base/build.gradle publish +``` + + +## 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 new file mode 100644 index 0000000000..97473ead19 --- /dev/null +++ b/_ext/eclipse-base/build.gradle @@ -0,0 +1,30 @@ +apply from: rootProject.file('../gradle/java-setup.gradle') +apply from: rootProject.file('../gradle/java-publish.gradle') + +ext { + developers = [ + fvgh: [ name: 'Frank Vennemeyer', email: 'frankgh@zoho.com' ] + ] +} + +dependencies { + compile("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' + exclude group: 'org.eclipse.platform', module: 'org.eclipse.core.filesystem' + } +} + +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 new file mode 100644 index 0000000000..693aa62383 --- /dev/null +++ b/_ext/eclipse-base/gradle.properties @@ -0,0 +1,15 @@ +# Mayor version correspond to the required Eclipse core version. +# Minor version changes in case the minimum Eclipse core dependencies are raised due to incompatibilities of their internal interfaces. +# Patch version is incremented in case of bug-fixes and evolutions. +ext_version=3.0.0-SNAPSHOT +ext_artifactId=spotless-eclipse-base +ext_description=Eclipse bundle controller and services for Spotless + +ext_org=diffplug +ext_group=com.diffplug.spotless + +# Build requirements +ext_VER_JAVA=1.8 + +# Compile dependencies +VER_ECLIPSE_CORE_RESOURCES=[3.11.0,4.0.0[ 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 new file mode 100644 index 0000000000..f481c667cd --- /dev/null +++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseCoreConfig.java @@ -0,0 +1,52 @@ +/* + * 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 org.eclipse.core.internal.runtime.PlatformActivator + */ +public class SpotlessEclipseCoreConfig extends BundleConfig+ * 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 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+ * 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 org.eclipse.core.resources.IFile + */ + 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+ * 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. + *
+ * @see org.eclipse.core.runtime.RegistryFactory + */ +public class SpotlessEclipsePluginConfig extends BundleConfig+ * 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+ * 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
+ */
+ public
+ * 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.
+ *
+ * The wiring information will always claim that all required bundles are present.
+ * Other functionality is not supported.
+ * Unsupported methods are marked as deprecated and throw an {@link UnsupportedOperationException}.
+ *
+ * Interface is deprecated, but for example the InternalPlatform still uses PackageAdmin.
+ */
+@SuppressWarnings("deprecation")
+class EclipseBundleLookup implements PackageAdmin {
+
+ private final BundleSet bundles;
+
+ EclipseBundleLookup(final BundleSet bundles) {
+ 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
+ }
+
+}
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
new file mode 100644
index 0000000000..8bad77d010
--- /dev/null
+++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ResourceAccessor.java
@@ -0,0 +1,132 @@
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+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;
+
+/**
+ * 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.
+ *
+ * Dictionary and capability look-ups are not supported and marked as deprecated.
+ */
+ private class ClassNameBasedFilter implements Filter {
+
+ private final static String NO_MATCH_CLASS_NAME = "";
+
+ private final String className;
+
+ private ClassNameBasedFilter(Optional
+ * All state related modifications are ignored.
+ * Installation related methods (update/uninstall) are unsupported.
+ * Unsupported methods are marked as deprecated and causing an exception.
+ */
+public interface StaticBundle extends Bundle {
+
+ @Override
+ default public void start(int options) throws BundleException {}
+
+ @Override
+ default public void start() throws BundleException {}
+
+ @Override
+ default public void stop(int options) throws BundleException {}
+
+ @Override
+ default public void stop() throws BundleException {}
+
+ @Override
+ @Deprecated
+ default public void update(InputStream input) throws BundleException {
+ update();
+ }
+
+ @Override
+ @Deprecated
+ default public void update() throws BundleException {
+ throw new UnsupportedOperationException("Bundle modifications are not supported.");
+ }
+
+ @Override
+ @Deprecated
+ default public void uninstall() throws BundleException {
+ throw new UnsupportedOperationException("Bundles cannot be uninstalled.");
+ }
+
+ @Override
+ default public long getLastModified() {
+ return 0;
+ }
+
+ @Override
+ @Deprecated
+ default public String getLocation() {
+ throw new UnsupportedOperationException("Bundle lookup by location only required for installation/update.");
+ }
+
+ @Override
+ default public ServiceReference>[] getServicesInUse() {
+ return getRegisteredServices(); //There is no distinction between available services and services in use.
+ }
+
+}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/StaticBundleContext.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/StaticBundleContext.java
new file mode 100644
index 0000000000..040ef98444
--- /dev/null
+++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/StaticBundleContext.java
@@ -0,0 +1,166 @@
+/*
+ * 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.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceObjects;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Restriction of the {@link BundleContext} interface rejecting run-time provision of bundles.
+ * Services provided at run-time are ignored.
+ *
+ * Multiple service instances per class are not supported, hence the services can be filtered by class name.
+ * Unsupported methods are marked as deprecated an causing an exception.
+ * Registration and removal of bundle/service listeners are ignored, since a run-time
+ * provision of bundles or services is not supported.
+ */
+interface StaticBundleContext extends BundleContext {
+
+ @Override
+ @Deprecated
+ default public Bundle installBundle(String location, InputStream input) throws BundleException {
+ throw new UnsupportedOperationException("Run-time installation of bundles is not supported.");
+ }
+
+ @Override
+ @Deprecated
+ default public Bundle installBundle(String location) throws BundleException {
+ throw new UnsupportedOperationException("Run-time installation of bundles is not supported.");
+ }
+
+ @Override
+ default public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {}
+
+ @Override
+ default public void addServiceListener(ServiceListener listener) {}
+
+ @Override
+ default public void removeServiceListener(ServiceListener listener) {}
+
+ @Override
+ default public void addBundleListener(BundleListener listener) {}
+
+ @Override
+ default public void removeBundleListener(BundleListener listener) {}
+
+ @Override
+ default public void addFrameworkListener(FrameworkListener listener) {}
+
+ @Override
+ default public void removeFrameworkListener(FrameworkListener listener) {}
+
+ @Override
+ @Deprecated
+ default public ServiceRegistration> registerService(String[] clazzes, Object service, Dictionary
+ * META data look-ups are not supported (only required for Eclipse plugins).
+ * Entry look-up in the bundle space (findEntries) is not supported.
+ * Installation related methods (update/uninstall) are not supported.
+ * Unsupported methods are marked as deprecated and causing an exception.
+ */
+public interface TemporaryBundle extends Bundle {
+
+ @Override
+ default public Version getVersion() {
+ return Version.emptyVersion; //Cannot support multiple version using single class loader.
+ }
+
+ @Override
+ default public int compareTo(Bundle o) {
+ //Symbolic name is sufficient to distinguish bundles
+ return getSymbolicName().compareTo(o.getSymbolicName());
+ }
+
+ @Override
+ default public A adapt(Class type) {
+ return null; //Adaptation is not successful
+ }
+
+ @Override
+ @Deprecated
+ default public Dictionary
+ * Note that the functionality provided by this class uses incubation features of the Eclipse core.
+ */
+public class PluginRegistrar {
+ private static final String PLUGIN_XML = "plugin.xml";
+ private static final String PLUGIN_PROPERTIES = "plugin.properties";
+
+ public static BundleException register(Bundle bundle) {
+ PluginRegistrar registrar = new PluginRegistrar(bundle);
+ try {
+ registrar.register();
+ } catch (BundleException e) {
+ return e;
+ }
+ return null;
+ }
+
+ private final Bundle bundle;
+
+ private PluginRegistrar(Bundle bundle) {
+ this.bundle = bundle;
+ }
+
+ private void register() throws BundleException {
+ IExtensionRegistry reg = RegistryFactory.getRegistry();
+ Object registryUser = ((ExtensionRegistry) reg).getTemporaryUserToken();
+ if (!reg.addContribution(getStreamForEntry(PLUGIN_XML), createContributor(), false, null, getPluginProperties(), registryUser)) {
+ throw new BundleException("Could not add plugin: " + bundle.getSymbolicName(), BundleException.REJECTED_BY_HOOK);
+ }
+ }
+
+ private IContributor createContributor() {
+ return new RegistryContributor(
+ Long.toString(bundle.getBundleId()),
+ bundle.getSymbolicName(),
+ // Local host
+ null,
+ null);
+ }
+
+ private ResourceBundle getPluginProperties() throws BundleException {
+ //Some plugins, like the org.codehaus.groovy.eclipse.core, do not provide a property file.
+ InputStream is = entryExists(PLUGIN_PROPERTIES) ? getStreamForEntry(PLUGIN_PROPERTIES) : new ByteArrayInputStream(new byte[0]);
+ try {
+ return new PropertyResourceBundle(is);
+ } catch (IOException e) {
+ throw new BundleException(String.format("Bund resource '%s' is not encoded with ISO-8859-1.", PLUGIN_PROPERTIES), BundleException.MANIFEST_ERROR, e);
+ }
+ }
+
+ private InputStream getStreamForEntry(String path) throws BundleException {
+ try {
+ return getEntry(path).openStream();
+ } catch (IOException e) {
+ throw new BundleException(String.format("Cannot access mandatory resource '%s'.", path), BundleException.MANIFEST_ERROR, e);
+ }
+ }
+
+ private URL getEntry(String path) throws BundleException {
+ URL url = bundle.getEntry(path);
+ if (null == url) {
+ throw new BundleException(String.format("Cannot find mandatory resource '%s'.", path), BundleException.MANIFEST_ERROR);
+ }
+ return url;
+ }
+
+ private boolean entryExists(String path) {
+ return null != bundle.getEntry(path);
+ }
+}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/runtime/package-info.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/runtime/package-info.java
new file mode 100644
index 0000000000..5ed08616b9
--- /dev/null
+++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/runtime/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * 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.
+ */
+/**
+ * Eclipse Core Runtime adapters allowing runtime modifications which normally requires an Eclipse restart.
+ */
+package com.diffplug.spotless.extra.eclipse.base.runtime;
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/HiddenEnvironment.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/HiddenEnvironment.java
new file mode 100644
index 0000000000..8c9c1a6c91
--- /dev/null
+++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/HiddenEnvironment.java
@@ -0,0 +1,81 @@
+/*
+ * 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.service;
+
+import java.util.Locale;
+
+import org.eclipse.osgi.service.environment.Constants;
+import org.eclipse.osgi.service.environment.EnvironmentInfo;
+
+/** Empty default Eclipse environment. No system information is accessible. */
+public class HiddenEnvironment implements EnvironmentInfo {
+
+ @Override
+ public String[] getCommandLineArgs() {
+ return new String[0];
+ }
+
+ @Override
+ public String[] getFrameworkArgs() {
+ return new String[0];
+ }
+
+ @Override
+ public String[] getNonFrameworkArgs() {
+ return new String[0];
+ }
+
+ @Override
+ public String getOSArch() {
+ return System.getProperty("os.arch");
+ }
+
+ @Override
+ public String getNL() {
+ return Locale.getDefault().getLanguage();
+ }
+
+ @Override
+ public String getOS() {
+ return Constants.OS_UNKNOWN;
+ }
+
+ @Override
+ public String getWS() {
+ return null; //No window system
+ }
+
+ @Override
+ public boolean inDebugMode() {
+ return false;
+ }
+
+ @Override
+ public boolean inDevelopmentMode() {
+ return false;
+ }
+
+ @Override
+ public String setProperty(String key, String value) {
+ return value; //Launcher information is not stored
+ }
+
+ @Override
+ public String getProperty(String key) {
+ return null; //Launcher information/configuration is not required
+ }
+
+}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/NoContentTypeSpecificHandling.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/NoContentTypeSpecificHandling.java
new file mode 100644
index 0000000000..87e1f2f91b
--- /dev/null
+++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/NoContentTypeSpecificHandling.java
@@ -0,0 +1,95 @@
+/*
+ * 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.service;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.runtime.content.IContentTypeMatcher;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+
+/** No content type specific handling is supported. */
+public class NoContentTypeSpecificHandling implements IContentTypeManager {
+
+ @Override
+ public IContentType findContentTypeFor(InputStream contents, String fileName) throws IOException {
+ return null;
+ }
+
+ @Override
+ public IContentType findContentTypeFor(String fileName) {
+ return null;
+ }
+
+ @Override
+ public IContentType[] findContentTypesFor(InputStream contents, String fileName) throws IOException {
+ return null;
+ }
+
+ @Override
+ public IContentType[] findContentTypesFor(String fileName) {
+ return null;
+ }
+
+ @Override
+ public IContentDescription getDescriptionFor(InputStream contents, String fileName, QualifiedName[] options) throws IOException {
+ return null;
+ }
+
+ @Override
+ public IContentDescription getDescriptionFor(Reader contents, String fileName, QualifiedName[] options) throws IOException {
+ return null;
+ }
+
+ @Override
+ public void addContentTypeChangeListener(IContentTypeChangeListener listener) {}
+
+ @Override
+ public IContentType[] getAllContentTypes() {
+ return null;
+ }
+
+ @Override
+ public IContentType getContentType(String contentTypeIdentifier) {
+ return null;
+ }
+
+ @Override
+ public IContentTypeMatcher getMatcher(ISelectionPolicy customPolicy, IScopeContext context) {
+ return null;
+ }
+
+ @Override
+ public void removeContentTypeChangeListener(IContentTypeChangeListener listener) {
+
+ }
+
+ @Override
+ public IContentType addContentType(String contentTypeIdentifier, String name, IContentType baseType)
+ throws CoreException {
+ return null;
+ }
+
+ @Override
+ public void removeContentType(String contentTypeIdentifier) throws CoreException {}
+
+}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/NoDebugging.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/NoDebugging.java
new file mode 100644
index 0000000000..095be889e9
--- /dev/null
+++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/NoDebugging.java
@@ -0,0 +1,87 @@
+/*
+ * 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.service;
+
+import java.io.File;
+import java.util.Map;
+
+import org.eclipse.osgi.service.debug.DebugOptions;
+import org.eclipse.osgi.service.debug.DebugTrace;
+
+/** No debugging shall be performed */
+public class NoDebugging implements DebugOptions {
+
+ @Override
+ public boolean getBooleanOption(String option, boolean defaultValue) {
+ return false;
+ }
+
+ @Override
+ public String getOption(String option) {
+ return null;
+ }
+
+ @Override
+ public String getOption(String option, String defaultValue) {
+ return null;
+ }
+
+ @Override
+ public int getIntegerOption(String option, int defaultValue) {
+ return 0;
+ }
+
+ @Override
+ public Map void add(Class interfaceClass, S service);
+
+ /**
+ * Spotless formatters should not be configured by environment variables, and
+ * they shall be OS independent.
+ */
+ default public void hideEnvironment() {
+ 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.
+ */
+ default public void ignoreContentType() {
+ add(IContentTypeManager.class, new NoContentTypeSpecificHandling());
+ }
+
+ /** Disable Eclipse internal debugging. */
+ default public void disableDebugging() {
+ add(DebugOptions.class, new NoDebugging());
+ }
+
+ /** Ignore accesses of unsupported preference. */
+ default public void ignoreUnsupportedPreferences() {
+ 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.
+ */
+ default public void useTemporaryLocations() {
+ 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.
+ */
+ default public void changeSystemLineSeparator() {
+ System.setProperty("line.separator", LINE_DELIMITER);
+ }
+
+ /** Applies the default configurations. */
+ default public void applyDefault() {
+ 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
new file mode 100644
index 0000000000..90bfafc8e4
--- /dev/null
+++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleConfig.java
@@ -0,0 +1,95 @@
+/*
+ * 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 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 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
+ * 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
new file mode 100644
index 0000000000..59e15929fd
--- /dev/null
+++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleSet.java
@@ -0,0 +1,71 @@
+/*
+ * 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 void add(Class interfaceClass, S service) {
+ 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);
+ }
+ }
+
+ /** Creates filter object suitable to lookup service by its interface name. */
+ Filter createFilter(String filterDescr) {
+ Optional 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;
+ }
+
+ }
+
+ /**
+ * Class name based service filter
+ * ServiceRegistration registerService(Class clazz, S service, Dictionary ServiceRegistration registerService(Class clazz, ServiceFactory factory, Dictionary ServiceReference getServiceReference(Class clazz) {
+ Objects.requireNonNull(clazz, "The class under whose name the service was registered must not be null.");
+ return (ServiceReference) getServiceReference(clazz.getName());
+ }
+
+ @Override
+ default public ServiceReference> getServiceReference(String clazz) {
+ Objects.requireNonNull(clazz, "The class under whose name the service was registered must not be null.");
+ ServiceReference>[] references;
+ try {
+ references = getServiceReferences(clazz, null);
+ } catch (InvalidSyntaxException e) {
+ throw new RuntimeException(e); //null is always valid
+ }
+ return (null == references) ? null : references[0];
+ }
+
+ @Override
+ default public ServiceReference>[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
+ return getAllServiceReferences(clazz, filter); //Services are always considered compatible
+ }
+
+ @Override
+ default public ServiceReference>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
+ //Filters are based on class names
+ ServiceReference> reference = (null == clazz) ? getServiceReference(filter) : getServiceReference(clazz);
+ return (reference == null) ? null : new ServiceReference>[]{reference};
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ default public Collection clazz, String filter) throws InvalidSyntaxException {
+ ServiceReference>[] references = getServiceReferences(clazz.getName(), filter);
+ Collection) r).collect(Collectors.toList());
+ }
+ return result;
+ }
+
+ @Override
+ default public boolean ungetService(ServiceReference> reference) {
+ return true; //Services are persistent and never unregistered
+ }
+
+ @Override
+ @Deprecated
+ default public ServiceObjects getServiceObjects(ServiceReference reference) {
+ throw new UnsupportedOperationException("Service specific objects are not supported.");
+ }
+
+ @Override
+ @Deprecated
+ default public File getDataFile(String filename) {
+ throw new UnsupportedOperationException("Persistent data storage provision is handled by the Location service.");
+ }
+
+}
diff --git a/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/TemporaryBundle.java b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/TemporaryBundle.java
new file mode 100644
index 0000000000..24cfadc8c2
--- /dev/null
+++ b/_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/TemporaryBundle.java
@@ -0,0 +1,107 @@
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.security.cert.X509Certificate;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * Temporary bundle loaded by common class loader and added temporarily.
+ * It shall not be recognized as a Eclipse plugin (providing plugin.xml)
+ * but as a mere OSGI bundle.
+ *