-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.gradle
142 lines (126 loc) · 4.17 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
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT' apply(false)
id 'net.minecraftforge.gradle' version '[6.0,6.2)' apply(false)
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT' apply(false)
id('org.spongepowered.mixin') version '0.7-SNAPSHOT' apply(false)
}
String execCmd(List<String> params, String fallback) {
def stdout = new ByteArrayOutputStream()
def result = exec {
commandLine params
standardOutput = stdout
}
return result.getExitValue() != 0 ? fallback : stdout.toString().trim()
}
// We use the version format MCVERSION-MAJOR.MINOR.PATCH-COMMIT
version = "${minecraft_version}-${mod_version}-${execCmd(['git', 'rev-parse', '--short', 'HEAD'], 'nogit')}"
group = mod_group
ext {
// For the config color picker (we include it in our production jar with ShadowJar)
COLOR_FACTORY_VERSION = '1.0.2'
MIXIN_EXTRAS_VERSION = '0.3.5'
}
subprojects {
apply plugin: 'java'
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.withSourcesJar()
java.withJavadocJar()
version = rootProject.version
group = rootProject.group
dependencies {
// For @Nullable
compileOnly 'org.jetbrains:annotations:23.0.0'
// For unit tests
testImplementation 'org.mockito:mockito-core:4.5.1'
testImplementation 'junit:junit:4.13.2'
testImplementation group: 'org.beryx', name: 'awt-color-factory', version: rootProject.ext.COLOR_FACTORY_VERSION
}
jar {
archiveClassifier.set('dev')
from(rootProject.file('LICENSE')) {
rename { "${it}_${mod_name}" }
}
manifest {
attributes([
'Specification-Title' : mod_name,
'Specification-Vendor' : mod_authors,
'Specification-Version' : project.jar.archiveVersion,
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_authors,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestamp' : System.currentTimeMillis(),
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On-Minecraft' : minecraft_version,
'Main-Class' : 'io.github.cadiboo.nocubes.DoNotRunThisFromTheConsoleDialog',
])
}
}
sourcesJar {
archiveClassifier.set('sources')
from(rootProject.file('LICENSE')) {
rename { "${it}_${mod_name}" }
}
}
javadocJar {
archiveClassifier.set('javadoc')
}
javadoc {
// Gradle doesn't support Java 8's new tags out of the box
options.tags = [
'apiNote:a:API Note:',
'implSpec:a:Implementation Requirements:',
'implNote:a:Implementation Note:',
]
options.addBooleanOption('Xdoclint:-missing', true)
}
repositories {
mavenCentral()
maven {
name = 'Sponge / Mixin'
url = 'https://repo.spongepowered.org/repository/maven-public/'
}
maven {
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
name = 'Modrinth'
url = 'https://api.modrinth.com/maven'
content {
includeGroup 'maven.modrinth'
}
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.getRelease().set(17)
}
processResources {
def expandProps = [
"minecraft_version" : minecraft_version,
"forge_version" : forge_version,
"forge_loader_version_range": forge_loader_version_range,
"forge_version_range" : forge_version_range,
"minecraft_version_range" : minecraft_version_range,
"fabric_loader_version" : fabric_loader_version,
"mod_name" : mod_name,
"mod_id" : mod_id,
"mod_version" : version,
"mod_group" : project.group, // Else we target the task's group.
"mod_authors" : mod_authors,
"mod_license" : mod_license,
"mod_issue_tracker_url" : mod_issue_tracker_url,
"mod_update_json_url" : mod_update_json_url,
"mod_homepage_url" : mod_homepage_url,
"mod_credits" : mod_credits,
"mod_description" : mod_description,
]
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', '*.mixins.json']) {
expand expandProps
}
inputs.properties(expandProps)
}
}