generated from minecraft-cursed-legacy/Example-Mod
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
232 lines (195 loc) · 5.22 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
231
232
buildscript {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
maven {
name = 'Jitpack'
url 'https://jitpack.io/'
}
}
dependencies {
classpath 'com.github.Chocohead:Fabric-Loom:3219e42'
}
}
plugins {
id 'checkstyle'
//From https://gitlab.com/barfuin/gradle-taskinfo, useful for checking the order tasks will run
//id 'org.barfuin.gradle.taskinfo' version '1.3.0'
}
def getSubprojectVersion(project, ver) {
return "${project.mod_version}-$ver"
}
def moduleDependencies(Project project, String... projectNames) {
project.with {
def modules = projectNames.collect { dependencies.project(path: ":$it", configuration: 'dev') }
dependencies {
modules.each {
implementationOnly it
}
}
publishing {
publications {
mavenJava(MavenPublication) {
pom.withXml {
addDependency(it, 'compile', *modules)
}
}
}
}
}
}
void addDependency(XmlProvider xml, String scope, Object... dependencies) {
def dependenciesNode = net.fabricmc.loom.util.GroovyXmlUtil.getOrCreateNode(xml.asNode(), 'dependencies')
dependencies.each {dependency ->
dependenciesNode.appendNode('dependency').with {
appendNode('groupId', dependency.group)
appendNode('artifactId', dependency.name)
appendNode('version', dependency.version)
appendNode('scope', scope)
}
}
}
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'fabric-loom'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
//Group is common for all API modules
group = project.maven_group
repositories {
maven {
name = 'Jitpack'
url 'https://jitpack.io/'
}
maven {
name = 'HalfOf2'
url = 'https://storage.googleapis.com/devan-maven/'
}
}
configurations {
implementationOnly //A non-transitive implementation
runtimeClasspath.extendsFrom implementationOnly
compileClasspath.extendsFrom implementationOnly
}
minecraft {
addLibraryFilter {library ->
return !(library.startsWith('net.minecraft:launchwrapper:') ||
library.startsWith('net.sf.jopt-simple:jopt-simple:') ||
library.startsWith('org.ow2.asm:asm-all:'))
}
}
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "io.github.minecraft-cursed-legacy:plasma:b1.7.3-build.${project.plasma_build}"
modImplementation("io.github.minecraft-cursed-legacy:cursed-fabric-loader:${project.loader_version}") {
transitive false //Avoid leaking Loader's dependencies forwards
}
//For @Nullable and @Nonnull
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
}
sourceSets {
test {
compileClasspath += main.compileClasspath + main.output
runtimeClasspath += main.runtimeClasspath + main.output
}
}
afterEvaluate {
processResources {
inputs.property 'version', project.version
from(sourceSets.main.resources.srcDirs) {
include 'fabric.mod.json'
expand 'version': project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'fabric.mod.json'
}
}
}
// 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) {
options.encoding = 'UTF-8'
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
publishing {
publications {
mavenJava(MavenPublication) {
afterEvaluate {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
}
}
}
import net.fabricmc.loom.task.RunClientTask
import net.fabricmc.loom.task.RunServerTask
subprojects {subproject ->
task runTestmodClient(type: RunClientTask) {
classpath sourceSets.test.runtimeClasspath
}
task runTestmodServer(type: RunServerTask) {
classpath sourceSets.test.runtimeClasspath
}
assert this.remapJar != remapJar //No accidents moving this around
this.remapJar.dependsOn(remapJar)
configurations {
out {
canBeConsumed = true
canBeResolved = false
}
dev {
canBeConsumed = true
canBeResolved = false
}
test {
canBeConsumed = true
canBeResolved = false
}
}
task testJar(type: Jar) {
from sourceSets.test.output
classifier 'test'
}
artifacts {
out remapJar
dev jar
test testJar
}
//Attach the subproject to the root project
this.dependencies {
implementationOnly project(path: ":$name", configuration: 'dev')
testImplementation project(path: ":$name", configuration: 'test')
include project(path: ":$name", configuration: 'out')
}
//Mark the subproject as a compile time dependency of the root project
this.publishing {
publications {
mavenJava(MavenPublication) {
pom.withXml {xml ->
addDependency(xml, 'compile', subproject)
}
}
}
}
}
//Subprojects will set these themselves
archivesBaseName = archives_base_name
version = mod_version
dependencies {
}