mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-21 13:05:43 -05:00
Tab page size preference (50, 100, 250, 500; default 500) next to the paging controls. Calls tab call type search filter. - Type filter (group, patch, private, telephone, other) in the Calls search bar, applied when selected. - CallType provides the SQL condition on the stored identifier forms, using the same rules as the Type column. #2742 Calls tab default column order puts protocol, system, site and channel at the end. #2742 Call type test. #2742 Calls tab shows the call type: group, patch, private or telephone. - CallType is derived from the stored TO and FROM identifier forms, so existing calls have a type without a schema change. Telephone interconnect calls (telephone number TO or FROM) show as Telephone. - Calls tab: Type column. #2742 Patch group calls store their patched talkgroups so a talkgroup search finds the calls it was patched into. - Schema version 2 adds the patched_talkgroups table (call id, talkgroup, fully qualified address), deleted with the call. Existing version 1 databases are upgraded automatically at startup. - The call manager captures the patched talkgroups (they can change during the call); transfers copy them. - TO searches by talkgroup value or talkgroup alias match the patch group and its patched talkgroups, in the database and for live calls. - Calls tab: Patched column lists the patched talkgroups with their current aliases. #2742 Calls tab replays recordings through the audio channels. - Replay uses the sdrtrunk audio output and channels instead of a separate JavaFX media player: an idle channel (left first), otherwise the left (or mono) channel, which drops the live call it is playing. Live calls aren't assigned to a replaying channel and queued calls play after the replay. - RecordingReader decodes MP3 (LAME decoder; MPEG-2/2.5 frame size fix) and WAVE recordings to 8 kHz audio. - ReplaySource supports pause, seek and stop; the Calls player keeps its controls and auto-play next. - Playback events and the Calls tab Playing column show replays (history icon); the audio panel shows REPLAY. - Playing row channel edge is drawn as a background layer so the row's cells stay aligned with other rows. - HikariCP and MariaDB driver logging limited to INFO. - javafx.media removed from the runtime image modules. #2742 Calls tab shows which calls are playing on each audio channel. - Audio segments have a unique id, which the call manager uses as the call key. - Audio channels report the call they start and stop playing; the audio playback manager publishes these as ChannelPlayback events (re-wired when the output device changes) with a snapshot for late listeners. - Calls tab: Playing column with a LEFT/RIGHT/MONO chip and a channel-colored row tint and edge for calls that are playing. Calls reloaded from the database keep their call key so a call that ended but is still playing stays marked. - Audio panel channel tags use the same colors (left/mono blue, right orange). #2742 Replace AudioRecordingManager with CallManager and CallRecorder. - CallManager (new call package) is the single audio segment listener for calls. It manages each call's life-cycle: creates and updates the call record, saves it to the call database and broadcasts it to call listeners (Calls tab, future external subscribers). - CallRecorder (record package) holds the streaming recording logic and file naming. The call manager creates one CallRecorder.Recording per call, which fills in the recording details of the call record. - DatabaseManager remains storage only. No behavior change. #2742 Record all calls by default; delete duplicate and Do Not Monitor calls after a retention period. - Record preferences: 'Record all calls' (default on). When off, only calls with an alias record option are recorded, as before. - Duplicate calls are no longer discarded immediately. Duplicate calls, and Do Not Monitor calls that no alias marked for recording, are deleted with their recordings after a configurable retention period (30 minutes to 7 days, or never; default 1 hour) set in the Call Database preferences. Calls store whether an alias requested recording. - The duplicate call 'Recording' suppression switch is replaced by a note pointing to the retention setting. - Age-off runs every 5 minutes. #2742 Calls store the alias list name and look up TO/FROM aliases from the current alias list. - The calls table no longer stores TO/FROM alias names. It stores the alias list name, the TO/FROM identifier forms and the fully qualified (roaming) addresses, and the Calls tab looks up the aliases in the current alias list when it displays a call, so historical calls show the latest alias values. - AliasList lookups by protocol, value and fully qualified address, sharing the identifier matching rules. - TO and FROM search fields drop down a filtering list of talkgroup or radio aliases. Selecting an alias filters by the alias's alias list and its talkgroup/radio values, ranges and fully qualified identifiers. Typed text still matches the identifier. The alias search field is replaced by a talker alias search. #2742 Call database, Calls tab, call audio age-off and talkgroup hold. - Call database: built-in H2 (application 'db' folder) by default, with optional MariaDB or PostgreSQL. The sdrtrunk schema and tables are installed and versioned automatically. Engine differences are isolated in IDatabaseDialect implementations and call storage behind ICallRepository. - Switching databases asks whether to transfer the existing calls and, when the target schema already has sdrtrunk calls, whether to append, clear, or create a separately named schema. - Every call gets a database row when it starts, updated as identifiers change and when the call completes. - Call recordings are written while the call is in progress (streaming MP3/WAVE), so the recording file and its name are stored with the call from the start. MP3 ID3 metadata is rewritten in reserved space at the end. - Calls tab after Now Playing: search by talkgroup, radio, alias, protocol, system and date range, live duration of calls in progress, built-in recording player with auto-play, context menu to hold a talkgroup. - Call Database preferences: database selection, test connection, and age-off rules (age and total size), each deleting the call and recording or only the recording. The status bar recordings meter uses the size rule limit when enabled. - Talkgroup hold: Hold button on each audio channel steers the held talkgroup (and patch groups that include it) to that channel, keeps other calls off it, plays it even when do-not-monitor, with an optional idle auto-release in Playback preferences.
562 lines
24 KiB
Groovy
562 lines
24 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 org.beryx.runtime.RuntimeZipTask
|
|
import org.gradle.internal.jvm.Jvm
|
|
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
|
|
|
|
import java.text.SimpleDateFormat
|
|
|
|
/**
|
|
* Instructions for building/compiling the sdrtrunk application.
|
|
*
|
|
* Prerequisites:
|
|
* Install and configure an OpenJDK version 27+ that includes the JavaFX modules (e.g. Bellsoft Liberica JDK)
|
|
* - Optional: install and configure Gradle 9.8+
|
|
*
|
|
* 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'
|
|
}
|
|
|
|
/**
|
|
* Version is derived from the most recent 'v<version>' git tag (e.g. v1.0.0-beta-1 -> 1.0.0-beta-1). Commits after
|
|
* the tag produce a version like 1.0.0-beta-1-14-g4626d567 and uncommitted changes append '-dirty'. The moving
|
|
* 'nightly' tag is ignored. Override with -PprojectVersion=<version> (the nightly build uses 'nightly' so that the
|
|
* nightly release asset names stay the same). Falls back to 'unknown' when built outside a git checkout.
|
|
*/
|
|
String gitDescribe = describeGitVersion()
|
|
version = project.findProperty('projectVersion') ?: (gitDescribe ? gitDescribe.substring(1) : 'unknown')
|
|
|
|
String describeGitVersion()
|
|
{
|
|
try
|
|
{
|
|
def describe = providers.exec {
|
|
commandLine 'git', 'describe', '--tags', '--match', 'v[0-9]*', '--dirty'
|
|
ignoreExitValue = true
|
|
}
|
|
|
|
if(describe.result.get().exitValue == 0)
|
|
{
|
|
return describe.standardOutput.asText.get().trim()
|
|
}
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
logger.warn("Unable to determine version from git tags: " + e.message)
|
|
}
|
|
|
|
return null
|
|
}
|
|
|
|
tasks.register('printVersion') {
|
|
description = 'Prints the project version'
|
|
def projectVersion = version
|
|
doLast {
|
|
println projectVersion
|
|
}
|
|
}
|
|
|
|
//Java 27 is required for this version of the Project Panama preview/incubator feature
|
|
java {
|
|
toolchain {
|
|
languageVersion = JavaLanguageVersion.of(27)
|
|
vendor = JvmVendorSpec.BELLSOFT
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Verifies that the selected toolchain JDK includes the JavaFX modules (e.g. Bellsoft Liberica 'Full JDK').
|
|
*
|
|
* Gradle's toolchain spec can only select by language version, vendor and implementation, so it can't distinguish
|
|
* between the Liberica JDK packages that do and don't bundle JavaFX. This task fails the build with a clear message
|
|
* instead of allowing compilation to fail with missing javafx packages.
|
|
*/
|
|
tasks.register('verifyToolchainJavaFx') {
|
|
def jdkHome = javaToolchains.launcherFor(java.toolchain).map { it.metadata.installationPath.asFile }
|
|
|
|
doLast {
|
|
def release = new File(jdkHome.get(), 'release')
|
|
|
|
if(!release.exists() || !release.text.contains('javafx.base')) {
|
|
throw new GradleException("The JDK at [${jdkHome.get()}] does not include the JavaFX modules. Install " +
|
|
"the Bellsoft Liberica JDK 27 'Full' package (includes LibericaFX), or use " +
|
|
"-Porg.gradle.java.installations.paths=<jdk path> to specify the JDK that Gradle should use.")
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.named('compileJava') {
|
|
dependsOn 'verifyToolchainJavaFx'
|
|
}
|
|
|
|
test {
|
|
useJUnitPlatform()
|
|
}
|
|
|
|
dependencies {
|
|
|
|
// JUnit Tests
|
|
testImplementation(platform("org.junit:junit-bom:6.1.3"))
|
|
testImplementation 'org.junit.jupiter:junit-jupiter-api'
|
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
|
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
|
|
|
//Jitpack imports
|
|
implementation 'com.github.dnault:libresample4j:master'
|
|
implementation 'com.github.nwaldispuehl:java-lame:v3.98.4'
|
|
|
|
//mavenCentral/jcenter imports
|
|
implementation 'ch.qos.logback:logback-classic:1.6.6'
|
|
implementation 'ch.qos.logback:logback-core:1.6.6'
|
|
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.23.0'
|
|
implementation 'com.github.jiconfont:jiconfont-font_awesome:4.7.0.1'
|
|
implementation 'com.github.jiconfont:jiconfont-javafx:1.0.0'
|
|
implementation('com.github.wendykierp:JTransforms:3.2') {
|
|
exclude group: 'junit' //JLargeArrays 1.7 declares junit as a compile dependency
|
|
}
|
|
implementation 'com.google.code.gson:gson:2.15.0'
|
|
implementation 'com.google.guava:guava:33.8.0-jre'
|
|
implementation 'com.h2database:h2:2.5.252' //Built-in call database
|
|
implementation 'com.zaxxer:HikariCP:7.1.0' //Database connection pool
|
|
implementation 'com.mpatric:mp3agic:0.9.1'
|
|
implementation 'commons-io:commons-io:2.22.0'
|
|
implementation 'io.github.dsheirer:jairspy:1.0.12.1' //Airspy tuners - GitHub release, see settings.gradle
|
|
implementation 'io.github.dsheirer:jairspyhf:1.8.1.1' //Airspy HF+ tuners - GitHub release, see settings.gradle
|
|
implementation 'io.github.dsheirer:jbladerf:2.6.0.1' //bladeRF tuners - GitHub release, see settings.gradle
|
|
implementation 'io.github.dsheirer:jhackrf:2026.01.3.1' //HackRF tuners - GitHub release, see settings.gradle
|
|
implementation 'io.github.dsheirer:jmbe-api:3.0.0' //JMBE audio codec interfaces - GitHub release, see settings.gradle
|
|
implementation 'io.github.dsheirer:jlibusb:1.0.30.1' //libusb and USB hotplug for the tuner libraries - GitHub release; not pulled in transitively
|
|
implementation 'io.github.dsheirer:jhydrasdr:1.1.4.1' //HydraSDR tuners - GitHub release, see settings.gradle
|
|
implementation 'io.github.dsheirer:jlimesdr:25.1.0.2' //LimeSDR tuners - GitHub release, see settings.gradle
|
|
implementation 'io.github.dsheirer:jrtl:1.4.0.3' //RTL-SDR tuners - GitHub release, see settings.gradle
|
|
implementation 'io.github.dsheirer:jsdrplay:3.15.3' //SDRplay RSP tuners - GitHub release, see settings.gradle
|
|
implementation 'io.github.dsheirer:radio-reference-api:18.1.0' //RadioReference SOAP API - GitHub release, see settings.gradle
|
|
implementation 'org.apache.commons:commons-compress:1.28.0' //Not used directly - overrides the vulnerable 1.21 version from jarchivelib
|
|
implementation 'org.apache.commons:commons-lang3:3.21.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.10'
|
|
implementation 'org.apache.mina:mina-http:2.2.10'
|
|
implementation 'org.controlsfx:controlsfx:11.2.6'
|
|
implementation 'org.mariadb.jdbc:mariadb-java-client:3.5.11' //Optional MariaDB call database
|
|
implementation 'org.postgresql:postgresql:42.7.14' //Optional PostgreSQL call database
|
|
implementation 'org.rauschig:jarchivelib:1.2.0'
|
|
implementation 'org.slf4j:slf4j-api:2.0.20'
|
|
}
|
|
|
|
def os = DefaultNativePlatform.currentOperatingSystem
|
|
|
|
/**
|
|
* This is needed for the JDK23+ vector API ... until it moves out of incubation or preview
|
|
*/
|
|
tasks.withType(JavaCompile).configureEach {
|
|
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-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
|
|
|
|
/**
|
|
* 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
|
|
'--enable-native-access=javafx.graphics', //JDK24 - suppress restricted java.lang.System calls
|
|
'--enable-native-access=ALL-UNNAMED'] //Suppress warnings for FFM API native calls (tuner libraries)
|
|
|
|
/**
|
|
* Startup splash screen image. The JVM shows it before any application code runs and closes it when the main window
|
|
* opens. The release launch scripts load it from the runtime image lib folder (see the runtime task below) and the
|
|
* gradle run task loads it from the resources folder. The JVM picks up the @2x image on HiDPI displays.
|
|
*/
|
|
def splashImages = ['sdrtrunk-splash.png', 'sdrtrunk-splash@2x.png']
|
|
def splashResourceDir = 'src/main/resources/images/sdrtrunk'
|
|
|
|
application {
|
|
mainClass = "io.github.dsheirer.gui.SDRTrunk"
|
|
|
|
if(os.isWindows()) {
|
|
applicationDefaultJvmArgs = jvmArgsWindows
|
|
}
|
|
else {
|
|
applicationDefaultJvmArgs = jvmArgsLinux
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Adds the splash screen to the run task through an argument provider. Calling jvmArgs here would replace the
|
|
* applicationDefaultJvmArgs convention (--add-modules=jdk.incubator.vector, --enable-preview, etc.) instead of adding
|
|
* to it.
|
|
*/
|
|
tasks.named('run') {
|
|
def splashImage = file(splashResourceDir + '/' + splashImages[0]).absolutePath
|
|
jvmArgumentProviders.add({ ["-splash:${splashImage}".toString()] } as CommandLineArgumentProvider)
|
|
}
|
|
|
|
test {
|
|
if(os.isWindows()) {
|
|
jvmArgs = jvmArgsWindows
|
|
}
|
|
else {
|
|
jvmArgs = jvmArgsLinux
|
|
}
|
|
}
|
|
|
|
jar {
|
|
manifest {
|
|
attributes (
|
|
'Implementation-Title' : 'sdrtrunk project',
|
|
'Implementation-Version' : archiveVersion,
|
|
'Git-Describe' : gitDescribe ?: 'unknown',
|
|
'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
|
|
|
|
/**
|
|
* Download URLs to download the JDK as part of the gradle build packaging process
|
|
*/
|
|
def jdk_download_base = "https://download.bell-sw.com/java/27+36/bellsoft-jdk27+36-"
|
|
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(RuntimeZipTask rt, List<String> jvmArgs) {
|
|
//Use the correct set of JVM arguments, plus the startup splash screen that the runtime task copies to lib
|
|
rt.extension.launcherData.get().jvmArgs = jvmArgs + ['-splash:{{BIN_DIR}}/../lib/sdrtrunk-splash.png']
|
|
|
|
//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
|
|
//java.sql, java.naming, java.security.jgss, jdk.net - call database JDBC drivers and connection pool
|
|
//java.base, java.desktop, java.logging, java.net.http, java.prefs, javafx.controls - required by sdrtrunk (jdeps)
|
|
rt.extension.addModules('jdk.charsets', 'jdk.crypto.ec', 'jdk.incubator.vector', 'jdk.accessibility', 'java.management',
|
|
'java.base', 'java.desktop', 'java.logging', 'java.net.http', 'java.prefs', 'javafx.controls', 'java.sql',
|
|
'java.naming', 'java.security.jgss', 'jdk.net')
|
|
|
|
//Use only the modules listed above. The runtime plugin's module auto-detection uses a bundled ASM library that
|
|
//can't read Java 27 class files and logs a 'Failed to scan' error for each sdrtrunk class. The jdeps module check
|
|
//on the runtime task verifies that this list is complete.
|
|
rt.extension.additive.set(false)
|
|
|
|
//Recommended options for reducing/shrinking runtime target image size
|
|
rt.extension.addOptions('--strip-debug', '--compress', 'zip-6', '--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.imageDir=layout.buildDirectory.dir('image')
|
|
rt.extension.imageZip.set(file(layout.buildDirectory.dir('image').get().file('sdr-trunk.zip')))
|
|
}
|
|
|
|
/**
|
|
* Rewrites the jar file without the native library folders for other operating systems and architectures. Fails the
|
|
* build if a jar that contains native libraries doesn't contain the folder for the target.
|
|
* @param jar file to rewrite
|
|
* @param keep native folder for the target
|
|
* @return number of bytes removed from the jar
|
|
*/
|
|
long stripJar(File jar, String keep) {
|
|
def tunerPattern = ~/^[^\/]+\/native\/([^\/]+)\/.*/
|
|
def removed = [] as Set
|
|
def hadTuner = false, keptTuner = false
|
|
File temp = new File(jar.parentFile, jar.name + '.tmp')
|
|
|
|
new java.util.zip.ZipFile(jar).withCloseable { zip ->
|
|
def entries = zip.entries().toList()
|
|
|
|
entries.each { e ->
|
|
def tuner = tunerPattern.matcher(e.name)
|
|
|
|
if(tuner.matches()) {
|
|
hadTuner = true
|
|
if(tuner.group(1) == keep) { keptTuner = true } else { removed << e.name }
|
|
}
|
|
}
|
|
|
|
if(hadTuner && !keptTuner) {
|
|
throw new GradleException("Native strip: ${jar.name} has no native/${keep} folder")
|
|
}
|
|
|
|
if(!removed.isEmpty()) {
|
|
new java.util.zip.ZipOutputStream(new FileOutputStream(temp)).withCloseable { out ->
|
|
entries.findAll { !removed.contains(it.name) }.each { e ->
|
|
def copy = new java.util.zip.ZipEntry(e)
|
|
if(copy.method == java.util.zip.ZipEntry.DEFLATED) {
|
|
copy.compressedSize = -1
|
|
}
|
|
out.putNextEntry(copy)
|
|
zip.getInputStream(e).withCloseable { out << it }
|
|
out.closeEntry()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(removed.isEmpty()) {
|
|
return 0
|
|
}
|
|
|
|
long before = jar.length()
|
|
java.nio.file.Files.move(temp.toPath(), jar.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
|
return before - jar.length()
|
|
}
|
|
|
|
/**
|
|
* Removes the native libraries for other operating systems and architectures from the jars in each runtime target
|
|
* image, before the runtimeZip tasks package the images. The tuner libraries (jRTL, jAirspy, etc.) package their
|
|
* native libraries under '<library>/native/<os>-<arch>/', where the folder name matches the runtime target name
|
|
* '<os>-<arch>-v<version>' without the version suffix, except that the libraries use 'macos' where the target uses 'osx'.
|
|
*/
|
|
tasks.named('runtime') {rt ->
|
|
rt.doLast {
|
|
rt.targetPlatforms.get().keySet().each { target ->
|
|
def nativeFolder = (target - "-v${version}").replaceFirst(/^osx-/, 'macos-')
|
|
def lib = new File(rt.imageDir.asFile, "${project.name}-${target}/lib")
|
|
long total = 0
|
|
lib.listFiles({ File f -> f.name.endsWith('.jar') } as FileFilter).each { jar ->
|
|
total += stripJar(jar, nativeFolder)
|
|
}
|
|
logger.lifecycle("Native strip: removed ${String.format('%.1f', total / 1048576)} MB of other " +
|
|
"platform native libraries from [${target}]")
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Copies the startup splash screen images into the lib folder of each runtime target image, where the launch scripts
|
|
* load them from (-splash:{{BIN_DIR}}/../lib/...).
|
|
*/
|
|
tasks.named('runtime') {rt ->
|
|
rt.doLast {
|
|
rt.targetPlatforms.get().keySet().each { target ->
|
|
def lib = new File(rt.imageDir.asFile, "${project.name}-${target}/lib")
|
|
splashImages.each { name ->
|
|
java.nio.file.Files.copy(file(splashResourceDir + '/' + name).toPath(), new File(lib, name).toPath(),
|
|
java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Verifies that each runtime target image contains every module that the sdrtrunk jar requires, as reported by jdeps.
|
|
* This guards against the runtime plugin's module auto-detection silently missing modules (e.g. when it can't parse
|
|
* class files compiled for a newer Java version).
|
|
*/
|
|
def jdepsHome = javaToolchains.launcherFor(java.toolchain).map { it.metadata.installationPath.asFile }
|
|
def mainJar = tasks.named('jar').flatMap { it.archiveFile }
|
|
|
|
tasks.named('runtime') {rt ->
|
|
rt.doLast {
|
|
def jdeps = new File(jdepsHome.get(), 'bin/' + (os.isWindows() ? 'jdeps.exe' : 'jdeps')).absolutePath
|
|
def process = new ProcessBuilder(jdeps, '--multi-release', java.toolchain.languageVersion.get().toString(),
|
|
'--ignore-missing-deps', '--print-module-deps', '-q', mainJar.get().asFile.absolutePath)
|
|
.redirectErrorStream(true).start()
|
|
def output = process.inputStream.text.trim()
|
|
|
|
if(process.waitFor() != 0) {
|
|
throw new GradleException("Module check: jdeps failed: ${output}")
|
|
}
|
|
|
|
def required = output.split(',')*.trim().findAll { it } as Set
|
|
|
|
rt.targetPlatforms.get().keySet().each { target ->
|
|
def release = new File(rt.imageDir.asFile, "${project.name}-${target}/release")
|
|
def match = release.text =~ /(?m)^MODULES="([^"]*)"/
|
|
|
|
if(!match.find()) {
|
|
throw new GradleException("Module check: no MODULES entry in ${release}")
|
|
}
|
|
|
|
def missing = required - (match.group(1).split(' ') as Set)
|
|
|
|
if(missing) {
|
|
throw new GradleException("Module check: runtime image [${target}] is missing required modules " +
|
|
"${missing.sort()} - add them to addModules() in build.gradle")
|
|
}
|
|
}
|
|
logger.lifecycle("Module check: runtime images contain all modules required by sdrtrunk: ${required.sort()}")
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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', RuntimeZipTask) {rt ->
|
|
def arch = System.properties.getProperty("os.arch")
|
|
def javaHome = Jvm.current().getJavaHome().toString()
|
|
|
|
if(os.isWindows()) {
|
|
if(arch == "amd64") {
|
|
rt.extension.targetPlatform(targetWindowsX86_64, javaHome)
|
|
}
|
|
else if(arch == "aarch64") {
|
|
rt.extension.targetPlatform(targetWindowsAarch64, javaHome)
|
|
}
|
|
configure(rt, jvmArgsWindows)
|
|
}
|
|
else if(os.isLinux())
|
|
{
|
|
if(arch == "amd64") {
|
|
rt.extension.targetPlatform(targetLinuxX86_64, javaHome)
|
|
}
|
|
else if(arch == "aarch64") {
|
|
rt.extension.targetPlatform(targetLinuxAarch64, javaHome)
|
|
}
|
|
configure(rt, jvmArgsLinux)
|
|
}
|
|
else if(os.isMacOsX())
|
|
{
|
|
if(arch == "amd64") {
|
|
rt.extension.targetPlatform(targetOsxX86_64, javaHome)
|
|
}
|
|
else if(arch == "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', RuntimeZipTask) {rt ->
|
|
//Windows aarch64
|
|
rt.extension.targetPlatform(targetWindowsAarch64) {
|
|
jdkHome = jdkDownload(jdk_download_windows_aarch64)
|
|
}
|
|
//Windows x86-64
|
|
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', RuntimeZipTask) {rt ->
|
|
//Linux aarch64
|
|
rt.extension.targetPlatform(targetLinuxAarch64) {
|
|
jdkHome = jdkDownload(jdk_download_linux_aarch64)
|
|
}
|
|
//Linux x86-64
|
|
rt.extension.targetPlatform(targetLinuxX86_64) {
|
|
jdkHome = jdkDownload(jdk_download_linux_x86_64)
|
|
}
|
|
//OSX aarch64
|
|
rt.extension.targetPlatform(targetOsxAarch64) {
|
|
jdkHome = jdkDownload(jdk_download_osx_aarch64)
|
|
}
|
|
//OSX x86-64
|
|
rt.extension.targetPlatform(targetOsxX86_64) {
|
|
jdkHome = jdkDownload(jdk_download_osx_x86_64)
|
|
}
|
|
|
|
configure(rt, jvmArgsLinux)
|
|
}
|