Browse Source

Require Java 17

Keeping support for Java 8 only results in headaches.
master
Jannis Weis 1 year ago
parent
commit
8638d9d0bd
No known key found for this signature in database
GPG Key ID: 7C9D8D4B558049AB
  1. 1
      annotations-processor/build.gradle.kts
  2. 1
      annotations/build.gradle.kts
  3. 12
      build.gradle.kts
  4. 4
      buildSrc/build.gradle.kts
  5. 10
      compatibility/build.gradle.kts
  6. 54
      compatibility/src/main/java/com/github/weisj/darklaf/compatibility/SwingUtil.java
  7. 13
      core/build.gradle.kts
  8. 1
      iconset/build.gradle.kts
  9. 19
      macos/build.gradle.kts
  10. 1
      native-utils/build.gradle.kts
  11. 1
      platform-base/build.gradle.kts
  12. 1
      platform-decorations/build.gradle.kts
  13. 1
      platform-preferences/build.gradle.kts
  14. 1
      property-loader/build.gradle.kts
  15. 1
      theme-spec/build.gradle.kts
  16. 1
      theme/build.gradle.kts
  17. 1
      utils/build.gradle.kts
  18. 7
      windows/build.gradle.kts

1
annotations-processor/build.gradle.kts

@ -1,6 +1,5 @@
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }
dependencies { dependencies {

1
annotations/build.gradle.kts

@ -1,6 +1,5 @@
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }
dependencies { dependencies {

12
build.gradle.kts

@ -172,8 +172,8 @@ allprojects {
plugins.withType<JavaPlugin> { plugins.withType<JavaPlugin> {
configure<JavaPluginExtension> { configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_17
withSourcesJar() withSourcesJar()
if (!skipJavadoc && isRelease) { if (!skipJavadoc && isRelease) {
withJavadocJar() withJavadocJar()
@ -271,14 +271,6 @@ allprojects {
withType<Javadoc>().configureEach { withType<Javadoc>().configureEach {
(options as StandardJavadocDocletOptions).apply { (options as StandardJavadocDocletOptions).apply {
// -add-exports requires target 9
// The library is built with target=1.8, so add-exports
if (project.the<JavaPluginExtension>().targetCompatibility.isJava9Compatible) {
addStringOption("-add-exports", "java.desktop/sun.swing=ALL-UNNAMED")
addStringOption("-add-exports", "java.desktop/sun.awt=ALL-UNNAMED")
addStringOption("-add-exports", "java.desktop/com.sun.java.swing=ALL-UNNAMED")
addStringOption("-add-exports", "java.desktop/sun.awt.shell=ALL-UNNAMED")
}
quiet() quiet()
locale = "en" locale = "en"
docEncoding = "UTF-8" docEncoding = "UTF-8"

4
buildSrc/build.gradle.kts

@ -28,9 +28,5 @@ gradlePlugin {
id = "apple-m1-toolchain" id = "apple-m1-toolchain"
implementationClass = "AppleM1ToolChainRule" implementationClass = "AppleM1ToolChainRule"
} }
create("module-info-compile") {
id = "module-info-compile"
implementationClass = "ModuleInfoCompilePlugin"
}
} }
} }

10
compatibility/build.gradle.kts

@ -3,19 +3,9 @@ import com.github.vlsi.gradle.crlf.LineEndings
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
id("com.github.vlsi.crlf") id("com.github.vlsi.crlf")
} }
configure<ModuleInfoExtension> {
version = JavaVersion.VERSION_11
extraArgs = listOf(
"--add-exports",
"java.desktop/sun.awt=darklaf.compatibility"
)
stubModule("darklaf.core")
}
dependencies { dependencies {
implementation(projects.darklafUtils) implementation(projects.darklafUtils)
implementation(projects.darklafPlatformBase) implementation(projects.darklafPlatformBase)

54
compatibility/src/main/java/com/github/weisj/darklaf/compatibility/SwingUtil.java

@ -1,7 +1,7 @@
/* /*
* MIT License * MIT License
* *
* Copyright (c) 2019-2022 Jannis Weis * Copyright (c) 2019-2023 Jannis Weis
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, * associated documentation files (the "Software"), to deal in the Software without restriction,
@ -31,9 +31,6 @@ import java.awt.Toolkit;
import java.awt.Window; import java.awt.Window;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -48,9 +45,9 @@ import javax.swing.plaf.synth.SynthContext;
import javax.swing.plaf.synth.SynthGraphicsUtils; import javax.swing.plaf.synth.SynthGraphicsUtils;
import javax.swing.plaf.synth.SynthStyle; import javax.swing.plaf.synth.SynthStyle;
import jdk.swing.interop.SwingInterOpUtils;
import com.github.weisj.darklaf.platform.SystemInfo; import com.github.weisj.darklaf.platform.SystemInfo;
import com.github.weisj.darklaf.util.Lambdas;
import com.github.weisj.darklaf.util.LazyValue;
import com.github.weisj.darklaf.util.LogUtil; import com.github.weisj.darklaf.util.LogUtil;
import com.intellij.util.ui.UIUtilities; import com.intellij.util.ui.UIUtilities;
@ -62,31 +59,12 @@ public final class SwingUtil {
private SwingUtil() {} private SwingUtil() {}
private static boolean swingInteropAvailable;
private static Class<?> swingInteropClass;
private static final LazyValue<MethodHandle> grabMethod = new LazyValue<>(
Lambdas.orDefault(() -> MethodHandles.lookup().findStatic(swingInteropClass, "grab",
MethodType.methodType(void.class, Toolkit.class, Window.class)), null));
private static final LazyValue<MethodHandle> ungrabMethod = new LazyValue<>(
Lambdas.orDefault(() -> MethodHandles.lookup().findStatic(swingInteropClass, "ungrab",
MethodType.methodType(void.class, Toolkit.class, Window.class)), null));
static {
try {
swingInteropClass = Class.forName("jdk.swing.interop.SwingInterOpUtils");
swingInteropAvailable = true;
} catch (Throwable e) {
swingInteropAvailable = false;
}
LOGGER.fine("SwingInterOpUtils available: " + swingInteropAvailable);
}
public static boolean isSunToolkit(final Toolkit toolkit) { public static boolean isSunToolkit(final Toolkit toolkit) {
return toolkit != null && isInstanceOf(toolkit.getClass(), "sun.awt.SunToolkit"); return toolkit != null && isInstanceOf(toolkit.getClass(), "sun.awt.SunToolkit");
} }
public static boolean isUngrabEvent(final AWTEvent event) { public static boolean isUngrabEvent(final AWTEvent event) {
return event != null && isInstanceOf(event.getClass(), "sun.awt.UngrabEvent"); return SwingInterOpUtils.isUngrabEvent(event);
} }
private static boolean isInstanceOf(final Class<?> cls, final String type) { private static boolean isInstanceOf(final Class<?> cls, final String type) {
@ -99,31 +77,11 @@ public final class SwingUtil {
} }
public static void grab(final Toolkit toolkit, final Window window) { public static void grab(final Toolkit toolkit, final Window window) {
if (swingInteropAvailable) { SwingInterOpUtils.grab(toolkit, window);
try {
grabMethod.get().invokeExact(toolkit, window);
} catch (Throwable e) {
throw new RuntimeException(e);
}
} else {
if (toolkit instanceof sun.awt.SunToolkit) {
((sun.awt.SunToolkit) toolkit).grab(window);
}
}
} }
public static void ungrab(final Toolkit toolkit, final Window window) { public static void ungrab(final Toolkit toolkit, final Window window) {
if (swingInteropAvailable) { SwingInterOpUtils.ungrab(toolkit, window);
try {
ungrabMethod.get().invokeExact(toolkit, window);
} catch (Throwable e) {
throw new RuntimeException(e);
}
} else {
if (toolkit instanceof sun.awt.SunToolkit) {
((sun.awt.SunToolkit) toolkit).ungrab(window);
}
}
} }
public static void drawStringUnderlineCharAt(final JComponent c, final Graphics g, public static void drawStringUnderlineCharAt(final JComponent c, final Graphics g,

13
core/build.gradle.kts

@ -4,7 +4,6 @@ import com.github.vlsi.gradle.properties.dsl.props
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
id("com.github.vlsi.crlf") id("com.github.vlsi.crlf")
} }
@ -41,12 +40,12 @@ dependencies {
testCompileOnly(libs.nullabilityAnnotations) testCompileOnly(libs.nullabilityAnnotations)
} }
moduleInfo { // moduleInfo {
modularExec { // modularExec {
addExports.add("java.desktop/com.sun.java.swing=darklaf.core") // addExports.add("java.desktop/com.sun.java.swing=darklaf.core")
openTestPackagesTo("darklaf.properties") // openTestPackagesTo("darklaf.properties")
} // }
} // }
tasks.test { tasks.test {
doFirst { doFirst {

1
iconset/build.gradle.kts

@ -3,7 +3,6 @@ import com.github.vlsi.gradle.crlf.LineEndings
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
id("com.github.vlsi.crlf") id("com.github.vlsi.crlf")
} }

19
macos/build.gradle.kts

@ -1,6 +1,5 @@
plugins { plugins {
java java
`module-info-compile`
id("dev.nokee.jni-library") id("dev.nokee.jni-library")
id("dev.nokee.objective-cpp-language") id("dev.nokee.objective-cpp-language")
`uber-jni-jar` `uber-jni-jar`
@ -8,12 +7,6 @@ plugins {
`apple-m1-toolchain` `apple-m1-toolchain`
} }
moduleInfo {
stubModule("darklaf.core")
stubModule("darklaf.platform.preferences")
stubModule("darklaf.platform.decorations")
}
val nativeResourcePath = "com/github/weisj/darklaf/platform/${project.name}" val nativeResourcePath = "com/github/weisj/darklaf/platform/${project.name}"
library { library {
@ -22,8 +15,8 @@ library {
jvmImplementation(projects.darklafUtils) jvmImplementation(projects.darklafUtils)
jvmImplementation(projects.darklafNativeUtils) jvmImplementation(projects.darklafNativeUtils)
jvmImplementation(projects.darklafPlatformBase) jvmImplementation(projects.darklafPlatformBase)
nativeLibImplementation(macOsFrameworks.appKit) // nativeLibImplementation(macOsFrameworks.appKit)
nativeLibImplementation(macOsFrameworks.cocoa) // nativeLibImplementation(macOsFrameworks.cocoa)
} }
targetMachines.addAll(machines.macOS.x86_64, machines.macOS.architecture("arm64")) targetMachines.addAll(machines.macOS.x86_64, machines.macOS.architecture("arm64"))
@ -40,9 +33,11 @@ library {
linkTask.configure { linkTask.configure {
linkerArgs.addAll( linkerArgs.addAll(
"-lobjc", "-lobjc",
"-mmacosx-version-min=$minOs" "-mmacosx-version-min=$minOs",
// "-framework", "AppKit", "-framework",
// "-framework", "Cocoa", "AppKit",
"-framework",
"Cocoa"
) )
} }
} }

1
native-utils/build.gradle.kts

@ -3,7 +3,6 @@ import com.github.vlsi.gradle.crlf.LineEndings
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }
tasks.jar { tasks.jar {

1
platform-base/build.gradle.kts

@ -1,4 +1,3 @@
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }

1
platform-decorations/build.gradle.kts

@ -1,6 +1,5 @@
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }
dependencies { dependencies {

1
platform-preferences/build.gradle.kts

@ -1,6 +1,5 @@
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }
dependencies { dependencies {

1
property-loader/build.gradle.kts

@ -1,6 +1,5 @@
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }
dependencies { dependencies {

1
theme-spec/build.gradle.kts

@ -1,4 +1,3 @@
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }

1
theme/build.gradle.kts

@ -1,6 +1,5 @@
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }
dependencies { dependencies {

1
utils/build.gradle.kts

@ -1,6 +1,5 @@
plugins { plugins {
`java-library` `java-library`
`module-info-compile`
} }
dependencies { dependencies {

7
windows/build.gradle.kts

@ -1,18 +1,11 @@
plugins { plugins {
java java
`module-info-compile`
id("dev.nokee.jni-library") id("dev.nokee.jni-library")
id("dev.nokee.cpp-language") id("dev.nokee.cpp-language")
`uber-jni-jar` `uber-jni-jar`
`use-prebuilt-binaries` `use-prebuilt-binaries`
} }
moduleInfo {
stubModule("darklaf.core")
stubModule("darklaf.platform.preferences")
stubModule("darklaf.platform.decorations")
}
library { library {
dependencies { dependencies {
jvmImplementation(projects.darklafNativeUtils) jvmImplementation(projects.darklafNativeUtils)

Loading…
Cancel
Save