This repository has been archived by the owner on Dec 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathbuild.gradle
230 lines (197 loc) · 7.2 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
plugins {
id 'eclipse'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.+'
id 'com.matthewprenger.cursegradle' version '1.4.+'
id 'org.ajoberstar.grgit' version '5.+'
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version "1.+"
}
def branch = grgit.branch.current()
println "On branch: ${branch.fullName}"
println "Pipeline branch: " + (System.getenv('CI_COMMIT_BRANCH') ?: 'NONE')
group = 'com.github.percivalalb'
archivesBaseName = "DoggyTalents-${project.target_mc_version}"
version = (grgit.describe(longDescr: true, tags: true) ?: '0-0-0').split('-').with { it -> "${it[0]}.${it[1]}" }
println "Version: ${version}"
println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
sourceSets {
api
main {
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
resources.srcDirs += 'src/generated/resources'
}
test {
compileClasspath += sourceSets.api.output
runtimeClasspath += sourceSets.api.output
}
}
configurations {
apiImplementation.extendsFrom(implementation)
apiRuntimeOnly.extendsFrom(runtimeOnly)
}
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
repositories {
maven {
name = "Progwml6 maven"
url "https://dvs1.progwml6.com/files/maven"
content { includeGroup "mezz.jei" }
}
maven {
name = "ModMaven"
url "https://modmaven.dev"
content { includeGroup "mezz.jei" }
}
}
minecraft {
mappings channel: project.mcp_channel, version: project.mcp_mappings
accessTransformer = project.file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
taskName 'doggytalents_client'
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'doggytalents'
mods {
doggytalents.sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
server {
taskName 'doggytalents_server'
workingDirectory project.file('run-server')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'doggytalents'
mods {
doggytalents.sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
gameTestServer {
taskName 'doggytalents_test'
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'doggytalents'
mods {
doggytalents.sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
data {
taskName 'doggytalents_data'
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
args '--mod', 'doggytalents', '--all', '--output', '"' + project.file('src/generated/resources/') + '"', '--existing', '"' + sourceSets.main.resources.srcDirs[0] + '"'
mods {
doggytalents.sources((SourceSet[]) [sourceSets.main, sourceSets.api])
}
}
}
}
dependencies {
minecraft "net.minecraftforge:forge:${project.forge_version}"
compileOnly fg.deobf("mezz.jei:jei-${project.jei_mc_version}-common-api:${project.jei_version}")
compileOnly fg.deobf("mezz.jei:jei-${project.jei_mc_version}-forge-api:${project.jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${project.jei_mc_version}-forge:${project.jei_version}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
}
task sourcesJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier = 'sources'
from sourceSets.main.allJava
from sourceSets.api.allJava
}
task apiJar(type: Jar) {
duplicatesStrategy(DuplicatesStrategy.FAIL)
archiveClassifier = 'api'
from sourceSets.api.output
from sourceSets.api.allJava
}
artifacts {
archives sourcesJar
archives apiJar
}
def replaceResources = tasks.register('replaceResources', Copy) {
it.outputs.upToDateWhen { false }
it.from(sourceSets.main.resources) {
include 'META-INF/mods.toml'
expand([
'version': project.version,
'minecraft_version_range': project.minecraft_version_range,
'forge_version_range': project.forge_version_range,
'fml_version_range': project.fml_version_range,
])
}
it.into "$buildDir/resources/main/"
}
processResources {
duplicatesStrategy(DuplicatesStrategy.FAIL)
exclude('META-INF/mods.toml')
configure { finalizedBy(replaceResources) }
}
classes.configure {
dependsOn(replaceResources)
}
jar {
from sourceSets.main.output
from sourceSets.api.output
manifest {
attributes([
"Specification-Title": "Doggy Talents",
"Specification-Vendor": "percivalalb",
"Specification-Version": project.version, // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": project.version,
"Implementation-Vendor" :"percivalalb",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
test {
useJUnitPlatform()
}
task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
file = project.file("build/changelog.html")
untaggedName = "Current release ${project.version}"
fromCommit = 'f594ba81ba02d04a2189b6cf15216d2afb6943ba'
toRef = 'HEAD'
templateContent = project.file('changelog.mustache').getText('UTF-8')
}
curseforge {
apiKey = findProperty('curseforge_api_key') ?: 0
project {
id = project.curseforge_project_id
changelog = project.file("build/changelog.html")
changelogType = 'html'
releaseType = findProperty("curseforge_release_type") ?: 'alpha'
addGameVersion project.target_mc_version
for (String v : project.additional_mc_versions.split(',')) {
if (v) {
addGameVersion v
}
}
addArtifact apiJar
}
options {
detectNewerJava = true
}
}
// Must be done in afterEvaluate as the specific curseforge$id
// task is generated lazily
afterEvaluate {
tasks.named("curseforge${project.curseforge_project_id}").get().dependsOn.add(makeChangelog)
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
if (project.hasProperty('UPDATE_MAPPINGS')) {
extractRangeMap {
sources sourceSets.api.java.srcDirs
}
applyRangeMap {
sources sourceSets.api.java.srcDirs
}
sourceSets.api.java.srcDirs.each { extractMappedNew.addTarget it }
}