forked from CreativeMD/ItemPhysic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
171 lines (146 loc) · 4.71 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
plugins {
id 'eclipse'
id 'idea'
id 'net.minecraftforge.gradle' version '[6.0,6.2)'
id 'com.diffplug.eclipse.apt'
id 'org.spongepowered.mixin'
id 'com.modrinth.minotaur' version '2.+'
id 'com.matthewprenger.cursegradle' version '1.4+'
}
group= "team.creative" + project.mod_id
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
project.evaluationDependsOn(":CreativeCore")
minecraft {
mappings channel: 'official', version: "${project.property 'minecraft_version'}"
runs {
client {
taskName "itemphysic_client"
workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug'
arg '--mixin.config'
arg 'creativecore.mixins.json'
arg '--mixin.config'
arg 'creativecore.forge.mixins.json'
mods {
creativecore {
source project(':CreativeCore').sourceSets.main
}
"${mod_id}" {
source sourceSets.main
}
}
}
server {
taskName "itemphysic_server"
workingDirectory project.file('run')
property 'forge.logging.console.level', 'debug'
arg '--mixin.config'
arg 'creativecore.mixins.json'
arg '--mixin.config'
arg 'creativecore.forge.mixins.json'
mods {
creativecore {
source project(':CreativeCore').sourceSets.main
}
"${mod_id}" {
source sourceSets.main
}
}
}
}
}
dependencies {
minecraft "net.minecraftforge:forge:${project.property 'minecraft_version'}-${project.property 'forge_version'}"
implementation project(':CreativeCore')
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
modDependencies = [
[ modId: "creativecore", mandatory: true, ordering: "NONE", side: "BOTH", versionRange: creativecore_version ]
]
jar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveFileName.set(project.mod_name + "_FORGE_v" + project.mod_version + "_mc" + project.minecraft_version + ".jar")
manifest {
attributes([
"Specification-Title": project.mod_name,
"Specification-Vendor": "CreativeMD",
"Specification-Version": project.mod_version,
"Implementation-Title": project.mod_name,
"Implementation-Version" : project.mod_version,
"Implementation-Vendor": "CreativeMD",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
jar.finalizedBy('reobfJar')
mixin {
add sourceSets.main, 'itemphysic.mixin.refmap.json'
config 'itemphysic.mixins.json'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
String getChangelogText() {
String result = ''
boolean first = true
file('changelog.txt').readLines().find {
if (first) {
if (it.equals(project.mod_version)) {
first = false
}
return false
} else if (!it?.trim()) {
return true
} else {
result += "* " + it + "\n"
return false
}
}
return result
}
task upload(type: GradleBuild) {
description 'Uploads new version to modrinth and curseforge.'
group = 'publishing'
tasks = ['modrinth', 'curseforge']
}
gradle.taskGraph.whenReady {
if (it.hasTask(tasks.modrinth) || it.hasTask(tasks.curseforge)) {
if (!getChangelogText()?.trim()) {
throw new GradleException('No changelog provided')
}
}
}
tasks.modrinth.enabled = System.getenv("MODRINTH_TOKEN") != null
tasks.modrinth.group = 'publishing'
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = project.mod_id
versionNumber = project.mod_version
versionType = project.release_type
uploadFile = jar
gameVersions = [ project.minecraft_version ]
changelog = getChangelogText()
loaders = [ "forge", "neoforge" ]
dependencies {
required.project "creativecore"
}
}
tasks.curseforge.enabled = System.getenv("CURSEFORGE_TOKEN") != null
tasks.curseforge.group = 'publishing'
curseforge {
apiKey = System.getenv("CURSEFORGE_TOKEN") != null ? System.getenv("CURSEFORGE_TOKEN") : "empty"
project {
id = project.curse_id
changelog = getChangelogText()
changelogType = "markdown"
addGameVersion project.minecraft_version
addGameVersion "Forge"
addGameVersion "NeoForge"
releaseType = project.release_type
mainArtifact(jar) {
}
relations {
requiredLibrary "creativecore"
}
}
}