-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
198 lines (169 loc) · 6.5 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
import de.undercouch.gradle.tasks.download.Download
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
plugins {
id 'application'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'io.micronaut.application' version '4.2.1'
id 'com.juanmuscaria.tooling.dmm' /* because sometimes we need to make our own tools */
id 'de.undercouch.download' /* version set in the plugin above */
}
ext.gitInfoCached = null
version = "0.0.1-${gitInfo('branch')}-${gitInfo('hash')}"
group = "com.juanmuscaria"
var os = DefaultNativePlatform.currentOperatingSystem
repositories {
mavenCentral()
}
dependencies {
annotationProcessor("org.projectlombok:lombok")
annotationProcessor("info.picocli:picocli-codegen")
annotationProcessor("io.micronaut.serde:micronaut-serde-processor")
implementation("info.picocli:picocli")
implementation("io.micronaut.picocli:micronaut-picocli")
implementation("io.micronaut.serde:micronaut-serde-jackson")
implementation("jakarta.annotation:jakarta.annotation-api")
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("commons-io:commons-io:2.13.0")
implementation("org.fusesource.jansi:jansi:2.4.1")
implementation("io.github.mkpaz:atlantafx-base:2.0.1")
compileOnly("org.projectlombok:lombok")
implementation("ch.qos.logback:logback-classic")
implementation('org.apache.tika:tika-core:2.9.1')
implementation('org.apache.commons:commons-collections4:4.4')
implementation('com.fasterxml.jackson.core:jackson-databind:2.16.1')
implementation('com.fasterxml.jackson.core:jackson-annotations:2.16.1')
implementation('com.fasterxml.jackson.dataformat:jackson-dataformat-toml:2.16.1')
}
graalvmNative {
toolchainDetection = true
binaries {
main {
buildArgs.add("-O4")
}
configureEach {
resources.autodetect()
if (os.isWindows()) {
buildArgs.addAll(
"-H:NativeLinkerOption=/SUBSYSTEM:WINDOWS",
"-H:NativeLinkerOption=/ENTRY:mainCRTStartup",
"-H:NativeLinkerOption='${projectDir}\\src\\main\\windows\\dmm.res'",
)
}
}
}
}
application {
mainClass.set("com.juanmuscaria.dmm.ModManagerCommand")
}
micronaut {
testRuntime("junit5")
processing {
incremental(true)
annotations("com.juanmuscaria.*")
}
}
tasks.register('downloadBepInExUnix', Download) {
group("BepInEx")
src "https://github.com/BepInEx/BepInEx/releases/download/v${project.property('BepInExVersion')}/BepInEx_unix_${project.property('BepInExVersion')}.0.zip"
dest layout.buildDirectory.map { it.file("BepInExUnix.zip")}
overwrite false
}
tasks.register('downloadBepInExWin', Download) {
group("BepInEx")
src "https://github.com/BepInEx/BepInEx/releases/download/v${project.property('BepInExVersion')}/BepInEx_x86_${project.property('BepInExVersion')}.0.zip"
dest layout.buildDirectory.map { it.file("BepInExWin.zip")}
overwrite false
}
tasks.register("repackBepInExWin", Zip) {
group("BepInEx")
dependsOn("downloadBepInExWin")
from(zipTree("${layout.buildDirectory.get()}/BepInExWin.zip")) {
exclude("changelog.txt", "doorstop_config.ini")
}
from("$projectDir/src/main/repack")
archiveFileName = "${layout.buildDirectory.get()}/repack/win.zip"
}
tasks.register("repackBepInExUnix", Zip) {
group("BepInEx")
dependsOn("downloadBepInExUnix")
from(zipTree("${layout.buildDirectory.get()}/BepInExUnix.zip")) {
exclude("changelog.txt", "run_bepinex.sh")
}
from("$projectDir/src/main/repack")
archiveFileName = "${layout.buildDirectory.get()}/repack/unix.zip"
}
tasks.register("repackBepInEx") {
group("BepInEx")
dependsOn("repackBepInExUnix", "repackBepInExWin")
}
tasks.register("installDotnetSdk", Exec) {
group('dotnet')
workingDir = "$projectDir/dotnet"
if (os.isWindows()) {
commandLine 'cmd', '/c', 'Powershell -File dotnet-install.ps1'
} else {
commandLine './dotnet-install.sh'
}
// dotnet-install.sh accepts the same arguments as the powershell version, but not the other way around...
args += ['-InstallDir', 'sdk', '-NoPath', '-Channel', '6.0']
}
tasks.register("updateNuGetDependencies", Exec) {
group('dotnet')
dependsOn('installDotnetSdk')
workingDir = "$projectDir/modloader"
if (os.isWindows()) {
commandLine 'cmd', '/c', file("$projectDir/dotnet/sdk/dotnet.exe").getAbsolutePath()
} else {
commandLine file("$projectDir/dotnet/sdk/dotnet").getAbsolutePath()
}
args += ['restore']
}
tasks.register("buildModloader", Exec) {
group('dotnet')
dependsOn('updateNuGetDependencies')
workingDir = "$projectDir/modloader"
if (os.isWindows()) {
commandLine 'cmd', '/c', file("$projectDir/dotnet/sdk/dotnet.exe").getAbsolutePath()
} else {
commandLine file("$projectDir/dotnet/sdk/dotnet").getAbsolutePath()
}
args += ['msbuild']
}
processResources {
dependsOn("repackBepInEx", "buildModloader")
from("${rootProject.layout.buildDirectory.get()}/repack")
from("$projectDir/modloader/bin/Debug/net35/modloader.dll")
inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs) {
include 'application.properties'
expand 'version':project.version
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
run {
//jvmArgs += "-agentlib:native-image-agent=config-merge-dir=../src/main/resources/META-INF/native-image"
jvmArgs += '-Ddmm.installer=false'
jvmArgs += '-Djansi.mode=force'
jvmArgs += '-Dpicocli.ansi=true'
workingDir = rootProject.layout.buildDirectory
}
def gitInfo(String key) {
if (!gitInfoCached) {
if (file('.git').exists()) {
gitInfoCached = [
hash : ['git', 'log', "--format=%h", '-n', '1'].execute().text.trim(),
fullHash: ['git', 'log', "--format=%H", '-n', '1'].execute().text.trim(),
branch : ['git', 'symbolic-ref', '--short', 'HEAD'].execute().text.trim(),
message : ['git', 'log', "--format=%B", '-n', '1'].execute().text.trim()
]
} else {
gitInfoCached = [
hash : 'NOT_A_GIT',
fullHash: 'NOT_A_GIT',
branch : 'NOT_A_GIT',
message : 'NOT_A_GIT'
]
}
}
return key ? gitInfoCached[key] : gitInfoCached
}