-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
141 lines (122 loc) · 4.61 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
* iSongs-RadioText - Radio-text part of iSongs.
*
* Copyright (C) 2024 mhahnFr
*
* This file is part of the iSongs-RadioText.
*
* iSongs-RadioText 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.
*
* iSongs-RadioText 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
* iSongs-RadioText, see the file LICENSE. If not, see <https://www.gnu.org/licenses/>.
*/
import java.nio.file.Files
import java.nio.file.StandardCopyOption
plugins {
id 'java'
}
group 'mhahnFr'
version '3.6.1'
// Adapt this path to the folder of the native NDL library file!
def NDL_PATH = '<path/to/NDL/>'
def nativeNdlFile = new File(NDL_PATH + File.separatorChar + System.mapLibraryName('ndl'))
def isMac = System.getProperty('os.name').toLowerCase().contains('mac')
def appleScripts = new File('scripts').listFiles()
final String githubUsername = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
final String githubToken = project.findProperty("gpr.token") ?: System.getenv("TOKEN")
repositories {
if (githubUsername != null && !githubUsername.isEmpty() &&
githubToken != null && !githubToken.isEmpty()) {
maven {
url = uri('https://maven.pkg.github.com/mhahnfr/jutilities')
credentials {
username = githubUsername
password = githubToken
}
}
} else {
ivy {
url 'https://github.com/'
patternLayout {
artifact '/[organisation]/[module]/releases/download/v[revision]/[module]-[revision].jar'
}
metadataSources { artifact() }
}
}
mavenCentral()
}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs 'scripts'
include '**/*.applescript'
}
}
}
static def assertBuildFolder() {
def build = new File('./build/')
if (!build.exists()) {
build.mkdir()
}
def libs = new File('./build/libs')
if (!libs.exists()) {
libs.mkdir()
}
}
tasks.register('deploy', Exec) {
dependsOn(jar)
assertBuildFolder()
if (nativeNdlFile.exists() && nativeNdlFile.isFile()) {
Files.copy(nativeNdlFile.toPath(), new File('./build/libs/' + nativeNdlFile.name).toPath(), StandardCopyOption.REPLACE_EXISTING)
}
for (final var file : appleScripts) {
if (!file.name.endsWith('.scpt')) continue
Files.copy(file.toPath(), new File('./build/libs/' + file.name).toPath(), StandardCopyOption.REPLACE_EXISTING)
}
final String icon = 'resources/' + (isMac ? 'icon.icns' : 'icon.png')
configurations.runtimeClasspath.each {
Files.copy(it.toPath(), new File('./build/libs/' + it.name).toPath(), StandardCopyOption.REPLACE_EXISTING)
}
commandLine 'jpackage', '--input', 'build/libs',
'--name', project.name,
'--main-jar', project.name + '-' + version + '.jar',
'--copyright', 'Copyright © 2014 - 2024 mhahnFr',
'--app-version', version,
'--description', 'Radio-Text part of iSongs',
'--vendor', project.group,
'--about-url', 'https://github.com/mhahnFr/iSongs-RadioText',
'--icon', icon,
'--java-options', '--enable-native-access=ALL-UNNAMED'
}
tasks.register('maybeAppleScript', Exec) {
if (isMac) {
for (final var script : appleScripts) {
if (!script.name.endsWith('.applescript')) continue
commandLine 'osacompile', '-xo', script.getParent() + File.separator + script.name.substring(0, script.name.lastIndexOf('.')) + '.scpt', script
}
} else {
commandLine 'echo', 'AppleScript: Nothing to do.'
}
}
dependencies {
implementation 'com.formdev:flatlaf:3.4.1'
implementation 'mhahnfr:jutilities:0.1.1'
implementation 'mhahnfr:ndl4java:0.2'
}
jar {
dependsOn maybeAppleScript
manifest {
attributes 'Main-Class': 'mhahnFr.iSongs.iSongs', 'Class-Path': configurations.runtimeClasspath.collect { it.getName() }.join(' ')
}
}