generated from Legacy-Fabric/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
187 lines (156 loc) · 5.35 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
import com.diffplug.gradle.spotless.JavaExtension
plugins {
id 'java-library'
id 'com.diffplug.spotless' version "6.12.0"
id 'fabric-loom' version "1.7-SNAPSHOT" apply false // To use chocoloom, change the version to a commit hash
id 'legacy-looming' version "1.7-SNAPSHOT" apply false // Version must be the same as fabric-loom's
id 'maven-publish'
id "com.modrinth.minotaur" version "2.+"
}
def displayVersion = project.mod_version + "+" + project.minecraft_version
def debug = true
def branch = System.getenv("GITHUB_REF_NAME") == null ? "-forge" : System.getenv("GITHUB_REF_NAME")
if (!branch.endsWith("-forge")) {
debug = false
}
allprojects {
apply plugin: "maven-publish"
apply plugin: "java-library"
apply plugin: "fabric-loom"
apply plugin: "legacy-looming"
version = project.mod_version
group = project.maven_group
repositories {
mavenLocal()
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
flatDir {
dirs (rootProject.rootDir.toString() + "/lib", rootProject.rootDir.toString() + "/mods")
}
maven {
name = "Jitpack"
url 'https://jitpack.io/'
}
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings legacy.yarn(project.minecraft_version, project.yarn_mappings)
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modApi("maven.modrinth:mod-remapping-api:${project.mod_remapping_api}")
modApi("maven.modrinth:spasm:${project.spasm_version}")
implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${project.mixin_extras_version}"))
implementation(group: "local", name: "argo", version: "2.25")
implementation(group: "local", name: "guava", version: "12.0.1")
modImplementation(legacy.apiModule("legacy-fabric-logger-api-v1", "1.9.0+1.8.9"))
implementation("com.github.thecatcore.CursedMixinExtensions:fabric:1.0.0")
}
base {
archivesName = project.archives_base_name + "-" + project.minecraft_version
}
processResources {
inputs.property "version", project.version
inputs.property "mc_version", project.minecraft_version
inputs.property "mrapi_version", project.mod_remapping_api
filesMatching("fabric.mod.json") {
expand "version": project.version,
"mc_version": rootProject.minecraft_version,
"mrapi_version": project.mod_remapping_api
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (JavaVersion.current().isJava9Compatible()) it.options.release = 8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${base.archivesName.get()}" }
}
}
tasks.withType(JavaCompile) {
options.deprecation = true
}
}
loom {
accessWidenerPath = file("src/main/resources/fabricated-forge.accesswidener")
}
dependencies {
include(group: "local", name: "argo", version: "2.25")
include(group: "local", name: "guava", version: "12.0.1")
modRuntimeOnly(files("./forge-${project.minecraft_version}-${project.forge_version}-universal-intermediary.jar"))
}
subprojects {
dependencies {
api(project.dependencies.project(path: ":", configuration: 'namedElements'))
}
}
remapJar {
afterEvaluate {
subprojects.each {
// Include the jar from the sub project.
nestedJars.from project("${it.path}").tasks.getByName("remapJar")
}
}
}
jar {
from("licensing.md")
from("LICENSE-fml.txt")
from("CREDITS-fml.txt")
from("MinecraftForge-Credits.txt")
from("MinecraftForge-License.txt")
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}
spotless {
format('fml', JavaExtension) {
licenseHeaderFile(rootProject.file("HEADER_FML"))
target 'src/*/java/cpw/mods/**/*.java', 'src/*/java/net/minecraft/*.java'
}
format('forge', JavaExtension) {
licenseHeaderFile(rootProject.file("HEADER_FORGE"))
target 'src/*/java/net/minecraftforge/**/*.java'
}
}
modrinth {
token = System.getenv("MODRINTH_TOKEN") == null ? "dev" : System.getenv("MODRINTH_TOKEN") // This is the default. Remember to have the MODRINTH_TOKEN environment variable set or else this will fail, or set it to whatever you want - just make sure it stays private!
projectId = "JpHZ1Cyv" // This can be the project ID or the slug. Either will work!
versionName = displayVersion
changelog = """
Fix IC2 crash because of bad reflection again
"""
uploadFile = remapJar
gameVersions = [project.minecraft_version] // Must be an array, even with only one version
debugMode = debug
dependencies { // A special DSL for creating dependencies
// scope.type
// The scope can be `required`, `optional`, `incompatible`, or `embedded`
// The type can either be `project` or `version`
required.project("mod-remapping-api")
}
}