-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.gradle
438 lines (394 loc) · 12.1 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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
import java.time.Instant
import org.apache.tools.ant.taskdefs.condition.Os
import java.time.ZoneOffset
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
['java', 'distribution', 'checkstyle', 'maven-publish', 'signing', 'eclipse' ].each { apply plugin: it }
group = 'com.fifesoft'
ext.isReleaseVersion = !project.version.endsWith('SNAPSHOT')
assert JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)
configurations.all { // Check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
dependencies {
implementation('com.fifesoft.rtext:fife.common:6.0.3')
implementation('com.fifesoft:rsyntaxtextarea:3.3.4')
implementation('com.fifesoft:autocomplete:3.3.1')
implementation('com.fifesoft:rstaui:3.3.1')
implementation('com.fifesoft:spellchecker:3.3.1')
implementation('com.fifesoft:languagesupport:3.3.0')
implementation 'com.formdev:flatlaf:3.1.1'
implementation 'net.sf.jtidy:jtidy:r938'
implementation 'org.apache.groovy:groovy-all:4.0.13'
implementation 'com.esotericsoftware:jsonbeans:0.7'
implementation 'org.graalvm.js:js:22.3.3'
implementation 'org.graalvm.js:js-scriptengine:22.3.3'
implementation 'org.jruby:jruby:9.4.3.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
}
repositories {
mavenCentral()
mavenLocal()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
}
wrapper {
gradleVersion = '8.2.1'
}
checkstyle {
toolVersion = '10.12.2'
}
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
test {
useJUnitPlatform()
}
static isPluginJar(jarName) {
return jarName.startsWith('plugin-') ||
jarName.startsWith('groovy') || jarName.startsWith('jsonbeans') ||
jarName.startsWith('jtidy') || jarName.startsWith('languagesupport') ||
jarName.startsWith('rhino') || jarName.startsWith('tidy')
}
compileJava {
sourceCompatibility javaVersion.toString()
targetCompatibility javaVersion.toString()
options.debug = true
options.debugOptions.debugLevel = 'source,vars,lines'
options.compilerArgs << '-Xlint:deprecation' << '-Xlint:unchecked'
}
processResources {
doFirst {
new File(projectDir.absolutePath, 'build/resources/main/build-date.txt').text =
ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT)
}
}
java {
withSourcesJar()
withJavadocJar()
}
jar {
manifest {
attributes(
'Specification-Title': 'rtext',
'Specification-Version': version,
'Implementation-Title': 'org.fife.rtext',
'Implementation-Version': version,
'Build-Date': Instant.now().toString(),
'Main-Class': 'org/fife/rtext/Main',
'Class-Path': configurations.runtimeClasspath.findAll { !isPluginJar(it.name) }.collect {
def name = it.name
System.out.println(name)
return name
}.join(' ')
)
}
include 'build-date.txt'
include 'org/fife/**'
exclude 'org/fife/rtext/plugins/**'
}
// RText is odd in that we generate multiple jars from a single source tree.
//task mainJar(type: Jar) {
//}
task consoleJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/console/**'
archiveFileName = provider { 'plugin-console.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.console.Plugin',
'Fife-Plugin-Load-Priority': 'normal'
)
}
}
task fileSystemTreeJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/filesystemtree/**'
archiveFileName = provider { 'plugin-fileSystemTree.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.filesystemtree.FileSystemTreePlugin',
'Fife-Plugin-Load-Priority': 'normal'
)
}
}
task heapIndicatorJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/heapindicator/**'
archiveFileName = provider { 'plugin-heapIndicator.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.heapindicator.HeapIndicatorPlugin',
'Fife-Plugin-Load-Priority': 'low'
)
}
}
task macroSupportJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/macros/**'
archiveFileName = provider { 'plugin-macros.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.macros.MacroPlugin',
'Fife-Plugin-Load-Priority': 'normal'
)
}
}
task projectSupportJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/project/**'
archiveFileName = provider { 'plugin-projects.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.project.ProjectPlugin',
'Fife-Plugin-Load-Priority': 'normal'
)
}
}
task languageSupportJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/langsupport/**'
archiveFileName = provider { 'plugin-languageSupport.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.langsupport.Plugin',
'Fife-Plugin-Load-Priority': 'normal'
)
}
}
task sourceBrowserJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/sourcebrowser/**'
archiveFileName = provider { 'plugin-sourceBrowser.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.sourcebrowser.SourceBrowserPlugin',
'Fife-Plugin-Load-Priority': 'high'
)
}
}
task taskListJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/tasks/**'
archiveFileName = provider { 'plugin-tasks.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.tasks.TasksPlugin',
'Fife-Plugin-Load-Priority': 'normal'
)
}
}
task tidyJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/tidy/**'
archiveFileName = provider { 'plugin-tidy.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.tidy.Plugin',
'Fife-Plugin-Load-Priority': 'normal'
)
}
}
task toolsJar(type: Jar) {
from (sourceSets.main.output) {
include 'org/fife/rtext/plugins/tools/**'
archiveFileName = provider { 'plugin-tools.jar' }
}
manifest {
attributes(
'Fife-Plugin-Class': 'org.fife.rtext.plugins.tools.ToolPlugin',
'Fife-Plugin-Load-Priority': 'normal'
)
}
}
artifacts {
archives /*mainJar,*/ consoleJar, fileSystemTreeJar, heapIndicatorJar,
macroSupportJar, projectSupportJar, languageSupportJar,
sourceBrowserJar, taskListJar, tidyJar, toolsJar
}
distTar.dependsOn(jar, consoleJar, fileSystemTreeJar, heapIndicatorJar, macroSupportJar, projectSupportJar,
languageSupportJar, sourceBrowserJar, taskListJar, tidyJar, toolsJar)
distZip.dependsOn(jar, consoleJar, fileSystemTreeJar, heapIndicatorJar, macroSupportJar, projectSupportJar,
languageSupportJar, sourceBrowserJar, taskListJar, tidyJar, toolsJar)
installDist.dependsOn(jar, consoleJar, fileSystemTreeJar, heapIndicatorJar, macroSupportJar, projectSupportJar,
languageSupportJar, sourceBrowserJar, taskListJar, tidyJar, toolsJar)
def getDistributionFiles(configurations) {
def distFiles = [
'build/libs', // The built jars
configurations.runtimeClasspath // Gradle dependencies
]
// Copy native libraries from FifeCommon, if it's checked out alongside this project
def fifeCommonNativesDir = new File("${projectDir.absolutePath}/../FifeCommon/native")
if (fifeCommonNativesDir.isDirectory()) {
distFiles += fifeCommonNativesDir.listFiles().collect { it.getAbsolutePath() }
}
return distFiles
}
distributions {
main {
distributionBaseName = 'rtext'
contents {
exclude([ '**/*-sources.jar', '**/*-javadoc.jar' ])
from { getDistributionFiles(configurations) }
eachFile { details ->
def path = details.path
if (isPluginJar(path)) {
//println "Is a plugin jar: ${path}"
details.path = "plugins/" + path
}
else if (path.contains("-javadoc.jar") || path.contains("-source.jar")) {
// Ignore
}
else if (path.contains("RText-") && path.endsWith(".jar")) {
details.path = "RText.jar"
}
}
// rename "(.+)\\-${version}\\.jar", '$1.jar'
}
}
src {
distributionBaseName = 'rtext'
}
}
srcDistZip.archiveClassifier = 'src'
srcDistZip {
from projectDir
include '.classpath'
include '.gitignore'
include '.project'
include 'build.gradle'
include 'gradle.properties'
include 'gradle/**/*'
include 'gradlew*'
include 'lib/**'
include 'mac/**'
include 'README.md'
include '.settings/**'
include 'MakeRTextIntaller.nsi'
include 'RText.exe'
include 'src/**'
include 'TO-DO'
}
publishing {
repositories {
maven {
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/'
url = isReleaseVersion ? releasesRepoUrl : snapshotsRepoUrl
credentials { // Credentials usually kept in user's .gradle/gradle.properties
// We must defensively check for these properties so Travis CI build works
username = project.hasProperty('ossrhUsername') ? ossrhUsername : 'unknown'
password = project.hasProperty('ossrhPassword') ? ossrhPassword : 'unknown'
}
}
}
publications {
maven(MavenPublication) {
groupId = 'com.fifesoft.rtext'
artifactId = 'rtext'
version = version
from components.java
pom {
name = 'rtext'
description = 'RText is a powerful, cross-platform programmer\'s text editor written in Java. It is designed ' +
'to be easy to use, highly customizable and flexible. Part of RText\'s design is for the source code ' +
'to be simple, easy to understand, and well documented, so that other programmers can look into its ' +
'inner-workings and figure out how RText ticks with ease. A good place to start (besides the source ' +
'code) is the Javadoc for all classes used in the project. '
url = 'https://github.com/bobbylight/RText'
inceptionYear = '2003'
packaging = 'jar'
licenses {
license {
name = 'BSD-3-Clause'
url = 'https://github.com/bobbylight/RText/blob/master/src/main/dist/License.txt'
}
}
developers {
developer {
name = 'Robert Futrell'
}
}
scm {
url = 'https://github.com/bobbylight/RText'
connection = 'scm:git:git://github.com/bobbylight/RText'
developerConnection = 'scm:git:[email protected]:bobbylight/RText'
if (isReleaseVersion) {
tag = project.version
}
}
}
}
}
}
signing {
// Don't require signing for e.g. ./gradlew install
required { gradle.taskGraph.hasTask('publish') && isReleaseVersion }
sign publishing.publications.maven
}
tasks.withType(Sign) {
onlyIf { isReleaseVersion }
}
def getWindowsJreDependencyList = { installDistDir ->
// Store the output instead of printing to the console
def stdout = new ByteArrayOutputStream()
exec {
workingDir installDistDir
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "${jdkRoot}/bin/jdeps", '--ignore-missing-deps', '--list-deps', 'RText.jar', 'plugins/plugin*.jar'
}
else {
commandLine '/bin/bash', '-c', "${jdkRoot}/bin/jdeps --ignore-missing-deps --list-deps RText.jar plugins/plugin*.jar"
}
standardOutput = stdout
}
def retVal = String.join(',', stdout.toString().split('[ \t\r\n]+'))
if (retVal[0] == ',') {
retVal = retVal.substring(1)
}
retVal += ',java.logging,jdk.unsupported' // GraalVM (for JS support) needs java.util.logging and sun.misc.Unsafe
retVal += ',java.management' // Needed for JRuby
retVal += ',jdk.crypto.ec' // Needed to make HTTPS calls
return retVal
}
task generateWindowsJre {
doLast {
def installDistDir = 'build/install/rtext'
def moduleList = getWindowsJreDependencyList(installDistDir)
println "Generating JRE with modules: ${moduleList}"
exec {
workingDir installDistDir
commandLine "${jdkRoot}/bin/jlink", '--module-path', "\"${jdkRoot}/jmods\"", '--add-modules',
moduleList, '--output', embeddedJreFolderName, '--strip-debug', '--compress', '2',
'--no-header-files', '--no-man-pages'
}
}
}
generateWindowsJre.dependsOn('build', 'installDist')
task generateWindowsStarterExe {
doLast {
exec {
commandLine launch4jExe, 'launch4j.xml'
}
}
}
generateWindowsStarterExe.dependsOn('generateWindowsJre')
task generateMacApp {
doLast {
exec {
commandLine '/bin/bash', '-c', './mac/build-mac-app.sh'
}
}
}
generateMacApp.dependsOn('build', 'installDist')