-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
287 lines (241 loc) · 8.62 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
// For Ant filter
import org.apache.tools.ant.filters.ReplaceTokens
buildscript {
repositories {
mavenCentral()
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
// https://gitlab.com/svg2ico/svg2ico-gradle-plugin
classpath('gradle.plugin.com.gitlab.svg2ico:svg2ico-gradle-plugin:0.14') {
exclude module: 'commons-io'
}
}
// force to use commons-io:2.11.0 instead of svg2ico-gradle-plugin transitive commons-io (which not includes org.apache.commons.io.FileUtils.copyInputStreamToFile method)
configurations.classpath {
resolutionStrategy {
force 'commons-io:commons-io:2.16.1'
}
}
}
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
id 'java'
id 'checkstyle'
// https://github.com/qoomon/gradle-git-versioning-plugin
id 'me.qoomon.git-versioning' version '6.4.3'
id 'org.beryx.jlink' version '3.0.1'
id 'org.gradlex.extra-java-module-info' version '1.8'
}
apply plugin: 'com.gitlab.svg2ico'
gitVersioning.apply {
refs {
considerTagsOnBranches = true
tag('v(?<version>.*)') {
version = '${ref.version}'
}
branch('.+') {
version = '${describe.tag.version}-${describe.distance}-g${commit.short}'
}
}
rev {
version = '${commit}'
}
}
sourceCompatibility = 15
targetCompatibility = 15
project.mainClassName = 'listfix.view.GUIScreen'
def manifestAttributes = [
'Implementation-Title' : project.applicationName,
'Implementation-Version': project.version,
'Implementation-Vendor' : 'Borewit',
'SCM-Repository' : 'https://github.com/Borewit/listFix',
'Main-Class' : project.mainClassName
]
def cleanVersion = project.version.substring(0, project.version.indexOf("-") == -1 ? project.version.length() : project.version.indexOf("-"))
def jpackageName = 'listFix';
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
maven {
url "https://repo1.maven.org/maven2/"
}
mavenLocal()
// Staging repository
maven { url 'https://s01.oss.sonatype.org/content/groups/staging/' }
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
// Provides christophedelory.playlist.*
implementation 'io.github.borewit:lizzy:4.0.1'
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
implementation 'org.apache.logging.log4j:log4j-core:2.23.1'
implementation 'jakarta.activation:jakarta.activation-api:2.1.3';
// Required for log4j yaml configuration files
// https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.1'
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.1'
// https://mvnrepository.com/artifact/commons-io/commons-io
implementation 'commons-io:commons-io:2.16.1'
// Provide JFontChooser
implementation 'com.rover12421.opensource:JFontChooser:1.0.5-3'
// JUnit Jupiter using Gradle's native JUnit Platform
testImplementation platform('org.junit:junit-bom:5.10.2')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.junit.jupiter:junit-jupiter-params'
testRuntimeOnly 'org.junit.platform:junit-platform-reporting'
}
application {
mainModule = 'listFix.app'
// Define the main class for the application.
mainClass = project.mainClassName
}
jar {
manifest {
attributes(manifestAttributes)
}
}
// Convert legacy dependency to named Java module
extraJavaModuleInfo {
module('com.rover12421.opensource:JFontChooser', 'say.swing.JFontChooser') {
requires('java.desktop');
exports('say.swing')
}
module('org.objenesis:objenesis', 'org.objenesis') {
exports('org.objenesis')
}
module('org.mockito:mockito-core', 'org.mockito.core') {
exports('org.mockito.verification')
}
module('com.jcabi:jcabi-log', 'com.jcabi.log') {
exports('com.jcabi.log')
}
module('com.jcabi:jcabi-manifests', 'com.jcabi.manifests') {
//requires('com.jcabi.log')
exports('com.jcabi.manifests')
}
module('com.googlecode.plist:dd-plist', 'dd.plist') {
exports('com.dd.plist')
requires('java.xml')
}
}
def generatedDir = "$buildDir/generated"
def generatedSources = "$generatedDir/sources"
def generatedResources = "$generatedDir/resources"
def generatedImages = "$generatedResources/images"
def pathFavicon = "$generatedDir/images/favicon.ico"
def pathPngIcon = "${generatedImages}/icon.png"
def pathSvgLogo = "${generatedImages}/listFix() logo.svg"
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/resources', generatedResources]
}
}
}
jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher{
name = jpackageName
noConsole = true
jvmArgs = ['-Dlog4j.configurationFile=./log4j2.xml']
}
forceMerge 'jackson', 'log4j', 'log4j-core', 'slf4j', 'com.jcabi.log'
jpackage {
jvmArgs = ['-splash:images/listfixSplashScreen.png']
def currentOs = org.gradle.internal.os.OperatingSystem.current()
icon = currentOs.windows ? pathFavicon : pathPngIcon
description = 'Fix and repairs broken playlist'
// imageOptions += ['--win-console']
imageOptions += ['--app-version', cleanVersion]
installerOptions += [
'--vendor', project.vendor,
'--app-version', cleanVersion
]
if (currentOs.windows) {
installerOptions += [
'--win-upgrade-uuid', project.windowsUpgradeUuid,
'--install-dir', 'listFix',
'--win-per-user-install',
'--win-dir-chooser',
'--win-menu'
]
} else if (currentOs.unix) {
installerOptions += [
'--install-dir', '/opt/listfix',
'--linux-package-name', 'listfix',
'--linux-rpm-license-type', 'MIT'
]
}
}
mergedModule {
additive = true
uses "org.apache.logging.log4j.spi.Provider"
uses "org.apache.logging.log4j.core.util.WatchEventService"
uses "org.apache.logging.log4j.core.util.ContextDataProvider"
}
}
task windowsPortableFolder(type: Copy, dependsOn: jpackage) {
group = 'distribution'
from "${buildDir}/jpackage/${jpackageName}"
into "${buildDir}/distributions/portable/listFix-${project.version}"
}
task fatJar(type: Jar) {
group = 'distribution'
manifest {
attributes(manifestAttributes)
}
setDuplicatesStrategy(DuplicatesStrategy.WARN)
archiveBaseName = 'listFix'
archiveVersion = project.version
archiveClassifier = 'all'
from { configurations.runtimeClasspath.filter { it.exists() }.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task makePngIcon(type: Svg2PngTask) {
group = 'graphics'
source = new File('src/main/svg/listFix() icon.svg')
width = 64
height = 64
destination = new File(pathPngIcon)
}
tasks.processResources.dependsOn makePngIcon
task generateSplashScreenWithVersion(type: Copy) {
group = 'graphics'
from 'src/main/svg/listFix() logo.svg'
into generatedImages
filter(ReplaceTokens, tokens: [VERSION: project.version])
}
task makeSplashScreen(type: Svg2PngTask, dependsOn: generateSplashScreenWithVersion) {
group = 'graphics'
source = new File(pathSvgLogo)
width = 400
height = 160
destination = new File("$generatedImages/listfixSplashScreen.png")
}
tasks.processResources.dependsOn makeSplashScreen
task makeIcon (type: Svg2IcoTask) {
group = 'graphics'
input {
source = file('src/main/svg/listFix() icon.svg')
}
destination = file(pathFavicon)
}
tasks.processResources.dependsOn makeIcon
tasks.withType(Checkstyle).configureEach {
exclude 'listfix/model/playlists/winamp/generated/**.java'
}
task checkStyle(type: DefaultTask, dependsOn: [checkstyleMain, checkstyleTest]) {
group = 'verification'
}
tasks.withType(Test).configureEach {
useJUnitPlatform()
}
applicationDefaultJvmArgs = ['--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED',
'--add-exports=java.desktop/sun.awt.shell=ALL-UNNAMED'
]