-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
142 lines (121 loc) · 4.72 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
plugins {
id 'application'
id 'org.graalvm.buildtools.native' version '0.10.4'
}
tasks.wrapper {
gradleVersion = '8.12'
distributionType = Wrapper.DistributionType.ALL
}
group = 'com.github.chirontt.jgit'
description = "JGit HTTP server's native executable built by GraalVM"
version = '7.1.0'
ext {
mainClassName = 'com.github.chirontt.gitserver.JGitHttpServer'
jgitReleaseVersion = '7.1.0.202411261347-r'
jettyVersion = '11.0.24'
slf4jVersion = '2.0.16'
}
repositories {
mavenCentral()
mavenLocal()
}
compileJava {
options.release = 11 //use JDK11+ for compiling & running
options.encoding = 'UTF-8'
}
dependencies {
implementation "org.eclipse.jgit:org.eclipse.jgit.http.server:$jgitReleaseVersion"
implementation "org.eclipse.jgit:org.eclipse.jgit.lfs.server:$jgitReleaseVersion"
implementation "org.eclipse.jetty:jetty-servlet:$jettyVersion"
implementation "org.slf4j:slf4j-simple:$slf4jVersion"
}
application {
mainClass = project.mainClassName
applicationName = project.name
executableDir = ''
}
run {
//default parameter values for port, base-path, and lfs-path
args = ['8080', '/git', '/git-lfs-storage']
//get system properties specified from the command line (for debugging, etc.)
//and pass them on to the running application's JVM
systemProperties = System.getProperties()
jvmArgs = [
//use the following jvmArgs for as many different run scenarios as possible,
//and for all the code-execution paths as much as possible,
//to generate (or merge with) the GraalVM native-image configuration files
//in the src/main/resources/META-INF/native-image directory.
//This directory is read by GraalVM during the native-image build.
//"-agentlib:native-image-agent=config-merge-dir=src/main/resources/META-INF/native-image",
//enable debug logs of various subsystems
//'-Djava.security.debug=all',
//'-Djavax.net.debug=all',
'-Dorg.eclipse.jetty.LEVEL=DEBUG',
]
}
//create a stand-alone executable uber jar
//including all dependencies
task uberJar(type: Jar) {
with jar
archiveClassifier = 'no-deps'
manifest {
attributes(
'Main-Class': project.mainClassName,
'Built-By': System.getProperty('user.name'),
'Created-By': System.getProperty('java.runtime.version') + ' (' + System.getProperty('java.vendor') + ')',
'Gradle-Version': 'Gradle ' + gradle.getGradleVersion(),
'Multi-Release': 'true',
)
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
duplicatesStrategy 'exclude'
}
graalvmNative {
toolchainDetection = false
binaries {
main {
imageName = project.name
mainClass = project.mainClassName
debug = true
verbose = true
fallback = false
//packages/classes to be initialized at native image build time
def buildTimeInitClasses = [
'com.google.gson',
'jakarta.servlet',
'org.eclipse.jetty',
'org.eclipse.jgit',
'org.slf4j',
]
//packages/classes to be initialized at native image run time
def runTimeInitClasses = [
'org.eclipse.jgit.internal.storage.file.WindowCache',
'org.eclipse.jgit.lib.internal.WorkQueue',
'org.eclipse.jgit.lib.RepositoryCache',
'org.eclipse.jgit.transport.HttpAuthMethod',
]
//packages/classes to be re-initialized at native image run time
def runTimeReInitClasses = [
//all org.eclipse.jgit classes are initialized at build time
//(specified above), but due to SecureRandom seeding
//in their static initialization blocks, some JGit classes need be
//re-initialized at native image run time:
'org.eclipse.jgit.util.FileUtils:rerun',
]
buildArgs.add('--enable-url-protocols=http,https')
buildArgs.add('--initialize-at-build-time=' + buildTimeInitClasses.join(','))
buildArgs.add('--initialize-at-run-time=' + runTimeInitClasses.join(','))
buildArgs.add('-H:ClassInitialization=' + runTimeReInitClasses.join(','))
buildArgs.add('-march=compatibility') //only available in GraalVM for JDK 17+
useFatJar = false
}
}
}
tasks.named("nativeCompile") {
//use the uber jar if long classpath becomes a problem in Windows:
//dependsOn uberJar
//classpathJar = uberJar.archiveFile
}