-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.gradle.kts
214 lines (179 loc) · 6.66 KB
/
build.gradle.kts
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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
idea
java
id("com.github.johnrengelman.shadow") version "7.1.2"
id("com.google.protobuf") version "0.9.4"
id("com.gtnewhorizons.retrofuturagradle") version "1.3.35"
}
idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
}
}
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:4.26.1"
}
}
val nesqlExporterVersion: String by project
group = "com.github.dcysteine.nesql.exporter"
version = nesqlExporterVersion
val minecraftVersion: String by project
minecraft {
mcVersion.set(minecraftVersion)
injectedTags.put("EXPORTER_VERSION", project.version)
}
val shadowImplementation: Configuration by configurations.creating {
configurations["implementation"].extendsFrom(this)
}
val shadowRuntime: Configuration by configurations.creating {
configurations["runtimeOnly"].extendsFrom(this)
}
repositories {
maven("https://nexus.gtnewhorizons.com/repository/public/") {
name = "GTNH Maven"
}
maven("https://cursemaven.com") {
name = "Curse Maven"
}
/*
* This repo seems to be broken...
maven("https://maven.ic2.player.to") {
name = "IC2 Maven"
metadataSources {
mavenPom()
artifact()
}
content {
includeGroup("net.industrial-craft")
}
}
*/
maven("https://maven2.ic2.player.to") {
name = "IC2 Maven2"
metadataSources {
mavenPom()
artifact()
}
content {
includeGroup("net.industrial-craft")
}
}
maven("https://gregtech.overminddl1.com") {
content {
includeGroup("thaumcraft")
}
}
}
dependencies {
val autoValueVersion: String by project
compileOnly("com.google.auto.value:auto-value-annotations:$autoValueVersion")
annotationProcessor("com.google.auto.value:auto-value:$autoValueVersion")
val protoBufferVersion: String by project
shadowImplementation("com.google.protobuf:protobuf-java:$protoBufferVersion")
val lombokVersion: String by project
compileOnly("org.projectlombok:lombok:$lombokVersion")
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
val springDataVersion: String by project
shadowImplementation("org.springframework.data:spring-data-jpa:$springDataVersion")
val jakartaPersistenceVersion: String by project
compileOnly("jakarta.persistence:jakarta.persistence-api:$jakartaPersistenceVersion")
val hibernateVersion: String by project
shadowImplementation("org.hibernate:hibernate-core-jakarta:$hibernateVersion")
annotationProcessor("org.hibernate:hibernate-jpamodelgen-jakarta:$hibernateVersion")
val hsqldbVersion: String by project
shadowRuntime("org.hsqldb:hsqldb:$hsqldbVersion:jdk8")
val postgresqlVersion: String by project
shadowRuntime("org.postgresql:postgresql:$postgresqlVersion")
val neiVersion: String by project
implementation("com.github.GTNewHorizons:NotEnoughItems:$neiVersion:dev")
val mobsInfoVersion: String by project
implementation("com.github.GTNewHorizons:Mobs-Info:$mobsInfoVersion:dev")
val avaritiaVersion: String by project
implementation("com.github.GTNewHorizons:Avaritia:$avaritiaVersion:dev")
val gregTech5Version: String by project
implementation("com.github.GTNewHorizons:GT5-Unofficial:$gregTech5Version:dev")
val thaumcraftVersion: String by project
implementation("thaumcraft:Thaumcraft:$minecraftVersion-$thaumcraftVersion:dev")
val thaumcraftNeiVersion: String by project
implementation("curse.maven:thaumcraft-nei-plugin-225095:$thaumcraftNeiVersion")
val betterQuestingVersion: String by project
implementation("com.github.GTNewHorizons:BetterQuesting:$betterQuestingVersion:dev")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.withType<Jar> {
// Replace version in mcmod.info
filesMatching("mcmod.info") {
expand(
mapOf(
"version" to project.version,
"mcversion" to minecraftVersion,
)
)
}
archiveBaseName.set("NESQL-Exporter")
}
tasks.injectTags.configure {
outputClassName.set("com.github.dcysteine.nesql.Tags")
}
// Unfortunately, we can neither minimize the shadow jar nor relocate it,
// because Hibernate seems to reference classes indirectly and so we would break it.
//
// We also can't relocate it because it does not include the mod code, so we would need to relocate
// the code separately.
//
// I had to make this a separate deps jar rather than a single shadow jar that contains both the
// deps and the mod code. The reason appears to be some kind of weird bug where trying to include
// the mod code causes org.slf4j, specifically, to not get picked up somehow, resulting in a
// ClassNotFoundException at runtime. Oddly enough, copying that single directory verbatim out of
// the shadow jar and into a separate jar fixes the issue.
//
// I spent way too long trying to figure out what went wrong, so I'm giving up and making this a
// separate jar. This does have the side benefit of speeding up build times, since deps don't change
// very often.
val depsJar by tasks.creating(ShadowJar::class) {
// If mod code were to actually be included, we'd need this to use the obfuscated mod code.
//from(tasks["reobf"].outputs)
configurations = listOf(shadowImplementation, shadowRuntime)
/*
* Doesn't look like we actually need class path.
manifest {
val classPath = (shadowImplementation + shadowRuntime).joinToString(" ") { it.name }
attributes("Class-Path" to classPath)
}
*/
// Remove mod code and other junk from jar.
val excludeFun =
fun(fileTreeElement: FileTreeElement): Boolean {
val path = fileTreeElement.path
val keep = path.endsWith(".jar")
val remove = !path.contains("/") || path.startsWith("META-INF") || path.startsWith(project.group.toString())
return remove && !keep
}
exclude(excludeFun)
archiveClassifier.set("deps")
}
val sourcesJar by tasks.creating(Jar::class) {
from(sourceSets.main.get().allSource)
from("$projectDir/LICENSE.md")
archiveClassifier.set("sources")
}
// Export SQL Schema for NESQL Server.
val sqlJar by tasks.creating(Jar::class) {
from(sourceSets.main.get().output)
from(sourceSets.injectedTags.get().output)
exclude("com/github/dcysteine/nesql/exporter")
exclude("*.proto")
exclude("META-INF")
exclude("mcmod.info")
archiveClassifier.set("sql")
}
artifacts {
archives(depsJar)
archives(sourcesJar)
archives(sqlJar)
}