forked from freerouting/freerouting
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
236 lines (190 loc) · 7.3 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
import com.vanniktech.maven.publish.SonatypeHost
plugins {
id 'java'
id 'jvm-test-suite'
id 'signing'
id 'maven-publish'
id "com.vanniktech.maven.publish" version "0.30.0"
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'
}
testing {
suites {
test {
useJUnitJupiter()
}
integrationTest(JvmTestSuite) {
dependencies {
implementation project()
}
targets {
all {
testTask.configure {
shouldRunAfter(test)
}
}
}
}
}
}
tasks.named('check') {
dependsOn(testing.suites.integrationTest)
}
repositories {
flatDir {
dirs 'libs'
}
mavenCentral()
// Adding mirror repositories
maven {
name = 'MirrorRepo1'
url = 'https://repo1.maven.org/maven2' // Replace with actual mirror URL
}
google()
}
dependencies {
// https://mvnrepository.com/artifact/javax.help/javahelp
//implementation group: 'javax.help', name: 'javahelp', version: '2.0.05'
// https://mvnrepository.com/artifact/org.apache.logging.log4j
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.24.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.11.0'
// 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:+'
// Add Jakarta Inject API dependency
implementation 'jakarta.inject:jakarta.inject-api:2.0.1'
implementation 'jakarta.annotation:jakarta.annotation-api:3.0.0'
implementation 'jakarta.validation:jakarta.validation-api:3.1.0'
implementation 'jakarta.activation:jakarta.activation-api:2.1.3'
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'
// Add Jersey dependencies
implementation 'org.glassfish.jersey.core:jersey-common:3.1.7'
implementation 'org.glassfish.jersey.core:jersey-client:3.1.9'
implementation 'org.glassfish.jersey.core:jersey-server:3.1.7'
implementation 'org.glassfish.jersey.inject:jersey-hk2:3.1.7'
implementation 'org.glassfish.jersey.media:jersey-media-json-binding:3.1.7'
implementation 'org.glassfish.jersey.containers:jersey-container-servlet-core:3.1.7'
implementation 'org.glassfish.jersey.containers:jersey-container-servlet:3.1.7'
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.5'
// Add Jetty dependencies
implementation 'org.eclipse.jetty.ee10:jetty-ee10-servlet:12.0.15'
implementation 'org.eclipse.jetty:jetty-server:12.0.15'
implementation 'org.eclipse.jetty:jetty-util:12.0.15'
implementation 'org.eclipse.jetty:jetty-security:12.0.15'
// Add SLF4J API and binding dependencies for Jersey logging
implementation 'org.slf4j:slf4j-api:2.0.16'
implementation 'org.slf4j:slf4j-nop:2.0.16'
// Add Google Cloud BigQuery dependencies for telemetry
implementation 'com.google.auth:google-auth-library-oauth2-http:1.29.0'
implementation 'com.google.api:gax:2.57.0'
implementation 'com.google.api-client:google-api-client-appengine:2.7.0'
implementation 'com.google.cloud:google-cloud-core:2.47.0'
implementation 'com.google.cloud:google-cloud-core-http:2.47.0'
implementation 'com.google.cloud:google-cloud-bigquery:2.43.3'
}
ext {
mainClassName = 'app.freerouting.Freerouting'
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)
// Exclude signature files from dependencies
from {
configurations.runtimeClasspath.collect { zipTree(it) }
} {
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA'
}
from files(sourceSets.main.output)
manifest {
attributes manifestAttributes + ['Main-Class': project.mainClassName]
}
}
// Publishing
mavenPublishing {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
signAllPublications()
}
apply from: 'gradle/publishing.gradle'
// Signing - Signing (generating the \builds\libs\*.asc files) is needed for publishing to Maven Central
//signing {
// useGpgCmd()
//
// sign configurations.runtimeElements
//}
// 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
}
task buildDockerImage(type: Exec) {
group = 'docker'
description = 'Builds the Docker image for the application.'
commandLine 'docker', 'build', '-t', 'freerouting/freerouting:2.0.1', '.'
}