-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
199 lines (170 loc) · 5.74 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
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath group: 'com.modrinth.minotaur', name: 'Minotaur', version: '2.+'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+'
}
}
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'net.darkhax.curseforgegradle' version '1.+'
}
apply plugin: "com.modrinth.minotaur"
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'java'
version = "${project.mod_version}+${project.minecraft_version}"
group = project.group_id
archivesBaseName = "${project.mod_id}"
repositories {
maven {
url = 'https://maven.parchmentmc.org'
}
}
/* Use the same compile and runtime classpath in the Example Mod */
sourceSets {
examplemod {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
}
}
configurations {
examplemodImplementation.extendsFrom implementation
}
dependencies {
implementation 'org.jetbrains:annotations:23.0.0'
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
// parchment("org.parchmentmc.data:parchment-${project.minecraft_version}:${project.parchment_mappings}@zip")
// parchment("org.parchmentmc.data:parchment-1.19.3:${project.parchment_mappings}@zip")
}
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
examplemodImplementation sourceSets.main.output
}
processResources {
inputs.property "version", project.version
filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
}
}
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
withSourcesJar()
withJavadocJar()
}
jar {
dependsOn 'processDocs'
manifest {
attributes([
"Specification-Title" : project.name,
"Specification-Vendor" : project.group_id,
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : "${archiveVersion}",
"Implementation-Vendor" : project.group_id,
"Implementation-Timestamp": getDate()
])
}
}
loom {
runs {// Example of creating a basic run config for tests
exampleMod {
// Copies settings from another run configuration.
inherit client
configName = "ExampleMod Client"
source = sourceSets.examplemod
}
}
}
task processDocs(type: Copy) {
// update docs
from(file("$rootDir/doc/")) {
include '*.html'
expand 'version': project.mod_version,
'date': getDate(),
'mcversion': project.minecraft_version,
'loaderversion': project.fabric_version
}
into "$project.buildDir/doc"
}
if (!project.hasProperty("curseForgeApiKey")) {
ext.curseForgeApiKey = project.findProperty("curseforge_api_key") ?: "notset"
}
if (!project.hasProperty("modrinthApiKey")) {
ext.modrinthApiKey = project.findProperty("modrinth_api_key") ?: "notset"
}
task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
apiToken = "${curseForgeApiKey}"
def mainFile = upload('777581', remapJar)
mainFile.displayName = "${archivesBaseName}-${version}"
mainFile.releaseType = release_type
mainFile.addModLoader('Fabric', 'Quilt')
mainFile.addGameVersion(project.minecraft_version)
mainFile.changelogType = 'html'
mainFile.changelog = file("$project.buildDir/doc/changelog.html")
}
tasks.modrinth.dependsOn(tasks.build)
tasks.modrinth.mustRunAfter(tasks.processDocs)
modrinth {
token = "${modrinthApiKey}"
projectId = "7DOLIJdi"
versionNumber = "${version}"
versionName = "${archivesBaseName}-${version}"
versionType = release_type
uploadFile = remapJar
gameVersions = ["${project.minecraft_version}"]
loaders = ["fabric", "quilt"]
changelog = file("$rootDir/build/doc/changelog.html").exists() ? file("$rootDir/build/doc/changelog.html").text : null
}
// Ensure build is done prior to cursegradle tasks
project.afterEvaluate {
project.tasks.findAll { task ->
(task.name.startsWith('curseforge') || task.name.startsWith('modrinth'))
&& (task.name != 'curseforge' || task.name != 'modrinth')
}.each { projectTask ->
projectTask.dependsOn build
}
}
def getDate() {
def date = new Date()
def formattedDate = date.format(project.dateFormat)
return formattedDate
}
publishing {
repositories {
maven {
name = "FabricScreenLayers"
url = uri("https://jm.gserv.me/repository/maven-releases/")
credentials {
username = project.findProperty("deploy.user") ?: System.getenv("DEPLOY_USER")
password = project.findProperty("deploy.password") ?: System.getenv("DEPLOY_PASSWORD")
}
}
}
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from(components["java"])
}
}
}