-
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbuild.gradle
More file actions
154 lines (126 loc) · 4.19 KB
/
build.gradle
File metadata and controls
154 lines (126 loc) · 4.19 KB
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
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.moddev' version '1.0.23'
}
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
ext.early = true
apply from: 'project.gradle'
project.ext.package = project.ext.group + '.' + project.ext.projectName.toLowerCase()
if (project.ext.useElytraVersionFormat) {
def branch
if (System.env.BRANCH_NAME) {
// Jenkins support
branch = System.env.BRANCH_NAME
branch = branch.substring(branch.lastIndexOf('/') + 1)
} else {
branch = 'git rev-parse --abbrev-ref HEAD'.execute().in.text.trim()
}
if (branch == "HEAD") {
branch = 'git rev-parse --short HEAD'.execute().in.text.trim()
}
def commits = 'git rev-list --count HEAD'.execute().in.text.trim()
def dirty = !'git diff-index HEAD'.execute().in.text.trim().isEmpty()
version = branch + '-' + project.ext.version + '.' + commits + (dirty ? '-dirty' : '')
} else {
version = project.ext.version
}
group = project.ext.group
archivesBaseName = project.ext.projectName
ext {
compoundClassesDir = file('build/compound')
}
configurations {
shade
}
repositories {
maven { url = 'https://repo.tridevmc.com/' }
}
neoForge {
version = neoForgeVersion
if (mappingsChannel == "parchment") {
parchment {
mappingsVersion = project.mappingsVersion
minecraftVersion = project.mappingsMinecraftVersion
}
}
runs {
client {
client()
systemProperty 'neoforge.enabledGameTestNamespaces', project.ext.projectName
}
server {
server()
programArgument '--nogui'
systemProperty 'neoforge.enabledGameTestNamespaces', project.ext.projectName
}
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', project.ext.projectName
}
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
logLevel = org.slf4j.event.Level.DEBUG
}
}
mods {
// define mod <-> source bindings
// these are used to tell the game which sources are for which mod
// mostly optional in a single mod project
// but multi mod projects should define one per mod
"${project.projectName}" {
sourceSet(sourceSets.main)
}
}
}
configurations {
runtimeClasspath.extendsFrom localRuntime
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
minecraft_version : project.ext.minecraftVersion, minecraft_version_range: project.ext.minecraftVersionRange,
neo_version : project.ext.neoForgeVersion, neo_version_range: project.ext.neoForgeVersionRange,
loader_version_range: project.ext.loaderVersionRange,
mod_id : project.ext.projectName, mod_version: version
]
inputs.properties replaceProperties
filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties + [project: project]
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
def needsShadow = !project.ext.compoundModules.isEmpty()
if (needsShadow) {
dependencies {
for (String module : project.ext.compoundModules) {
def moduleIdentifier = 'com.tridevmc.compound:compound-' + module + ':' + project.ext.compoundVersion
implementation(moduleIdentifier)
shade(moduleIdentifier)
}
}
tasks.build.dependsOn shadowJar
artifacts {
archives shadowJar
}
jar {
archiveClassifier = 'slim'
}
shadowJar {
configurations = [project.configurations.shade]
relocate 'com.tridevmc.compound', project.ext.projectPackage + '.com.tridevmc.compound'
}
assemble.dependsOn shadowJar
}
ext.early = false
apply from: 'project.gradle'
if (file('private.gradle').exists()) {
apply plugin: 'maven-publish'
apply from: 'private.gradle'
}