forked from SuperMartijn642/AdditionalLanterns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
200 lines (166 loc) · 6.68 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
buildscript {
repositories {
maven { url = "https://files.minecraftforge.net/maven" }
mavenCentral()
}
dependencies {
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "5.1.+", changing: true
classpath "org.spongepowered:mixingradle:0.7.+"
}
}
plugins {
id "com.matthewprenger.cursegradle" version "1.4.0"
id "com.modrinth.minotaur" version "2.+"
}
apply plugin: "net.minecraftforge.gradle"
apply plugin: "eclipse"
apply plugin: "org.spongepowered.mixin"
version = project.mod_version + "-forge-" + project.minecraft_suffix
group = project.maven_group
archivesBaseName = project.mod_id
java.toolchain.languageVersion = JavaLanguageVersion.of(project.java_target)
println("Java: " + System.getProperty("java.version") + " JVM: " + System.getProperty("java.vm.version") + "(" + System.getProperty("java.vendor") + ") Arch: " + System.getProperty("os.arch"))
repositories {
flatDir {
dirs "libs"
}
maven {
url "https://www.cursemaven.com"
}
}
dependencies {
// Forge
minecraft "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}"
// Core library
implementation fg.deobf("curse.maven:supermartijn642s-core-lib-454372:${project.core_library_file}")
// Config library
// implementation fg.deobf("curse.maven:supermartijn642s-config-lib-438332:${project.config_library_file}")
// Just Enough Items
runtimeOnly fg.deobf("curse.maven:jei-238222:${project.just_enough_items_file}")
// Block Renderer
runtimeOnly fg.deobf("curse.maven:block-renderer-380456:${project.block_renderer_file}")
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir "src/generated/resources" }
processResources {
inputs.property "version", project.version
filesMatching(["META-INF/mods.toml", "modid.mixins.json", "pack.mcmeta"]) {
expand project.properties
}
exclude "**/*.pdn"
rename "^modid.mixins.json\$", "${project.mod_id}.mixins.json"
rename "^icon.png\$", "${project.mod_id}.png"
}
minecraft {
mappings channel: "official", version: project.minecraft_version
// accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg")
runs {
client {
workingDirectory project.file("run")
property "forge.logging.markers", "REGISTRIES"
mods {
source sourceSets.main
}
}
server {
workingDirectory project.file("run")
property "forge.logging.markers", "REGISTRIES"
mods {
source sourceSets.main
}
}
data {
workingDirectory project.file("run")
property "forge.logging.markers", "REGISTRIES"
args "--mod", project.mod_id, "--all", "--output", file("src/generated/resources/"), "--existing", file("$buildDir/data_resources")
mods {
source sourceSets.main
}
}
}
}
task prepareDataResources(type: Sync) {
from file("src/main/resources")
into "$buildDir/data_resources"
inputs.property "version", version
filesMatching(["META-INF/mods.toml", "modid.mixins.json", "pack.mcmeta"]) {
expand project.properties
}
exclude "**/*.pdn"
rename "^modid.mixins.json\$", "${project.mod_id}.mixins.json"
rename "^icon.png\$", "${project.mod_id}.png"
}
// Run prepareDataResources before prepareRunData
tasks.whenTaskAdded {
if (it.name == "prepareRunData")
it.dependsOn "prepareDataResources"
}
// CurseGradle settings for uploading to CurseForge
curseforge {
project {
// Get the CurseForge token from the environment variables
apiKey = System.getenv("CURSEFORGE_TOKEN")
// Copy settings from gradle.properties
id = project.curseforge_project_id
releaseType = project.curseforge_release_type
project.curseforge_game_versions.split(" ").each it::addGameVersion
addGameVersion("Forge")
addGameVersion("NeoForge")
// Point to 'changelog' setting to a the changelog file
changelog = file("changelog.md")
changelogType = "markdown"
if (!project.curseforge_required_dependency_ids.isEmpty() || !project.curseforge_optional_dependency_ids.isEmpty()) {
relations {
// Required dependencies
if (!project.curseforge_required_dependency_ids.isEmpty())
project.curseforge_required_dependency_ids.split(" ").each it::requiredDependency
// Optional dependencies
if (!project.curseforge_optional_dependency_ids.isEmpty())
project.curseforge_optional_dependency_ids.split(" ").each it::optionalDependency
}
}
mainArtifact(jar) {
displayName = "${project.mod_name} ${project.mod_version} for Forge ${project.minecraft_suffix.substring(2)}"
}
}
options {
// Don't add project Java version
javaVersionAutoDetect = false
}
}
// Move CurseGradle's tasks from 'upload' to 'publishing'
project.gradle.taskGraph.whenReady {
tasks.stream().filter(task -> task.group.equals "upload").each { task -> task.group = "publishing" }
}
// Minotaur settings for uploading to Modrinth
modrinth {
// Get the Modrinth token from the environment variables
token = System.getenv("MODRINTH_TOKEN")
// Copy settings from gradle.properties
projectId = project.modrinth_project_id
versionNumber = version
versionType = project.modrinth_release_type // Can be either 'release', 'alpha', or 'beta'
versionName = "${project.mod_name} ${project.mod_version}"
gameVersions = project.modrinth_game_versions.split(" ") as List
// Convert the changelog file to text
changelog = file("changelog.md").text
uploadFile = jar // With Loom, this MUST be set to `remapJar` instead of `jar`!
loaders = ["forge", "neoforge"]
if (!project.modrinth_required_dependency_ids.isEmpty() || !project.modrinth_optional_dependency_ids.isEmpty()) {
dependencies {
// Required dependencies
if (!project.modrinth_required_dependency_ids.isEmpty())
project.modrinth_required_dependency_ids.split(" ").each required::project
// Optional dependencies
if (!project.modrinth_optional_dependency_ids.isEmpty())
project.modrinth_optional_dependency_ids.split(" ").each optional::project
}
}
}
// Create a task to upload to both CurseForge and Modrinth
task publishAll {
group "publishing"
dependsOn("curseforge", "modrinth")
// Also build the file so I have a copy locally
dependsOn "build"
}