diff --git a/CHANGELOG.md b/CHANGELOG.md index 43098447..91ddeab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ FlatLaf Change Log other themes. - IntelliJ Themes: Material UI Lite themes did not work when using [IntelliJ Themes Pack](flatlaf-intellij-themes) addon. (PR #88, issue #89) +- IntelliJ Themes: Added Java 9 module descriptor to + `flatlaf-intellij-themes-.jar`. ## 0.32 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java index decacbf7..ce866526 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/IntelliJTheme.java @@ -86,7 +86,7 @@ public class IntelliJTheme * Using a buffered input stream is not necessary. */ public static FlatLaf createLaf( InputStream in ) - throws IOException, ParseException + throws IOException { return createLaf( new IntelliJTheme( in ) ); } @@ -106,11 +106,13 @@ public class IntelliJTheme */ @SuppressWarnings( "unchecked" ) public IntelliJTheme( InputStream in ) - throws IOException, ParseException + throws IOException { Map json; try( Reader reader = new InputStreamReader( in, StandardCharsets.UTF_8 ) ) { json = (Map) Json.parse( reader ); + } catch( ParseException ex ) { + throw new IOException( ex.getMessage(), ex ); } name = (String) json.get( "name" ); diff --git a/flatlaf-intellij-themes/build.gradle.kts b/flatlaf-intellij-themes/build.gradle.kts index 5e35d531..bc8e3839 100644 --- a/flatlaf-intellij-themes/build.gradle.kts +++ b/flatlaf-intellij-themes/build.gradle.kts @@ -25,6 +25,18 @@ dependencies { implementation( project( ":flatlaf-core" ) ) } +if( JavaVersion.current() >= JavaVersion.VERSION_1_9 ) { + sourceSets { + create( "module-info" ) { + java { + // include "src/main/java" here to get compile errors if classes are + // used from other modules that are not specified in module dependencies + setSrcDirs( listOf( "src/main/module-info", "src/main/java" ) ) + } + } + } +} + tasks { assemble { dependsOn( @@ -33,6 +45,26 @@ tasks { ) } + if( JavaVersion.current() >= JavaVersion.VERSION_1_9 ) { + named( "compileModuleInfoJava" ) { + sourceCompatibility = "9" + targetCompatibility = "9" + + dependsOn( ":flatlaf-core:jar" ) + + options.compilerArgs.add( "--module-path" ) + options.compilerArgs.add( project( ":flatlaf-core" ).tasks["jar"].outputs.files.asPath ) + } + } + + jar { + if( JavaVersion.current() >= JavaVersion.VERSION_1_9 ) { + from( sourceSets["module-info"].output ) { + include( "module-info.class" ) + } + } + } + javadoc { options { this as StandardJavadocDocletOptions diff --git a/flatlaf-intellij-themes/src/main/java/com/formdev/flatlaf/intellijthemes/Utils.java b/flatlaf-intellij-themes/src/main/java/com/formdev/flatlaf/intellijthemes/Utils.java index 61c5c664..0392cd94 100644 --- a/flatlaf-intellij-themes/src/main/java/com/formdev/flatlaf/intellijthemes/Utils.java +++ b/flatlaf-intellij-themes/src/main/java/com/formdev/flatlaf/intellijthemes/Utils.java @@ -21,7 +21,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.IntelliJTheme; -import com.formdev.flatlaf.json.ParseException; /** * @author Karl Tauber @@ -34,7 +33,7 @@ class Utils try { return new IntelliJTheme( Utils.class.getResourceAsStream( "/com/formdev/flatlaf/intellijthemes/themes/" + name ) ); - } catch( ParseException | IOException ex ) { + } catch( IOException ex ) { String msg = "FlatLaf: Failed to load IntelliJ theme '" + name + "'"; LOG.log( Level.SEVERE, msg, ex ); throw new RuntimeException( msg, ex ); diff --git a/flatlaf-intellij-themes/src/main/java/com/formdev/flatlaf/intellijthemes/materialthemeuilite/Utils.java b/flatlaf-intellij-themes/src/main/java/com/formdev/flatlaf/intellijthemes/materialthemeuilite/Utils.java index fa577e8c..f5523cca 100644 --- a/flatlaf-intellij-themes/src/main/java/com/formdev/flatlaf/intellijthemes/materialthemeuilite/Utils.java +++ b/flatlaf-intellij-themes/src/main/java/com/formdev/flatlaf/intellijthemes/materialthemeuilite/Utils.java @@ -21,7 +21,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.formdev.flatlaf.FlatLaf; import com.formdev.flatlaf.IntelliJTheme; -import com.formdev.flatlaf.json.ParseException; /** * @author Karl Tauber @@ -34,7 +33,7 @@ class Utils try { return new IntelliJTheme( Utils.class.getResourceAsStream( "/com/formdev/flatlaf/intellijthemes/themes/material-theme-ui-lite/" + name ) ); - } catch( ParseException | IOException ex ) { + } catch( IOException ex ) { String msg = "FlatLaf: Failed to load IntelliJ theme '" + name + "'"; LOG.log( Level.SEVERE, msg, ex ); throw new RuntimeException( msg, ex ); diff --git a/flatlaf-intellij-themes/src/main/module-info/module-info.java b/flatlaf-intellij-themes/src/main/module-info/module-info.java new file mode 100644 index 00000000..c6c87c20 --- /dev/null +++ b/flatlaf-intellij-themes/src/main/module-info/module-info.java @@ -0,0 +1,27 @@ +/* + * Copyright 2020 FormDev Software GmbH + * + * 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 + * + * https://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. + */ + +/** + * @author Karl Tauber + */ +module com.formdev.flatlaf.intellijthemes { + requires java.desktop; + requires java.logging; + requires com.formdev.flatlaf; + + exports com.formdev.flatlaf.intellijthemes; + exports com.formdev.flatlaf.intellijthemes.materialthemeuilite; +}