This repository has been archived by the owner on Dec 5, 2022. It is now read-only.
forked from minecraft-cursed-legacy/Cursed-Legacy-API
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
248 lines (213 loc) · 6 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
//file:noinspection GroovyAssignabilityCheck, SpellCheckingInspection
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
maven { url 'https://maven.fabricmc.net/' }
maven { url 'https://jitpack.io' }
}
dependencies {
classpath "org.codehaus.groovy:groovy-all:${project.groovy_version}"
classpath "com.github.Chocohead.Fabric-Loom:fabric-loom:${project.loom_version}"
}
}
plugins {
id 'checkstyle'
id 'eclipse'
id 'idea'
id 'java'
id 'groovy'
id 'scala'
id 'org.jetbrains.kotlin.jvm' version '1.5.30'
}
// Subprojects will set these themselves
archivesBaseName = archives_base_name
version = mod_version
@SuppressWarnings('unused')
static String getSubprojectVersion(project, ver) {
return "${project.mod_version}-$ver"
}
@SuppressWarnings('unused')
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) {
Node dependenciesNode = 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'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.jetbrains.kotlin.jvm'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
// Group is common for all API modules
group = project.maven_group
repositories {
mavenCentral()
maven { url 'https://maven.fabricmc.net/' }
maven { url 'https://repo.blucobalt.dev/repository/maven-halotroop/'}
maven { url 'https://storage.googleapis.com/devan-maven/' }
maven { url 'https://jitpack.io/' }
}
configurations {
implementationOnly // A non-transitive implementation
runtimeClasspath.extendsFrom implementationOnly
compileClasspath.extendsFrom implementationOnly
}
minecraft {
//Skip old versions of libraries which Mojang use but we don't need
addLibraryFilter {library ->
return !(library.startsWith('net.minecraft:launchwrapper:') ||
library.startsWith('net.sf.jopt-simple:jopt-simple:') ||
library.startsWith('org.ow2.asm:asm-all:'))
}
}
dependencies {
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.8.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.8.1'
annotationProcessor group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.8.1'
annotationProcessor group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.8.1'
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.fromCommit("Better-Than-Updates-MC/Mappings", "${project.mappings}") {spec ->
spec.version = "b1.7.3-${project.mappings}"
}
modImplementation("io.github.minecraft-cursed-legacy:cursed-fabric-loader:${project.loader_version}") {
transitive false // Avoid leaking Loader's dependencies forwards
}
testImplementation "net.fabricmc:fabric-language-groovy:1.1.0"
testImplementation "net.fabricmc:fabric-language-scala:0.3.1.+"
testImplementation "net.fabricmc:fabric-language-kotlin:1.6.4+kotlin.1.5.30"
//For @Nullable and @NotNull
compileOnly 'org.jetbrains:annotations:22.0.0'
}
sourceSets {
test {
compileClasspath += main.compileClasspath + main.output
runtimeClasspath += main.runtimeClasspath + main.output
}
}
afterEvaluate {
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set 'sources'
from sourceSets.main.allSource
}
publishing {
publications {
mavenJava(MavenPublication) {
afterEvaluate {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
}
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
import net.fabricmc.loom.task.RunClientTask
import net.fabricmc.loom.task.RunServerTask
import net.fabricmc.loom.util.GroovyXmlUtil
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
}
//Mark the subproject as a compile time dependency of the root project
this.publishing {
publications {
mavenJava(MavenPublication) {
pom.withXml {xml ->
addDependency(xml, 'compile', subproject)
}
}
}
}
}
dependencies {
afterEvaluate {
//Attach the subproject to the root project
subprojects.each {
implementationOnly project(path: ":${it.name}", configuration: "dev")
testImplementation project(path: ":${it.name}", configuration: 'test')
include project("${it.name}:")
runtimeOnly project(path: it.name, configuration: "dev")
}
}
}