diff --git a/core/ikonli-core/src/main/java/module-info.java b/core/ikonli-core/src/main/java/module-info.java index 5afb6b43a..7e010dcd3 100644 --- a/core/ikonli-core/src/main/java/module-info.java +++ b/core/ikonli-core/src/main/java/module-info.java @@ -21,6 +21,8 @@ requires static org.kordamp.jipsy.annotations; requires java.logging; + uses org.kordamp.ikonli.IkonHandler; + provides org.kordamp.ikonli.IkonHandler with org.kordamp.ikonli.IkonliIkonResolver; provides org.kordamp.ikonli.IkonProvider diff --git a/core/ikonli-core/src/main/java/org/kordamp/ikonli/AbstractIkonResolver.java b/core/ikonli-core/src/main/java/org/kordamp/ikonli/AbstractIkonResolver.java index b9ed86a40..5bea3578c 100644 --- a/core/ikonli-core/src/main/java/org/kordamp/ikonli/AbstractIkonResolver.java +++ b/core/ikonli-core/src/main/java/org/kordamp/ikonli/AbstractIkonResolver.java @@ -19,6 +19,7 @@ import java.util.Arrays; import java.util.LinkedHashSet; +import java.util.ServiceLoader; import java.util.Set; import java.util.logging.Logger; @@ -94,4 +95,23 @@ private void throwOrWarn(String message) { private boolean strictChecksEnabled() { return System.getProperty(ORG_KORDAMP_IKONLI_STRICT) == null || Boolean.getBoolean(ORG_KORDAMP_IKONLI_STRICT); } + + public static ServiceLoader resolveServiceLoader() { + // Check if handlers must be loaded from a ModuleLayer + if (null != IkonHandler.class.getModule().getLayer()) { + ServiceLoader handlers = ServiceLoader.load(IkonHandler.class.getModule().getLayer(), IkonHandler.class); + if (handlers.stream().count() > 0) { + return handlers; + } + } + + // Check if the IkonHandler.class.classLoader works + ServiceLoader handlers = ServiceLoader.load(IkonHandler.class, IkonHandler.class.getClassLoader()); + if (handlers.stream().count() > 0) { + return handlers; + } + + // If *nothing* else works + return ServiceLoader.load(IkonHandler.class); + } } diff --git a/core/ikonli-javafx/src/main/java/module-info.java b/core/ikonli-javafx/src/main/java/module-info.java index a32dbf32b..f70411fe9 100644 --- a/core/ikonli-javafx/src/main/java/module-info.java +++ b/core/ikonli-javafx/src/main/java/module-info.java @@ -23,6 +23,4 @@ requires javafx.base; requires javafx.graphics; requires javafx.controls; - - uses org.kordamp.ikonli.IkonHandler; } \ No newline at end of file diff --git a/core/ikonli-javafx/src/main/java/org/kordamp/ikonli/javafx/IkonResolver.java b/core/ikonli-javafx/src/main/java/org/kordamp/ikonli/javafx/IkonResolver.java index f2df89875..d12ebdae2 100644 --- a/core/ikonli-javafx/src/main/java/org/kordamp/ikonli/javafx/IkonResolver.java +++ b/core/ikonli-javafx/src/main/java/org/kordamp/ikonli/javafx/IkonResolver.java @@ -43,13 +43,6 @@ private IkonResolver() { } - private static ServiceLoader resolveServiceLoader() { - if (null != IkonHandler.class.getModule().getLayer()) { - return ServiceLoader.load(IkonHandler.class.getModule().getLayer(), IkonHandler.class); - } - return ServiceLoader.load(IkonHandler.class); - } - public static IkonResolver getInstance() { return INSTANCE; } diff --git a/core/ikonli-swing/src/main/java/module-info.java b/core/ikonli-swing/src/main/java/module-info.java index 4faf46a18..9f74337d5 100644 --- a/core/ikonli-swing/src/main/java/module-info.java +++ b/core/ikonli-swing/src/main/java/module-info.java @@ -16,8 +16,9 @@ * limitations under the License. */ module org.kordamp.ikonli.swing { + exports org.kordamp.ikonli.swing; + requires org.kordamp.ikonli.core; + requires java.desktop; - uses org.kordamp.ikonli.IkonHandler; - exports org.kordamp.ikonli.swing; } \ No newline at end of file diff --git a/core/ikonli-swing/src/main/java/org/kordamp/ikonli/swing/IkonResolver.java b/core/ikonli-swing/src/main/java/org/kordamp/ikonli/swing/IkonResolver.java index edd966e9d..074e0e147 100644 --- a/core/ikonli-swing/src/main/java/org/kordamp/ikonli/swing/IkonResolver.java +++ b/core/ikonli-swing/src/main/java/org/kordamp/ikonli/swing/IkonResolver.java @@ -54,13 +54,6 @@ private IkonResolver() { } - private static ServiceLoader resolveServiceLoader() { - if (null != IkonHandler.class.getModule().getLayer()) { - return ServiceLoader.load(IkonHandler.class.getModule().getLayer(), IkonHandler.class); - } - return ServiceLoader.load(IkonHandler.class); - } - public static IkonResolver getInstance() { return INSTANCE; } diff --git a/gradle.properties b/gradle.properties index be8f615ff..a4b988537 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ # ikonliJdk8Version = 2.6.0 -version = 12.0.0 +version = 12.0.1-SNAPSHOT group = org.kordamp.ikonli sourceCompatibility = 11