/
build.gradle
135 lines (105 loc) · 4.03 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
plugins {
id 'java'
id 'maven-publish'
id 'net.nemerosa.versioning' version '3.1.0'
id 'com.github.ben-manes.versions' version '0.51.0'
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
java.toolchain {
languageVersion = JavaLanguageVersion.of 21
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
tasks.withType(JavaCompile).configureEach {
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
}
// javadoc is way too strict for my taste.
tasks.withType(Javadoc).configureEach {
options.addStringOption 'encoding', 'UTF-8'
options.addStringOption 'Xdoclint:none', '-quiet'
}
repositories {
mavenCentral()
google()
}
dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
// https://mvnrepository.com/artifact/javax.help/javahelp
implementation group: 'javax.help', name: 'javahelp', version: '2.0.05'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.23.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.23.1'
// https://github.com/google/gson
implementation 'com.google.code.gson:gson:2.10.1'
// https://segment.com/docs - this one doesn't work because it's missing the Java 9+ module-info.class
//implementation 'com.segment.analytics.java:analytics:+'
}
ext {
mainClassName = 'app.freerouting.gui.MainApplication'
def buildDateTime = new Date()
buildDate = buildDateTime.format('yyyy-MM-dd')
buildTime = buildDateTime.format('HH:mm:ss.SSSZ')
}
def manifestAttributes = [
'Automatic-Module-Name' : 'app.freerouting',
'Built-By' : System.properties['user.name'],
'Created-By' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-Date' : project.buildDate,
'Build-Time' : project.buildTime,
'Build-Revision' : versioning.info.commit,
'Specification-Title' : project.name,
'Specification-Version' : project.version,
'Implementation-Title' : project.name,
'Implementation-Version': project.version
].asImmutable()
jar {
manifest {
attributes manifestAttributes
}
}
tasks.register('executableJar', Jar) {
archiveClassifier = 'executable'
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
from configurations.runtimeClasspath.collect { zipTree(it) }
from files(sourceSets.main.output)
manifest {
attributes manifestAttributes + ['Main-Class': project.mainClassName]
}
}
apply from: 'gradle/publishing.gradle'
// write constants to code
tasks.register('writeVersionInfo') {
doLast {
def buildInfoCode = file("${project.buildDir}/generated-src/app/freerouting/constants/Constants.java")
buildInfoCode.getParentFile().mkdirs()
buildInfoCode.write(
"""
package app.freerouting.constants;
public final class Constants {
public static final String FREEROUTING_VERSION = \"${publishing.versionId}\";
public static final String FREEROUTING_BUILD_DATE = \"${project.buildDate}\";
}
""".stripIndent().trim()
)
}
}
// add the 'vmfconstants' src dir to the folders to compile (input to groovyc)
sourceSets.main.java.srcDirs += "${project.buildDir}/generated-src/"
compileJava.dependsOn += 'writeVersionInfo'
tasks.register('dist', Copy) {
dependsOn assemble
from 'build/libs/freerouting-executable.jar'
into 'build/dist/'
}
tasks.register('run', JavaExec) {
classpath = sourceSets.main.runtimeClasspath
mainClass = project.mainClassName
// arguments to pass to the application
// args 'appArg1'
// jvmArgs 'arg1'
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "1000" // Increase maximum error messages
options.compilerArgs << "-Xmaxwarns" << "1000" // Increase maximum warning messages
}