forked from iLexiconn/LLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
224 lines (191 loc) · 5.92 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
buildscript {
ext.corePlugin = "net.ilexiconn.llibrary.server.core.plugin.LLibraryPlugin"
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "gradle"
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT"
classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.0.7"
}
}
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "maven-publish"
apply plugin: "com.matthewprenger.cursegradle"
import groovy.json.JsonSlurper;
def secretFile = file "secret.json"
project.ext.secret = null
if (secretFile.exists()) {
secretFile.withReader {
project.ext.secret = new JsonSlurper().parse it
}
}
version = getLLibraryVersion() + "-1.11.2"
group = "net.ilexiconn"
archivesBaseName = "llibrary"
sourceCompatibility = targetCompatibility = "1.8"
def minecraft_mappings = "stable_32"
minecraft {
version = "1.11.2-13.20.1.2386"
runDir = "minecraft"
mappings = minecraft_mappings
makeObfSourceJar = false
clientJvmArgs = ["-Dfml.coreMods.load=$corePlugin"]
serverJvmArgs = ["-Dfml.coreMods.load=$corePlugin"]
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
expand "version": project.version, "mcversion": project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
}
jar {
manifest {
attributes "FMLAT": "llibrary_at.cfg"
attributes "FMLCorePlugin": corePlugin
attributes "FMLCorePluginContainsFMLMod": "true"
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
task devJar(type: Jar) {
classifier = "dev"
from sourceSets.main.output
manifest {
attributes "FMLAT": "llibrary_at.cfg"
attributes "FMLCorePlugin": "net.ilexiconn.llibrary.server.core.plugin.LLibraryPlugin"
attributes "FMLCorePluginContainsFMLMod": "true"
}
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.getDestinationDir()
}
artifacts {
archives sourcesJar
archives devJar
archives javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId "net.ilexiconn"
artifactId "llibrary"
version project.version
from components.java
artifact devJar {
classifier "dev"
}
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
}
}
repositories {
maven {
credentials {
if (secret) {
username secret.username
password secret.password
} else {
username ""
password ""
}
}
if (secret) {
url secret.url
} else {
url ""
}
}
}
}
curseforge {
def url = "http://pastebin.com/raw/EjsPPpVG".toURL()
def versions = new JsonSlurper().parseText url.text
if (secret) {
apiKey = secret.apiKey
} else {
apiKey = ""
}
project {
id = "243298"
releaseType = "release"
def curse_version = getLLibraryVersion()
def remoteChangelog = versions.versions[curse_version];
if (remoteChangelog) {
changelog = remoteChangelog.join("\n")
} else {
changelog = ""
}
addGameVersion(project.minecraft.version)
mainArtifact(jar) {
displayName = "LLibrary $curse_version"
}
addArtifact(sourcesJar) {
displayName = "LLibrary $curse_version Sources"
}
addArtifact(devJar) {
displayName = "LLibrary $curse_version Development"
}
addArtifact(javadocJar) {
displayName = "LLibrary $curse_version Javadoc"
}
}
}
String getLLibraryVersion() {
def major = "0";
def revision = "0";
def patch = "0";
def prefix = "public static final String VERSION = \"";
def file = file("src/main/java/net/ilexiconn/llibrary/LLibrary.java")
file.eachLine { String s ->
s = s.trim();
if (s.startsWith(prefix)) {
s = s.substring(prefix.length(), s.length() - 2);
def pts = s.split("\\.");
major = pts[0];
revision = pts[1];
patch = pts[2];
}
}
return "$major.$revision.$patch";
}
task generateMappings << {
def mappingParts = minecraft_mappings.split("_");
def mappingReplacements = new HashMap<String, String>()
def mappingFile = new File(System.properties["user.home"] + "/.gradle/caches/minecraft/de/oceanlabs/mcp/mcp_" + mappingParts[0] + "/" + mappingParts[1] + "/" + project.minecraft.version + "/srgs/mcp-srg.srg")
if (mappingFile.exists()) {
mappingFile.eachLine { line ->
def parts = line.split(" ")
if (line.startsWith("FD")) {
mappingReplacements[parts[1]] = parts[2].substring(parts[2].lastIndexOf("/") + 1, parts[2].length())
} else if (line.startsWith("MD")) {
mappingReplacements[parts[1] + parts[2]] = parts[3].substring(parts[3].lastIndexOf("/") + 1, parts[3].length())
}
}
}
def mappingsFile = new File("src/main/resources/llibrary.mappings")
mappingsFile.withWriter("UTF-8") { writer ->
mappingReplacements.each { k, v -> writer.write(k + "=" + v + "\n") }
}
}
compileJava.dependsOn generateMappings
decompileMc.dependsOn generateMappings