forked from xfl03/MCCustomSkinLoader
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
196 lines (171 loc) · 6.55 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
apply plugin: 'base'
apply plugin: 'customskinloader'
ext.configFile = file "build.properties"
configFile.withReader {
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = "4.9"
}
import customskinloader.gradle.util.CurseForgeUtil
import customskinloader.gradle.util.ModrinthUtil
import customskinloader.gradle.util.RemapUtil
import customskinloader.gradle.util.VersionUtil
subprojects {
apply plugin: 'net.minecraftforge.gradle.forge'
ext.configFile = file "build.properties"
configFile.withReader {
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
version = VersionUtil.getCSLVersion(rootProject)
group = "customskinloader"
ext.shortVersion = VersionUtil.getShortVersion(rootProject)
sourceCompatibility = targetCompatibility = 1.8
compileJava {
sourceCompatibility = targetCompatibility = 1.8
}
minecraft {
version = config.forge_mc_version + "-" + config.forge_version
runDir = "run"
mappings = config.mappings_version
replace '@MOD_VERSION@', rootProject.ext.config.version
replace '@MOD_FULL_VERSION@', project.version
replace '@MOD_BUILD_NUMBER@', VersionUtil.getBuildNum()
replaceIn 'CustomSkinLoader.java'
}
repositories {
maven {
name = "sponge"
url = "https://repo.spongepowered.org/repository/maven-public/"
}
}
// We need to change source dirs for inherited problems.
sourceSets.main {
java {
srcDir "source"
}
resources {
srcDir "resource"
}
}
jar {
manifest {
attributes([
"Specification-Title" : "CustomSkinLoader",
"Specification-Vendor" : "xfl03",
"Specification-Version" : "1",
"Implementation-Title" : "CustomSkinLoader",
"Implementation-Version" : "${version}",
"Implementation-Vendor" : "xfl03",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
// For real subprojects
if (!config.is_real_project || Boolean.parseBoolean(config.is_real_project.toString())) {
archivesBaseName = "CustomSkinLoader_${-> VersionUtil.getEdition(project)}"
processResources {
filesNotMatching(["**/*.js", "mixins.*.json"]) {
expand([
modVersion : rootProject.ext.config.version,
modFullVersion : project.version,
modShortFullVersion: shortVersion,
mcVersion : config.minecraft_version,
mcFullVersions : config.minecraft_full_versions,
forgeVersion : config.forge_version,
gitVersion : System.getenv("CIRCLE_SHA1"),
buildUrl : System.getenv("CIRCLE_BUILD_URL"),
releaseTime : new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
// Mixin stuffs
if (!project.name.toLowerCase().contains("forge/legacy")) {
apply plugin: 'org.spongepowered.mixin'
apply from: rootProject.file("buildSrc/patch.gradle")
patchMixin()
task genSrgMap {
doLast {
if (config.srg_notch_map != null) {
// convert mappings
RemapUtil.tsrg2srg file(config.srg_notch_map), file("build/reobf.srg")
RemapUtil.tsrg2srg file("mixin.tsrg"), file("build/mixin.srg")
}
}
}
deobfCompileDummyTask.dependsOn genSrgMap
mixin {
add sourceSets.main, "mixins.customskinloader.refmap.json"
reobfSrgFile = "build/mixin.srg"
reobfNotchSrgFile = "build/mixin.srg"
}
reobf {
jar {
if (config.srg_notch_map != null) {
mappings = file("build/reobf.srg")
}
}
}
}
task signJar(type: SignJar, dependsOn: reobfJar) {
onlyIf { System.getenv("KEY_PASS") != null }
doLast { System.out.println("Jar will be signed.") }
inputFile = jar.archivePath
outputFile = jar.archivePath
keyStore = "${rootDir}/Common/CustomSkinLoader.jks"
alias = 'CustomSkinLoader'
storePass = System.getenv("KEY_PASS")
keyPass = System.getenv("KEY_PASS")
}
build.dependsOn signJar
task afterBuild {
doLast {
//copyBuildFile
copy {
from "build/libs"
into "${rootDir}/build/libs"
include "**/*.jar"
if (project.name.toLowerCase().contains("vanilla")) {
exclude "**/*-sources.jar"
}
}
}
}
build.finalizedBy afterBuild
apply plugin: 'maven-publish'
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/xfl03/MCCustomSkinLoader")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
}
publications {
gpr(MavenPublication) {
groupId 'customskinloader'
artifactId project.archivesBaseName
from(components.java)
}
}
}
tasks.withType(PublishToMavenRepository) {
onlyIf { System.getenv("GITHUB_TOKEN") != null }
}
if (project.name.toLowerCase().contains("vanilla/1.")) {
apply from: rootProject.file('Vanilla/common.gradle')
} else {
// Only Fabric and Forge edition should be uploaded to CurseForge and Modrinth
CurseForgeUtil.provideCurseForge project
ModrinthUtil.provideModrinth project
}
}
}