forked from Melledy/LunarCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
213 lines (168 loc) · 5.53 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
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* User Manual available at https://docs.gradle.org/5.6.3/userguide/tutorial_java_projects.html
*/
plugins {
// Apply the application plugin to add support for building a CLI application
id 'application'
// Apply the java plugin to add support for Java
id 'java'
// Protoc plugin
id 'com.google.protobuf' version '0.8.19'
id 'eclipse'
id 'idea'
}
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
version = '1.0.1'
var shouldGenerateProto = System.getenv("GENERATE_PROTO") == "true"
System.out.println(shouldGenerateProto ?
"Generating proto files" :
"Skipping proto generation")
repositories {
mavenCentral()
jcenter()
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.24.3'
}
plugins {
quickbuf {
artifact = 'us.hebi.quickbuf:protoc-gen-quickbuf:1.3.1'
}
}
generateProtoTasks {
all().each { task ->
task.builtins {
remove java
}
task.plugins {
quickbuf {
//option 'store_unknown_fields=true'
outputSubDir = ''
}
}
}
}
generatedFilesBaseDir = "$projectDir/src/generated/"
}
dependencies {
implementation fileTree(dir: 'lib', include: ['*.jar'])
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.9'
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.4.14'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.14'
implementation group: 'it.unimi.dsi', name: 'fastutil-core', version: '8.5.12'
implementation group: 'org.reflections', name: 'reflections', version: '0.10.2'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
implementation group: 'us.hebi.quickbuf', name: 'quickbuf-runtime', version: '1.3.1'
implementation group: 'io.javalin', name: 'javalin', version: '5.6.3'
implementation group: 'io.netty', name: 'netty-common', version: '4.1.101.Final'
implementation group: 'io.netty', name: 'netty-handler', version: '4.1.101.Final'
implementation group: 'io.netty', name: 'netty-transport-native-epoll', version: '4.1.101.Final'
implementation group: 'io.netty', name: 'netty-transport-native-kqueue', version: '4.1.101.Final'
implementation group: 'dev.morphia.morphia', name: 'morphia-core', version: '2.3.9'
implementation group: 'de.bwaldvogel', name: 'mongo-java-server', version: '1.44.0'
implementation group: 'de.bwaldvogel', name: 'mongo-java-server-h2-backend', version: '1.44.0'
implementation group: 'org.jline', name: 'jline', version: '3.24.1'
implementation group: 'org.jline', name: 'jline-terminal-jansi', version: '3.24.1'
protobuf files('proto/')
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
}
configurations.all {
exclude group: 'org.slf4j', module: 'slf4j'
}
clean {
if (shouldGenerateProto) {
delete protobuf.generatedFilesBaseDir
}
}
application {
// Define the main class for the application
mainClassName = 'emu.lunarcore.LunarCore'
}
jar {
dependsOn 'injectGitHash'
exclude '*.proto'
manifest {
attributes 'Main-Class': 'emu.lunarcore.LunarCore'
}
jar {
archiveBaseName = 'LunarCore'
archiveVersion = ''
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.INCLUDE
from('src/main/java') {
include '*.xml'
}
getDestinationDirectory().set(file("."))
}
sourceSets {
main {
proto {
srcDir 'src/generated'
}
java {
srcDir 'src/main/java'
}
}
}
idea {
module {
// proto files and generated Java files are automatically added as
// source dirs.
// If you have additional sources, add them here:
sourceDirs += file('/proto/')
}
}
eclipse {
classpath {
file.whenMerged { cp ->
cp.entries.add( new org.gradle.plugins.ide.eclipse.model.SourceFolder('src/generated/main/', null) )
}
}
}
tasks.register('injectGitHash') {
def gitCommitHash = {
try {
return 'git rev-parse --verify --short HEAD'.execute().text.trim()
} catch (ignored) {
return ''
}
}
def gitCommitTime = {
try {
return 'git log -1 --format=%cd --date=iso'.execute().text.trim()
} catch (ignored) {
return ''
}
}
new File(project.projectDir.getAbsolutePath() + '/src/main/java/emu/lunarcore/BuildConfig.java').text = """
package emu.lunarcore;
public final class BuildConfig {
public static final String VERSION = \"${version}\";
public static final String GIT_HASH = \"${gitCommitHash()}\";
public static final String GIT_HASH_TIME = \"${gitCommitTime()}\";
}
"""
}
task updateProto {
group 'Build'
description 'Cleans generated proto folder and regenerates protos'
if (shouldGenerateProto) {
dependsOn 'clean'
}
dependsOn 'generateProto'
}
processResources {
dependsOn 'generateProto'
}