mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-09 15:17:24 -05:00
* Add dark mode toggle under User Preferences > Application
- Add darkMode boolean preference to ApplicationPreference (persisted via java.util.prefs)
- Add ToggleSwitch labeled "Dark Mode" to ApplicationPreferenceEditor
- Add ThemeManager singleton that listens for preference updates and applies/removes
the dark stylesheet to all registered JavaFX Scenes and swaps the Swing LAF
- Add sdrtrunk_dark.css with dark styling for controls, tables, menus, dialogs, charts
- Add FlatLaf dependency for full Swing dark theming (replaces previous OS-specific
MetalLookAndFeel setup; FlatLaf works cross-platform)
- Register all Stages created in JavaFxWindowManager with the ThemeManager and walk
Window.getWindows() at apply-time so unregistered dialogs/alerts also pick up the theme
- Add Foojay toolchain resolver to settings.gradle so Gradle can auto-provision JDK 25
* Fix dark-mode startup failures on Linux
- Apply Swing LAF synchronously on the calling thread so the main JFrame's RootPane
has a populated UIDefaults set when constructed. Previously the LAF install was
scheduled via EventQueue.invokeLater, so JFrame construction raced ahead and threw
"no ComponentUI class for: javax.swing.JPanel".
- Call LookAndFeelFactory.installJideExtension(VSNET_STYLE) with an explicit style
instead of the no-arg auto-detection variant. The auto-detection path probes
com.sun.java.swing.plaf.windows.WindowsLookAndFeel via Class.forName, which is
absent on non-Windows JDKs and threw ClassNotFoundException at startup.
- Bounce only the SwingUtilities.updateComponentTreeUI walk through the EDT so it
redraws already-realized windows on theme toggle.
* Fix JIDE/Windows-LookAndFeel crash on non-Windows JDKs
JIDE 3.6.18's LookAndFeelFactory contains compile-time
\`instanceof com.sun.java.swing.plaf.windows.WindowsLookAndFeel\` checks in
multiple methods, including a JIDE PropertyChangeListener that fires on every
UIManager.setLookAndFeel call. On Linux and macOS JDKs the class is genuinely
absent from java.desktop, so the JVM throws NoClassDefFoundError the first time
JIDE's dispatch code is executed (during JFrame init and again from
JideSplitPane.updateUI on each LAF change).
Two complementary fixes:
1. Pass an explicit MetalLookAndFeel instance to the 3-arg
installJideExtension(UIDefaults, LookAndFeel, int) overload so JIDE's Metal
branch matches first and never falls through to the Windows branch in the
normal install path.
2. Add a no-op stub class at com.sun.java.swing.plaf.windows.WindowsLookAndFeel
so that the compile-time class reference resolves on non-Windows JDKs. The
stub reports isSupportedLookAndFeel = false and is never instantiated -
JIDE only uses it for instanceof comparisons against the active LAF, which
always return false in our setup. On Windows JDKs the real class in
java.desktop is loaded by the platform classloader and shadows this stub.
* Re-apply FlatLaf defaults after JIDE install + strengthen FX borders
Symptom: With dark mode enabled, the Swing main window's spectrum chrome and
menu bar were dark (FlatLaf) but tables, tabbed panes and the inner content
area were light/Metal coloured.
Root cause: LookAndFeelFactory.installJideExtension installs JIDE's
Metal-flavored UI defaults (VsnetMetalUtils etc.) into the live UIDefaults
table, overwriting FlatLaf's standard component colors and fonts for keys
like Table.background, TabbedPane.foreground, Panel.background.
Fix: After the JIDE install, walk a fresh FlatLaf UIDefaults table and put
every key back into the active defaults, skipping anything Jide-prefixed.
JIDE's UI delegate registrations live under Jide* keys that FlatLaf does
not define, so they survive untouched while the standard Swing color and
font keys are restored to their dark equivalents.
Also strengthen the JavaFX dark stylesheet: explicit borders on text fields,
tables, titled panes, split-pane dividers and separators so components have
more defining outlines in dark mode.
* Force-override Swing foreground colors via UIManager user-defaults layer
Symptom: With dark mode enabled the inner Swing content area now had dark
panels (good) but tab labels, table cells, status-bar labels and button
text were rendering nearly black-on-dark (bad).
Root cause: UIManager.getLookAndFeelDefaults() lookups for FlatLaf's
component foreground keys still resolve to Metal-era dark values after the
JIDE install + FlatLaf re-apply, because some FlatLaf keys are derived /
LazyValue and recompute against state that JIDE seeded.
Fix: After the bulk FlatLaf-defaults copy, explicitly UIManager.put the
foreground / background / selection / disabled / border colors for every
standard Swing component family. UIManager.put writes to the user-defaults
layer that takes precedence over the LAF defaults, so these overrides win
regardless of what JIDE or derived-value resolution produces.
Also bump the JavaFX dark stylesheet text colour from #d6d6d6 to #ececec so
labels read closer to white on the dark panels.
* Theme JIDE-specific UIManager keys so JideTabbedPane reads dark colors
The Now Playing / Map / Tuners / Playlist Editor / Details / Events /
Messages / Channel tabs are JIDE JideTabbedPane components and their UI
delegate reads JideTabbedPane.* UIManager keys, not the standard
TabbedPane.* keys. The previous overrides only set the standard keys so
the tabs were still rendering with JIDE's Metal-era dark foreground on
the now-dark background.
Override the JIDE-specific text foreground keys
(JideTabbedPane.foreground, .selectedTabTextForeground,
.unselectedTabTextForeground, .activeTabTextForeground) along with the
matching background and shadow keys. Also theme JideSplitPane,
JideButton and JideLabel keys for consistency.
* Remove hardcoded Color.BLACK foreground on JideTabbedPanes
ControllerPanel.getTabbedPane() and NowPlayingPanel.getTabbedPane() each
called setForeground(Color.BLACK) on their JideTabbedPane instances.
Color.BLACK is a plain java.awt.Color, not a ColorUIResource, so it is
never replaced by LookAndFeel.installColorsAndFont() on subsequent UI
installs - it permanently pins the tab labels to black regardless of any
JIDE or FlatLaf defaults the theme manager sets. In dark mode this leaves
the tab labels black-on-dark and unreadable.
Drop the explicit foreground calls so the LAF (JideTabbedPaneUI reading
JideTabbedPane.foreground / .unselectedTabTextForeground /
.selectedTabTextForeground / .activeTabTextForeground) drives the colour
in both light and dark modes.
* Register Channel tab's JFXPanel scenes with the ThemeManager
The Channel tab embeds two JavaFX scenes inside Swing via JFXPanel: the
noise squelch chart (NoiseSquelchView) and the symbol view. Neither was
registered with the ThemeManager, so the dark stylesheet was never applied
to them. In dark mode the chart legend, axis area and surrounding panel
rendered with JavaFX's default light Modena styling against the otherwise
dark UI.
JFXPanel-hosted scenes are invisible to javafx.stage.Window.getWindows(),
so the theme manager cannot find them automatically on toggle - they have
to be explicitly registered at creation time, the same as the JavaFX
Stages JavaFxWindowManager already registers.
* Use ColorUIResource for theme overrides + brighten chart series colors
Toggle-off problem: applyExplicitOverrides was storing plain java.awt.Color
values via UIManager.put. LookAndFeel.installColorsAndFont only replaces a
component's existing colour when it is null or an instance of UIResource -
plain Colors are not, so once a component picked up its dark colour it kept
that colour for the rest of the JVM lifetime even after toggling back to
light mode. Switching every override to ColorUIResource lets subsequent
updateComponentTreeUI calls replace the cached colour cleanly.
Chart visibility: the JavaFX charts on the Channel tab (NoiseSquelchView)
were inheriting Modena's default 8-colour series palette, which has several
hues that read poorly against a dark plot background. The existing
sdrtrunk_style.css also hardcodes .chart-symbol to solid black. Override
.default-color0..7.chart-series-line and matching .chart-line-symbol selectors
with a brighter high-contrast palette, darken the plot background to #1c1c1c
for stronger contrast against the grid lines, and add explicit colours for
axis tick marks, alternate row fills and legend border.
* Use primary foreground for selected tab text instead of selection foreground
The previous overrides set JideTabbedPane.selectedTabTextForeground and
TabbedPane.selectedForeground to fgSelection (always white). Selected tabs
render on the raised surface (bgRaised) which is white in light mode, so
white-on-white made selected tab labels invisible.
Selected tabs are not list/table row selections that use the blue
bgSelection background - they sit on the same raised tone as other surfaces.
Use fgPrimary so the text is dark on the light raised surface in light mode
and light on the dark raised surface in dark mode.
* Brighten chart data points to solid white in dark mode
* Restore default chart symbol size, only override colour
* Refresh detached Channel-tab swing components on theme toggle
The Channel tab swaps one of three right-pane components into its
JSplitPane depending on the active decoder type: SignalPowerView for AM,
the NoiseSquelchPanel JFXPanel for NBFM, the SymbolPanel JFXPanel for
feedback decoders. Only one is attached at any moment - the other two
are detached references on the ChannelSpectrumPanel.
SwingUtilities.updateComponentTreeUI(Window) during a theme toggle walks
only the currently-realized component trees, so the detached swappables
miss the refresh and carry stale colours from the LAF that was active
when they were last attached. Swapping back in then shows e.g. an AM
SignalPowerView in dark colours after a light-mode toggle.
Add ThemeManager.registerSwing(Component) tracking, walk those refs on
every toggle, and register the three swappables when constructed.
* Add preset themes selector under User Preferences > Application
Replace the single Dark Mode toggle with a curated selection of 9 preset
themes, exposed as a vertical radio-button group:
Light IntelliJ Nord
Dark Darcula Dracula
Solarized Light Solarized Dark Monokai Pro
Each Theme enum value pairs a human-readable display name with a FlatLaf
class name and a dark flag. The first four come from the core flatlaf
dependency; the others come from flatlaf-intellij-themes which is added
as a new implementation dependency (~1MB).
ApplicationPreference now stores the selected theme by enum name under
the new ui.theme key. isDarkMode() is retained as a compatibility shim
that delegates to the current theme. Existing users with the legacy
dark.mode boolean are auto-migrated on first read.
ThemeManager is refactored to drive the LAF from the Theme:
- Reflectively instantiates the FlatLaf class.
- Reads Panel.background, Button.background, TextField.background,
List.selectionBackground/Foreground, Label.foreground/disabledForeground,
Component.borderColor and Table.alternateRowColor from UIManager *after*
FlatLaf installs, then seeds those values into the JIDE-specific keys.
Each theme automatically contributes its own palette to JIDE widgets
without per-theme hardcoded colours.
ApplicationPreferenceEditor swaps the ToggleSwitch for a ToggleGroup of
RadioButtons that persist the selection through ApplicationPreference.setTheme.
* Fix theme switching past first toggle + move Themes to Appearance sub-page
Critical regression in 56b0f6c9: applyExplicitOverrides reads colours via
UIManager.getColor(...) which consults the merged defaults (user defaults
overlay LAF defaults). After the first apply our own UIManager.put calls
populate the user-defaults layer, so subsequent reads return our previous
theme's colours instead of the newly-installed LAF's colours. The result:
the first theme switch works, every switch after that silently re-applies
the previous palette and the UI appears frozen on the first picked theme.
Switch every palette read to UIManager.getLookAndFeelDefaults().getColor(...)
which is the LAF-only layer and ignores the user-defaults overlay we wrote.
Also:
- Move the Themes selector to its own sub-node:
User Preferences > Application > Appearance
PreferenceEditorType gets a new APPEARANCE entry, the existing APPLICATION
leaf is relabelled "General" so the tree no longer reads "Application >
Application > Application". New AppearancePreferenceEditor hosts the theme
radio group; ApplicationPreferenceEditor loses it.
- Replace a few hardcoded label foregrounds that read as
invisible-on-dark-bg with LAF-driven equivalents:
TunerViewPanel TunerStatus.DISABLED: DARK_GRAY -> Label.disabledForeground
BroadcastStatusPanel DISABLED state: LIGHT_GRAY -> Label.disabledForeground
JFrequencyControl Digit mouseExited: Color.WHITE -> TextField.background
Semantic colour usage (RED/YELLOW for error and warning states, the
audio-panel hardware-style black backgrounds) is intentionally kept.
* Auto-theme every JavaFX window so transient dialogs follow the theme
The Playlist Editor's main Scene is already registered with the ThemeManager,
but the many Alert / TextInputDialog / RadioReferenceUnavailableAlert popups
it spawns each create a fresh Stage with a fresh Scene that nothing registers.
Once one is shown after a theme switch it renders with default Modena styling
on top of an otherwise themed app.
Install a ListChangeListener on javafx.stage.Window.getWindows() at startup.
Every newly-added Window is themed immediately if its Scene is set, otherwise
a one-shot sceneProperty listener applies the theme the moment the Scene is
attached. Already-open windows at install time are also walked once.
This removes the need to manually register every transient dialog and covers
the playlist editor, alias editor confirmations, broadcastify error alerts,
channel-map editor warnings, and any future ad-hoc Alert / Dialog the
codebase grows.
* Curate themes to 8 modern variants + per-theme JavaFX accent colours
Theme set is trimmed and refocused:
Drop: IntelliJ (too similar to Light), FlatDarculaLaf (duplicates Dracula),
Monokai Pro (low identity in this app).
Add: Material Deep Ocean (vibrant teal dark), Arc Dark (flat modern dark).
Keep: Light, Dark, Nord, Dracula (FlatDraculaIJTheme - the one user liked),
Solarized Light, Solarized Dark.
Each theme now contributes its own accent palette to the JavaFX panels too,
not just the Swing chrome. ThemeManager builds a small per-theme stylesheet
at apply time by reading the FlatLaf-installed colours (Panel.background,
TextField.background, Component.accentColor, List.selectionBackground/Foreground,
Label.foreground, Component.borderColor, Table.alternateRowColor) and
substituting them into Modena's core variables (-fx-base, -fx-accent,
-fx-selection-bar, -fx-control-inner-background, etc.) plus a handful of
explicit rules for table selection rows, default button, scroll bar thumb.
The generated CSS is attached to every registered Scene as a data: URL, so
Nord reads blue-tinted, Dracula purple-tinted, Solarized cream/teal,
Material Deep Ocean dark teal, Arc Dark cool gray. The static
sdrtrunk_dark.css remains as the structural baseline for all dark themes.
* Add GUI scale slider under Appearance preferences
New slider in User Preferences > Application > Appearance lets users zoom
the whole UI between 50% and 200% in 10% increments. The value is
persisted as a new ApplicationPreference (ui.gui.scale, default 1.0,
bounded 0.5-2.0) and applied immediately on slider release - intermediate
drag positions do not trigger a re-apply so the LAF reinstall cost is
paid once at the end of the drag.
Swing side: ThemeManager sets the flatlaf.uiScale system property before
each setLookAndFeel call, so the new FlatLaf instance picks up the user's
zoom on initialise. All component sizes (fonts, padding, icons) scale
together because FlatLaf does the math internally.
JavaFX side: the per-theme accent stylesheet emits an
.root { -fx-font-size: <12 * scale>px; }
rule. Modena's component sizes are em-relative so cascading the font
size scales the JavaFX panels in sync with the Swing chrome.
The onPreferenceUpdated guard now compares both theme and scale, so
moving only the slider still triggers a re-apply. A Reset button next
to the slider returns to 100%.
393 lines
16 KiB
Groovy
393 lines
16 KiB
Groovy
/*
|
|
* *****************************************************************************
|
|
* Copyright (C) 2014-2026 Dennis Sheirer
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
* ****************************************************************************
|
|
*/
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
|
|
|
|
/**
|
|
* Instructions for building/compiling the sdrtrunk application.
|
|
*
|
|
* Prerequisites:
|
|
* Install and configure an OpenJDK version 22+ that includes the JavaFX modules (e.g. Bellsoft Liberica JDK)
|
|
* - Optional: install and configure Gradle 8.10+
|
|
*
|
|
* Scenario 1: run the application via gradle command line from the source code root directory:
|
|
* command: ./gradlew run
|
|
*
|
|
* Scenario 2: create an application release for the current operating system
|
|
* command: ./gradlew runtimeZipCurrent
|
|
* Note: release image is located in the /build/image/ directory
|
|
*
|
|
* Scenario 3: create releases for Linux and OSX operating systems using downloaded JDKs
|
|
* command: ./gradlew runtimeZipOthers
|
|
* Note: release images are located in the /build/image/ directory
|
|
*
|
|
* Scenario 4: create release for Windows operating system using downloaded JDK
|
|
* command: ./gradlew runtimeZipWindows
|
|
* Note: release image is located in the /build/image/ directory
|
|
*/
|
|
plugins {
|
|
id 'application'
|
|
id 'java'
|
|
id 'idea'
|
|
id 'org.beryx.runtime' version '2.0.1'
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
maven { url = "https://jitpack.io" }
|
|
}
|
|
|
|
//Version is defined in gradle.properties so that we can CLI override it for nightly builds.
|
|
version = project.findProperty('projectVersion')
|
|
|
|
//Java 24 is required for this version of the Project Panama preview/incubator feature
|
|
java {
|
|
toolchain {
|
|
languageVersion = JavaLanguageVersion.of(25)
|
|
vendor = JvmVendorSpec.BELLSOFT
|
|
}
|
|
}
|
|
|
|
test {
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
dependencies {
|
|
|
|
// JUnit Tests
|
|
testImplementation(platform("org.junit:junit-bom:6.0.1"))
|
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:6.0.1'
|
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:6.0.1")
|
|
testRuntimeOnly("org.junit.vintage:junit-vintage-engine:6.0.1")
|
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
|
|
//Jitpack imports
|
|
implementation 'com.github.dnault:libresample4j:master'
|
|
implementation 'com.github.DSheirer.jmbe:jmbe-api:1.0.0'
|
|
implementation 'com.github.nwaldispuehl:java-lame:v3.98.4'
|
|
|
|
//mavenCentral/jcenter imports
|
|
implementation 'ch.qos.logback:logback-classic:1.5.21'
|
|
implementation 'ch.qos.logback:logback-core:1.5.21'
|
|
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.20.1'
|
|
implementation 'com.fazecast:jSerialComm:2.11.4'
|
|
implementation 'com.formdev:flatlaf:3.5.4'
|
|
implementation 'com.formdev:flatlaf-intellij-themes:3.5.4'
|
|
implementation 'com.github.jiconfont:jiconfont-font_awesome:4.7.0.1'
|
|
implementation 'com.github.jiconfont:jiconfont-javafx:1.0.0'
|
|
implementation 'com.github.jiconfont:jiconfont-swing:1.0.1'
|
|
implementation 'com.github.wendykierp:JTransforms:3.1'
|
|
implementation 'com.google.code.gson:gson:2.13.2'
|
|
implementation 'com.google.guava:guava:33.5.0-jre'
|
|
implementation 'com.jidesoft:jide-oss:3.6.18'
|
|
implementation 'com.miglayout:miglayout-swing:11.4.2'
|
|
implementation 'com.mpatric:mp3agic:0.9.1'
|
|
implementation 'commons-io:commons-io:2.21.0'
|
|
implementation 'eu.hansolo:charts:1.0.5'
|
|
implementation 'io.github.dsheirer:radio-reference-api:18.0.0'
|
|
implementation 'io.github.dsheirer:usb4java-native-libraries:1.3.3' //OSX & Windows aarch64 native libs
|
|
implementation 'io.github.dsheirer:usb4java:1.3.5' //Fork with Loader support for OSX Multi-Version
|
|
implementation 'javax.usb:usb-api:1.0.2'
|
|
implementation 'net.coderazzi:tablefilter-swing:5.5.4'
|
|
implementation 'org.apache.commons:commons-compress:1.28.0'
|
|
implementation 'org.apache.commons:commons-lang3:3.19.0'
|
|
implementation 'org.apache.commons:commons-math3:3.6.1'
|
|
implementation 'org.apache.commons:commons-csv:1.14.1'
|
|
implementation 'org.apache.mina:mina-core:2.2.4'
|
|
implementation 'org.apache.mina:mina-http:2.2.4'
|
|
implementation 'org.controlsfx:controlsfx:11.2.2'
|
|
implementation 'org.rauschig:jarchivelib:1.2.0'
|
|
implementation 'org.slf4j:slf4j-api:2.0.17'
|
|
implementation 'org.usb4java:libusb4java:1.3.0'
|
|
implementation 'org.usb4java:usb4java-javax:1.3.0'
|
|
implementation 'pl.edu.icm:JLargeArrays:1.6'
|
|
}
|
|
|
|
def os = org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.currentOperatingSystem
|
|
|
|
/**
|
|
* This is needed for the JDK23 vector API ... until it moves out of incubation or preview
|
|
*/
|
|
tasks.withType(JavaCompile) {
|
|
options.compilerArgs.add("--enable-preview") //Project Panama Vector API is still in incubator
|
|
options.compilerArgs.add("--add-modules=jdk.incubator.vector") //Project Panama Vector API is still in incubator
|
|
}
|
|
|
|
/**
|
|
* JVM Arguments for running the application on Windows.
|
|
*/
|
|
def jvmArgsWindows =
|
|
['--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED', //Needed for controls-fx.jar
|
|
'--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED', //windows users for JIDE
|
|
'--add-modules=jdk.incubator.vector', //Project Panama vector API is still in incubator
|
|
'--enable-preview', //Project Panama Vector API is still in incubator
|
|
'--enable-native-access=ALL-UNNAMED', //Suppress unsafe warnings for FFM API Foreign Memory calls
|
|
'--enable-native-access=javafx.graphics', //JDK24 - suppress restricted java.lang.System calls
|
|
'--sun-misc-unsafe-memory-access=allow', //JDK24 - suppress sun.misc.Unsafe::allocateMemory warning
|
|
'-XX:+UseCompactObjectHeaders', //JDK25 - use compact object headers
|
|
'-Djava.library.path=c:\\Program Files\\SDRplay\\API\\x64'] //SDRPlay API library path
|
|
|
|
/**
|
|
* JVM Arguments for running the application on Linux.
|
|
*/
|
|
def jvmArgsLinux =
|
|
['--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED', //Needed for controls-fx.jar
|
|
'--add-modules=jdk.incubator.vector', //Project Panama vector API is still in incubator
|
|
'--enable-preview', //Project Panama Vector & Foreign Function APIs remain in incubator
|
|
'--sun-misc-unsafe-memory-access=allow', //JDK24 - suppress sun.misc.Unsafe::allocateMemory warning
|
|
'-XX:+UseCompactObjectHeaders', //JDK25 - use compact object headers
|
|
'--enable-native-access=javafx.graphics', //JDK24 - suppress restricted java.lang.System calls
|
|
'--enable-native-access=ALL-UNNAMED'] //SDRPlay API library path
|
|
|
|
application {
|
|
mainClass = "io.github.dsheirer.gui.SDRTrunk"
|
|
|
|
if(os.isWindows()) {
|
|
applicationDefaultJvmArgs = jvmArgsWindows
|
|
}
|
|
else {
|
|
applicationDefaultJvmArgs = jvmArgsLinux
|
|
}
|
|
}
|
|
|
|
test {
|
|
if(os.isWindows()) {
|
|
jvmArgs = jvmArgsWindows
|
|
}
|
|
else {
|
|
jvmArgs = jvmArgsLinux
|
|
}
|
|
}
|
|
|
|
jar {
|
|
manifest {
|
|
attributes (
|
|
'Implementation-Title' : 'sdrtrunk project',
|
|
'Implementation-Version' : archiveVersion,
|
|
'Created-By' : "Gradle ${gradle.gradleVersion}",
|
|
'Build-Timestamp' : new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
|
|
'Build-JDK' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']}",
|
|
'Build-OS' : "${System.properties['os.name']} (${System.properties['os.arch']} ${System.properties['os.version']}"
|
|
)
|
|
}
|
|
}
|
|
|
|
idea {
|
|
module {
|
|
downloadJavadoc = true
|
|
downloadSources = true
|
|
}
|
|
}
|
|
|
|
javadoc {
|
|
options.addStringOption('-add-modules', 'jdk.incubator.vector')
|
|
options.addStringOption('Xdoclint:none', '-quiet')
|
|
}
|
|
|
|
/**
|
|
* Runtime target OS and CPU image names. We append version here so that version details are at end of zip filename.
|
|
*/
|
|
String targetLinuxAarch64 = 'linux-aarch64-v' + version
|
|
String targetLinuxX86_64 = 'linux-x86_64-v' + version
|
|
String targetOsxAarch64 = 'osx-aarch64-v' + version
|
|
String targetOsxX86_64 = 'osx-x86_64-v' + version
|
|
String targetWindowsX86_64 = 'windows-x86_64-v' + version
|
|
String targetWindowsAarch64 = 'windows-aarch64-v' + version
|
|
|
|
/**
|
|
* Optional pre-downloaded Java Development Kit (JDK) for each target OS and CPU. These locations are hard-coded to the
|
|
* author's development environment, but can be changed to your environment if you want to use this build pattern.
|
|
*/
|
|
String jdk_base = '/home/denny/java_jdks/'
|
|
String jdk_linux_aarch64 = jdk_base + 'linux-arm64/jdk-25.0.1-full'
|
|
String jdk_linux_x86_64 = jdk_base + 'linux-x64/jdk-25.0.1-full'
|
|
String jdk_osx_x86_64 = jdk_base + 'osx-x64/jdk-25.0.1-full.jdk'
|
|
String jdk_osx_aarch64 = jdk_base + 'osx-arm64/jdk-25.0.1-full.jdk'
|
|
String jdk_windows_x86_64 = jdk_base + 'windows-x64/jdk-25.0.1-full'
|
|
String jdk_windows_aarch64 = jdk_base + 'windows-arm64/jdk-25.0.1-full'
|
|
|
|
/**
|
|
* Download URLs to download the JDK as part of the gradle build packaging process
|
|
*/
|
|
def jdk_download_base = "https://download.bell-sw.com/java/25.0.1+11/bellsoft-jdk25.0.1+11-"
|
|
def jdk_download_suffix = "-full.tar.gz"
|
|
def jdk_download_linux_aarch64 = jdk_download_base + "linux-aarch64" + jdk_download_suffix
|
|
def jdk_download_linux_x86_64 = jdk_download_base + "linux-amd64" + jdk_download_suffix
|
|
def jdk_download_osx_x86_64 = jdk_download_base + "macos-amd64" + jdk_download_suffix
|
|
def jdk_download_osx_aarch64 = jdk_download_base + "macos-aarch64" + jdk_download_suffix
|
|
def jdk_download_windows_x86_64 = jdk_download_base + "windows-amd64-full.zip"
|
|
def jdk_download_windows_aarch64 = jdk_download_base + "windows-aarch64-full.zip"
|
|
|
|
/**
|
|
* Configures the runtime zip task with additional options/settings.
|
|
* @param rt task to configure
|
|
* @param jvmArgs to use (windows or linux)
|
|
* @return configured task.
|
|
*/
|
|
def configure(org.beryx.runtime.RuntimeZipTask rt, List<String> jvmArgs) {
|
|
//Use the correct set of JVM arguments
|
|
rt.extension.launcherData.get().jvmArgs = jvmArgs
|
|
|
|
//Additional modules to include with auto-detected modules.
|
|
//jdk.charsets - NXDN BIG5 encoding support
|
|
//jdk.crypto.ec - needed for HTTPS connections (broadcastify calls & map tile server)
|
|
//jdk.incubator.vector - needed for Project Panama foreign function and vector apis
|
|
//jdk.accessibility is used with assistive technologies like screen readers
|
|
//java.management for JVM resource monitoring
|
|
rt.extension.addModules('jdk.charsets', 'jdk.crypto.ec', 'jdk.incubator.vector', 'jdk.accessibility', 'java.management')
|
|
|
|
//Use auto-detected modules and 'add' any specified modules.
|
|
rt.extension.additive.set(true)
|
|
|
|
//Recommended options for reducing/shrinking runtime target image size
|
|
rt.extension.addOptions('--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages')
|
|
|
|
//Runtime images have auto appended version in image zip name. Override to include version in single target image.
|
|
rt.extension.imageZip.set(file("$buildDir/image/sdr-trunk.zip"))
|
|
}
|
|
|
|
/**
|
|
* Creates a release package for the current operating system.
|
|
*
|
|
* Note: you cannot create both Windows and Linux releases at the same time due to limitations of the Runtime plugin
|
|
*
|
|
* Usage: gradle runtimeZipCurrent
|
|
* Usage: gradlew runtimeZipCurrent (windows - using gradlew)
|
|
* Usage: ./gradlew runtimeZipCurrent (linux - using gradlew)
|
|
*/
|
|
tasks.register('runtimeZipCurrent', org.beryx.runtime.RuntimeZipTask) {rt ->
|
|
def arch = System.properties.getProperty("os.arch")
|
|
def javaHome = org.gradle.internal.jvm.Jvm.current().getJavaHome().toString()
|
|
|
|
if(os.isWindows()) {
|
|
if(arch.equals("amd64")) {
|
|
rt.extension.targetPlatform(targetWindowsX86_64, javaHome)
|
|
}
|
|
else if(arch.equals("aarch64")) {
|
|
rt.extension.targetPlatform(targetWindowsAarch64, javaHome)
|
|
}
|
|
configure(rt, jvmArgsWindows)
|
|
}
|
|
else if(os.isLinux())
|
|
{
|
|
if(arch.equals("amd64")) {
|
|
rt.extension.targetPlatform(targetLinuxX86_64, javaHome)
|
|
}
|
|
else if(arch.equals("aarch64")) {
|
|
rt.extension.targetPlatform(targetLinuxAarch64, javaHome)
|
|
}
|
|
configure(rt, jvmArgsLinux)
|
|
}
|
|
else if(os.isMacOsX())
|
|
{
|
|
if(arch.equals("amd64")) {
|
|
rt.extension.targetPlatform(targetOsxX86_64, javaHome)
|
|
}
|
|
else if(arch.equals("aarch64")) {
|
|
rt.extension.targetPlatform(targetOsxAarch64, javaHome)
|
|
}
|
|
configure(rt, jvmArgsLinux)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Creates a Windows release package.
|
|
*
|
|
* Note: you cannot create both Windows and Linux releases at the same time due to limitations of the Runtime plugin
|
|
*
|
|
* Usage: gradle runtimeZipWindows
|
|
* Usage: gradlew runtimeZipWindows (windows - using gradlew)
|
|
* Usage: ./gradlew runtimeZipWindows (linux - using gradlew)
|
|
*/
|
|
tasks.register('runtimeZipWindows', org.beryx.runtime.RuntimeZipTask) {rt ->
|
|
//Windows aarch64
|
|
if(file(jdk_windows_aarch64).exists()) {
|
|
rt.extension.targetPlatform(targetWindowsAarch64, jdk_windows_aarch64, [])
|
|
}
|
|
else {
|
|
rt.extension.targetPlatform(targetWindowsAarch64) {
|
|
jdkHome = jdkDownload(jdk_download_windows_aarch64)
|
|
}
|
|
}
|
|
//Windows x86-64
|
|
if(file(jdk_windows_x86_64).exists()) {
|
|
rt.extension.targetPlatform(targetWindowsX86_64, jdk_windows_x86_64, [])
|
|
}
|
|
else {
|
|
rt.extension.targetPlatform(targetWindowsX86_64) {
|
|
jdkHome = jdkDownload(jdk_download_windows_x86_64)
|
|
}
|
|
}
|
|
|
|
configure(rt, jvmArgsWindows)
|
|
}
|
|
|
|
/**
|
|
* Creates Linux & OSX release packages.
|
|
*
|
|
* Note: you cannot create both Windows and Linux releases at the same time due to limitations of the Runtime plugin
|
|
*
|
|
* Usage: gradle runtimeZipOthers
|
|
* Usage: gradlew runtimeZipOthers (windows - using gradlew)
|
|
* Usage: ./gradlew runtimeZipOthers (linux - using gradlew)
|
|
*/
|
|
tasks.register('runtimeZipOthers', org.beryx.runtime.RuntimeZipTask) {rt ->
|
|
//Linux aarch64
|
|
if(file(jdk_linux_aarch64).exists()) {
|
|
rt.extension.targetPlatform(targetLinuxAarch64, jdk_linux_aarch64, [])
|
|
}
|
|
else {
|
|
rt.extension.targetPlatform(targetLinuxAarch64) {
|
|
jdkHome = jdkDownload(jdk_download_linux_aarch64)
|
|
}
|
|
}
|
|
//Linux x86-64
|
|
if(file(jdk_linux_x86_64).exists()) {
|
|
rt.extension.targetPlatform(targetLinuxX86_64, jdk_linux_x86_64, [])
|
|
}
|
|
else {
|
|
rt.extension.targetPlatform(targetLinuxX86_64) {
|
|
jdkHome = jdkDownload(jdk_download_linux_x86_64)
|
|
}
|
|
}
|
|
//OSX aarch64
|
|
if(file(jdk_osx_aarch64).exists()) {
|
|
rt.extension.targetPlatform(targetOsxAarch64, jdk_osx_aarch64, [])
|
|
}
|
|
else {
|
|
rt.extension.targetPlatform(targetOsxAarch64) {
|
|
jdkHome = jdkDownload(jdk_download_osx_aarch64)
|
|
}
|
|
}
|
|
//OSX x86-64
|
|
if(file(jdk_osx_x86_64).exists()) {
|
|
rt.extension.targetPlatform(targetOsxX86_64, jdk_osx_x86_64, [])
|
|
}
|
|
else {
|
|
rt.extension.targetPlatform(targetOsxX86_64) {
|
|
jdkHome = jdkDownload(jdk_download_osx_x86_64)
|
|
}
|
|
}
|
|
|
|
configure(rt, jvmArgsLinux)
|
|
}
|