Skip to content

Commit

Permalink
Adpated package names according to previous commit. Applied fixes as …
Browse files Browse the repository at this point in the history
…requested in #234. Refactored artifact name and version as discussed in #226.
  • Loading branch information
fvgh committed Apr 28, 2018
1 parent 8a4ecee commit e4e8fd2
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 39 deletions.
7 changes: 5 additions & 2 deletions _ext/eclipse-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ The `com.diffplug.gradle.spotless:spotless-eclipse-base` artifact mocks the redu

## Usage

Include the artifact to your Spotless Eclipse formatter project, whereas the minor/major version must match the Eclipse version your formatter supports. The exact default version should be selected by the **lib-extra**. Patch versions are backward compatible.
Include the artifact to your Spotless Eclipse formatter project, whereas 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-ext-eclipse-base:4.7.+"
compile "com.diffplug.spotless:spotless-eclipse-base:3.+"
}
```

Expand Down
9 changes: 5 additions & 4 deletions _ext/eclipse-base/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Mayor/Minor versions correspond to the minimum Eclipse version supported/tested.
# Patch version is incremented for backward compatible patches of this library.
ext_version=4.7.0-SNAPSHOT
ext_artifactId=spotless-ext-eclipse-base
# 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
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.gradle.spotless.eclipse;
package com.diffplug.spotless.extra.eclipse.base;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
Expand All @@ -30,8 +30,8 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleException;

import com.diffplug.gradle.spotless.eclipse.osgi.BundleController;
import com.diffplug.gradle.spotless.eclipse.runtime.PluginRegistrar;
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 {
Expand Down Expand Up @@ -131,7 +131,7 @@ public synchronized static boolean setup() throws BundleException {
* @return False if the SpotlessEclipseFramework instance already exists, true otherwise.
* @throws BundleException Throws exception in case the setup failed.
*/
public synchronized static boolean setup(final Consumer<Collection<BundleActivator>> plugins) throws BundleException {
public synchronized static boolean setup(Consumer<Collection<BundleActivator>> plugins) throws BundleException {
return setup(config -> config.applyDefault(), plugins);
}

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.gradle.spotless.eclipse;
package com.diffplug.spotless.extra.eclipse.base;

import java.util.Map;

Expand All @@ -23,7 +23,7 @@
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.environment.EnvironmentInfo;

import com.diffplug.gradle.spotless.eclipse.service.*;
import com.diffplug.spotless.extra.eclipse.base.service.*;

/**
* Configuration/Provision of services which shall be provided by the SpotlessEclipseFramework.
Expand All @@ -34,6 +34,9 @@
*/
public interface SpotlessEclipseServiceConfig {

/** Spotless always uses \n internally as line delimiter */
public static final String LINE_DELIMITER = "\n";

/** Sets property/preference value available to all bundles, plugins and services. */
void set(String key, String value);

Expand Down Expand Up @@ -90,12 +93,24 @@ 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();
}
}
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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -260,14 +260,11 @@ private static BundleFile getBundlFile(Object obj) throws BundleException {
if (!(jarOrDirectory.exists() && jarOrDirectory.canRead())) {
throw new BundleException(String.format("Path '%s' for '%s' is not accessible exist on local file system.", objUrl, obj.getClass().getName()), BundleException.READ_ERROR);
}
BundleFile bundleFile = null;
try {
bundleFile = jarOrDirectory.isDirectory() ? new DirBundleFile(jarOrDirectory, false) : new ZipBundleFile(jarOrDirectory, null, null, null);
return jarOrDirectory.isDirectory() ? new DirBundleFile(jarOrDirectory, false) : new ZipBundleFile(jarOrDirectory, null, null, null);
} catch (IOException e) {
throw new BundleException(String.format("Cannot access bundle at '%s'.", jarOrDirectory), BundleException.READ_ERROR);
}
return bundleFile;

}

}
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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import java.util.Collection;
import java.util.Map;
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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import org.osgi.framework.Bundle;
import org.osgi.service.packageadmin.ExportedPackage;
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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import java.util.Collection;
import java.util.Dictionary;
Expand All @@ -26,7 +26,7 @@
import org.osgi.framework.ServiceException;
import org.osgi.framework.ServiceReference;

import com.diffplug.gradle.spotless.eclipse.SpotlessEclipseServiceConfig;
import com.diffplug.spotless.extra.eclipse.base.SpotlessEclipseServiceConfig;

/**
* Collection of services.
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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import java.io.InputStream;

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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import java.io.File;
import java.io.InputStream;
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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/
/** Simplified OSGIi implementation bypassing Equinox module layer. */
package com.diffplug.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
* Please refer to the eclipse-base README.md for usage instructions.
*/
@ParametersAreNonnullByDefault
package com.diffplug.gradle.spotless.eclipse;
package com.diffplug.spotless.extra.eclipse.base;

import javax.annotation.ParametersAreNonnullByDefault;
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.gradle.spotless.eclipse.runtime;
package com.diffplug.spotless.extra.eclipse.base.runtime;

import java.io.IOException;
import java.io.InputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
/**
* Eclipse Core Runtime adapters allowing runtime modifications which normally requires an Eclipse restart.
*/
package com.diffplug.gradle.spotless.eclipse.runtime;
package com.diffplug.spotless.extra.eclipse.base.runtime;
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.gradle.spotless.eclipse.service;
package com.diffplug.spotless.extra.eclipse.base.service;

import java.util.Locale;

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.gradle.spotless.eclipse.service;
package com.diffplug.spotless.extra.eclipse.base.service;

import java.io.IOException;
import java.io.InputStream;
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.gradle.spotless.eclipse.service;
package com.diffplug.spotless.extra.eclipse.base.service;

import java.io.File;
import java.util.Map;
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.gradle.spotless.eclipse.service;
package com.diffplug.spotless.extra.eclipse.base.service;

import java.io.InputStream;
import java.io.OutputStream;
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.gradle.spotless.eclipse.service;
package com.diffplug.spotless.extra.eclipse.base.service;

import java.io.IOError;
import java.io.IOException;
Expand All @@ -27,7 +27,7 @@

/** All files generated at runtime are stored in a temporary location. */
public class TemporaryLocation implements Location {
private static final String TEMP_PREFIX = "com_diffplug_gradle_spotless";
private static final String TEMP_PREFIX = "com_diffplug_spotless_extra_eclipse";
private final URL location;
private Location parent;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
* limitations under the License.
*/
/** Mocking Eclipse Equinox OSGi services. */
package com.diffplug.gradle.spotless.eclipse.service;
package com.diffplug.spotless.extra.eclipse.base.service;
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.gradle.spotless.eclipse;
package com.diffplug.spotless.extra.eclipse.base;

import org.junit.Test;
import org.osgi.framework.BundleException;
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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.*;
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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import static org.assertj.core.api.Assertions.assertThat;

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.gradle.spotless.eclipse.osgi;
package com.diffplug.spotless.extra.eclipse.base.osgi;

import java.io.File;
import java.io.IOException;
Expand Down

0 comments on commit e4e8fd2

Please sign in to comment.