diff --git a/CHANGELOG.md b/CHANGELOG.md index eece0303..ad5be9ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,16 @@ FlatLaf Change Log - macOS: Support larger window title bar close/minimize/zoom buttons spacing in [full window content](https://www.formdev.com/flatlaf/macos/#full_window_content) mode and introduced "buttons placeholder". (PR #779) -- Native libraries: System property `flatlaf.nativeLibraryPath` now supports - loading native libraries named the same as on Maven central. Improved log - messages for loading fails. +- Native libraries: + - System property `flatlaf.nativeLibraryPath` now supports loading native + libraries named the same as on Maven central. + - Published `flatlaf--no-natives.jar` to Maven Central. This JAR is + equal to `flatlaf-.jar`, except that it does not contain the + FlatLaf native libraries. The Maven "classifier" to use this JAR is + `no-natives`. You need to distribute the FlatLaf native libraries with your + application. + See https://www.formdev.com/flatlaf/native-libraries/ for more details. + - Improved log messages for loading fails. - Fonts: Updated **Inter** to [v4.0](https://github.com/rsms/inter/releases/tag/v4.0). diff --git a/flatlaf-core/build.gradle.kts b/flatlaf-core/build.gradle.kts index eca0e2dd..da5c7ecc 100644 --- a/flatlaf-core/build.gradle.kts +++ b/flatlaf-core/build.gradle.kts @@ -61,6 +61,23 @@ tasks { archiveBaseName.set( "flatlaf" ) } + register( "jarNoNatives" ) { + group = "build" + dependsOn( "jar" ) + + archiveBaseName.set( "flatlaf" ) + archiveClassifier.set( "no-natives" ) + archiveExtension.set( "jar" ) + destinationDirectory = layout.buildDirectory.dir( "libs" ) + + from( zipTree( jar.get().archiveFile.get().asFile ) ) + exclude( "com/formdev/flatlaf/natives/**" ) + } + + withType().configureEach { + dependsOn( "jarNoNatives" ) + } + check { dependsOn( "sigtestCheck" ) } @@ -127,6 +144,8 @@ flatlafPublish { val natives = "src/main/resources/com/formdev/flatlaf/natives" nativeArtifacts = listOf( + NativeArtifact( tasks.getByName( "jarNoNatives" ).outputs.files.asPath, "no-natives", "jar" ), + NativeArtifact( "${natives}/flatlaf-windows-x86.dll", "windows-x86", "dll" ), NativeArtifact( "${natives}/flatlaf-windows-x86_64.dll", "windows-x86_64", "dll" ), NativeArtifact( "${natives}/flatlaf-windows-arm64.dll", "windows-arm64", "dll" ), diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLibrary.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLibrary.java index 2ca2de5c..9c57aba7 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLibrary.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatNativeLibrary.java @@ -22,6 +22,7 @@ import java.security.CodeSource; import com.formdev.flatlaf.FlatSystemProperties; import com.formdev.flatlaf.util.LoggingFacade; import com.formdev.flatlaf.util.NativeLibrary; +import com.formdev.flatlaf.util.StringUtils; import com.formdev.flatlaf.util.SystemInfo; /** @@ -224,6 +225,10 @@ class FlatNativeLibrary private static String buildLibraryName( File jarFile, String classifier, String ext ) { String jarName = jarFile.getName(); String jarBasename = jarName.substring( 0, jarName.lastIndexOf( '.' ) ); + + // remove classifier "no-natives" (if used) + jarBasename = StringUtils.removeTrailing( jarBasename, "-no-natives" ); + return jarBasename + (jarBasename.contains( "flatlaf" ) ? "" : "-flatlaf") + '-' + classifier + '.' + ext;