Skip to content

Commit

Permalink
Merge pull request #378 from diffplug/eclipse-wtp-upgrade
Browse files Browse the repository at this point in the history
Switch to Eclipse-WTP 3.10. Cleanup fix for #369. Add SLF4J support.
  • Loading branch information
nedtwigg authored Mar 17, 2019
2 parents 21fca9f + 14252be commit e0d1bb6
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class EclipseJdtFormatterStepImpl {

public EclipseJdtFormatterStepImpl(Properties settings) throws Exception {
SpotlessEclipseFramework.setup(
config -> {
config.applyDefault();
config.useSlf4J(EclipseJdtFormatterStepImpl.class.getPackage().getName());
},
plugins -> {
plugins.applyDefault();
plugins.add(new JavaCore());
Expand Down
11 changes: 8 additions & 3 deletions _ext/eclipse-wtp/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# spotless-eclipse-wtp

### Version 3.9.8 - March 10th 2018 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-wtp)))
### Version 3.10.0 - March 17th 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-wtp)))

* Switch to Eclipse WTP release 3.10.0 for Eclipse 4.8 ([#378](https://github.com/diffplug/spotless/pull/378)).
* Include Eclipse logging allowing formatter warnings/errors to be logged via SLF4J ([#236](https://github.com/diffplug/spotless/issues/236)).

### Version 3.9.8 - March 10th 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-wtp)))

* XML formatter ignores external URIs per default. ([#369](https://github.com/diffplug/spotless/issues/369)). Add `resolveExternalURI=true` property to switch to previous behavior.

### Version 3.9.7 - February 25th 2018 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-wtp)))
### Version 3.9.7 - February 25th 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-wtp)))

* Replaced `http` update-site with `https` ([#360](https://github.com/diffplug/spotless/issues/360)).

### Version 3.9.6 - February 10th 2018 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-wtp)))
### Version 3.9.6 - February 11th 2019 ([artifact]([jcenter](https://bintray.com/diffplug/opensource/spotless-eclipse-wtp)))

* Fixed formatting of JSON arrays ([#344](https://github.com/diffplug/spotless/issues/344)).

Expand Down
2 changes: 2 additions & 0 deletions _ext/eclipse-wtp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ dependencies {
compile "org.eclipse.platform:org.eclipse.core.filesystem:${VER_ECLISPE_EFS}"
// Required by org.eclipse.wst.xsd.core
compile "org.eclipse.xsd:org.eclipse.xsd:${VER_ECLISPE_XSD}"

testCompile("org.slf4j:slf4j-simple:${VER_SLF4J}")
}

jar {
Expand Down
11 changes: 7 additions & 4 deletions _ext/eclipse-wtp/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Versions correspond to the Eclipse-WTP version used for the fat-JAR.
# See https://www.eclipse.org/webtools/ for further information about Eclipse-WTP versions.
# Patch version can be incremented independently for backward compatible patches of this library.
ext_version=3.9.8
ext_version=3.10.0
ext_artifactId=spotless-eclipse-wtp
ext_description=Eclipse's WTP formatters bundled for Spotless

Expand All @@ -12,11 +12,14 @@ ext_group=com.diffplug.spotless
ext_VER_JAVA=1.8

# Compile
VER_ECLIPSE_WTP=oxygen
VER_SPOTLESS_ECLISPE_BASE=[3.0.0,4.0.0[
VER_ECLIPSE_WTP=photon
VER_SPOTLESS_ECLISPE_BASE=[3.1.0,4.0.0[
VER_IBM_ICU=[61,62[
VER_ECLISPE_EMF=[2.12.0,3.0.0[
VER_ECLISPE_PLATFORM=[3.6.0,4.0.0[
VER_ECLISPE_JFACE=[3.12.0,4.0.0[
VER_ECLISPE_EFS=[1.6.0,2.0.0[
VER_ECLISPE_XSD=[2.12.0,3.0.0[
VER_ECLISPE_XSD=[2.12.0,3.0.0[

# Provided dependencies
VER_SLF4J=[1.6,2.0[
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.diffplug.spotless.extra.eclipse.wtp.html.JsRegionProcessor;
import com.diffplug.spotless.extra.eclipse.wtp.html.StructuredDocumentProcessor;
import com.diffplug.spotless.extra.eclipse.wtp.sse.CleanupStep;
import com.diffplug.spotless.extra.eclipse.wtp.sse.PreventExternalURIResolverExtension;
import com.diffplug.spotless.extra.eclipse.wtp.sse.SpotlessPreferences;

/** Formatter step which calls out to the Eclipse HTML cleanup and formatter. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public class EclipseJsFormatterStepImpl {
public EclipseJsFormatterStepImpl(Properties properties) throws Exception {
SpotlessEclipseFramework.setup(
JS_CORE_CONFIG,
config -> config.applyDefault(),
config -> {
config.applyDefault();
config.useSlf4J(this.getClass().getPackage().getName());
},
plugins -> {
plugins.applyDefault();
// The JS core uses EFS for determination of temporary storage location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.osgi.framework.BundleException;

import com.diffplug.spotless.extra.eclipse.base.SpotlessEclipseFramework;
import com.diffplug.spotless.extra.eclipse.wtp.sse.PreventExternalURIResolverExtension;
import com.diffplug.spotless.extra.eclipse.wtp.sse.SpotlessPreferences;

/** Formatter step which calls out to the Eclipse XML formatter. */
Expand All @@ -58,7 +59,8 @@ public class EclipseXmlFormatterStepImpl {
private final INodeAdapterFactory xmlAdapterFactory;

public EclipseXmlFormatterStepImpl(Properties properties) throws Exception {
setupFramework(SpotlessPreferences.doResolveExternalURI(properties));
boolean resolveExternalURI = Boolean.parseBoolean(properties.getProperty(SpotlessPreferences.RESOLVE_EXTERNAL_URI, "false"));
setupFramework(resolveExternalURI);
preferences = PREFERENCE_FACTORY.create(properties);
formatter = new DefaultXMLPartitionFormatter();
//The adapter factory maintains the common CMDocumentCache
Expand All @@ -67,6 +69,10 @@ public EclipseXmlFormatterStepImpl(Properties properties) throws Exception {

private static void setupFramework(boolean resolveExternalURI) throws BundleException {
if (SpotlessEclipseFramework.setup(
config -> {
config.applyDefault();
config.useSlf4J(EclipseXmlFormatterStepImpl.class.getPackage().getName());
},
plugins -> {
plugins.applyDefault();
//The WST XML formatter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ protected CleanupStep(T processor, Consumer<SpotlessEclipseCoreConfig> core, Con
config.add(IContentTypeManager.class, new ContentTypeManager(processor));
//The preference lookup via the ContentTypeManager, requires a preference service
config.add(IPreferencesService.class, PreferencesService.getDefault());
config.useSlf4J(this.getClass().getPackage().getName());
},
plugins -> {
plugins.applyDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.diffplug.spotless.extra.eclipse.wtp;
package com.diffplug.spotless.extra.eclipse.wtp.sse;

import org.eclipse.core.resources.IFile;
import org.eclipse.emf.common.util.URI;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,6 @@ public static Properties configurePluginPreferences(Plugin plugin, Properties ne
return oldValues;
}

public static boolean doResolveExternalURI(Properties properties) {
Object obj = properties.get(RESOLVE_EXTERNAL_URI);
if (null != obj) {
if (obj instanceof Boolean) {
return (Boolean) obj;
}
if (obj instanceof String) {
return ((String) obj).equalsIgnoreCase("true");
}
}
return false;
}

public static void configureCatalog(final Properties config) {
Optional<File> catalog = getCatalogConfig(config);
Catalog defaultCatalog = getDefaultCatalog();
Expand Down
2 changes: 1 addition & 1 deletion _ext/eclipse-wtp/src/main/resources/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- "low priority' might be missleading. In fact the result of this extension overrules all other -->
<!-- physical resolvers with higher priority. -->
<extension point="org.eclipse.wst.common.uriresolver.resolverExtensions">
<resolverExtension stage="physical" priority="low" class="com.diffplug.spotless.extra.eclipse.wtp.PreventExternalURIResolverExtension">
<resolverExtension stage="physical" priority="low" class="com.diffplug.spotless.extra.eclipse.wtp.sse.PreventExternalURIResolverExtension">
</resolverExtension>
</extension>
</plugin>

0 comments on commit e0d1bb6

Please sign in to comment.