-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathbuild.gradle
125 lines (121 loc) · 5.33 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
// BEFORE SYNCING, YOU MUST GO TO Settings -> Build, Execution, Deployment -> Build Tools -> Gradle and change "Gradle JVM" to Java 11 or higher
plugins {
id "architectury-plugin" version "$architectury_plugin_version"
id "dev.architectury.loom" version "$loom_version" apply false
id "org.ajoberstar.grgit" version "3.1.1"
}
architectury {
minecraft = rootProject.mc_version
}
subprojects {
apply plugin: "dev.architectury.loom"
loom {
silentMojangMappingsLicense()
}
dependencies {
minecraft "com.mojang:minecraft:${rootProject.mc_version}"
mappings loom.officialMojangMappings()
}
}
allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
archivesBaseName = rootProject.mod_id
version = rootProject.mc_version+ "-" + rootProject.mod_version
group = rootProject.maven_group
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
options.release = targetVersion
}
}
repositories {
maven {
name = "itsmeowdev Maven"
url = "https://maven.itsmeow.dev/"
}
}
java {
withSourcesJar()
}
processResources {
doLast {
def jsonMinifyStart = System.currentTimeMillis()
def jsonMinified = 0
def jsonBytesSaved = 0
fileTree(dir: outputs.files.asPath, include: '**/*.json').each {
File file = it
jsonMinified++
def oldLength = file.length()
file.text = groovy.json.JsonOutput.toJson(new groovy.json.JsonSlurper().parse(file))
jsonBytesSaved += oldLength - file.length()
}
println('Minified ' + jsonMinified + ' json files. Saved ' + jsonBytesSaved + ' bytes. Took ' + (System.currentTimeMillis() - jsonMinifyStart) + 'ms.')
}
}
publishing {
repositories {
maven {
if ((System.getenv("MAVEN_USER") != '') && (System.getenv("MAVEN_PASSWORD") != '')) {
credentials {
username System.getenv("MAVEN_USER")
password System.getenv("MAVEN_PASSWORD")
}
}
if (System.getenv("MAVEN_URL") != '') {
url System.getenv("MAVEN_URL")
} else {
url "file:///${project.buildDir}/repo"
}
}
}
}
}
task exportAlphaVersions() {
def getVersion = {
//TAG-offset-hash
def raw = grgit.describe(longDescr: true, tags: true, match: ["${rootProject.mc_version}-[0-9].[0-9].[0-9]", "${rootProject.mc_version}-[0-9][0-9].[0-9][0-9].[0-9][0-9]", "${rootProject.mc_version}-[0-9].[0-9][0-9].[0-9][0-9]", "${rootProject.mc_version}-[0-9].[0-9].[0-9][0-9]", "${rootProject.mc_version}-[0-9].[0-9][0-9].[0-9]", "${rootProject.mc_version}-[0-9][0-9].[0-9].[0-9]"])
def desc = (raw == null ? '0.0-0-unknown' : grgit.describe(longDescr: true, tags: true, match: ["${rootProject.mc_version}-[0-9].[0-9].[0-9]", "${rootProject.mc_version}-[0-9][0-9].[0-9][0-9].[0-9][0-9]", "${rootProject.mc_version}-[0-9].[0-9][0-9].[0-9][0-9]", "${rootProject.mc_version}-[0-9].[0-9].[0-9][0-9]", "${rootProject.mc_version}-[0-9].[0-9][0-9].[0-9]", "${rootProject.mc_version}-[0-9][0-9].[0-9].[0-9]"])).split('-') as List
def hash = desc.remove(desc.size() - 1)
def offset = desc.remove(desc.size() - 1)
def tag = desc.join('-')
return "${tag}.${offset}".toString().replace("${rootProject.mc_version}-", "") //Bake the response instead of making it dynamic
}
rootProject.mod_version = getVersion();
allprojects {
version = rootProject.mc_version + '-' + getVersion();
}
def getLastTag = {
def raw = grgit.describe(longDescr: true, tags: true)
if(raw == null) {
return "HEAD"
} else {
List desc = raw.split('-') as List
if(desc.size() > 1) {
desc.remove(desc.size() - 1)
}
if(desc.size() > 1) {
desc.remove(desc.size() - 1)
}
return desc.join('-');
}
}
def rawLog = grgit.log(includes: ['HEAD'], excludes: [getLastTag()]);
def log = "";
for (org.ajoberstar.grgit.Commit commit: rawLog) {
log = log + "[`" + commit.abbreviatedId + "`](https://github.com/${rootProject.github}/commit/" + commit.id + ") " + commit.shortMessage + " - " + commit.author.name + "\\n";
}
doLast {
exec {
commandLine "echo", "##[set-output name=modid;]${rootProject.mod_id}";
}
exec {
commandLine "echo", "##[set-output name=version;]${rootProject.version}";
}
exec {
commandLine "echo", "##[set-output name=commitlog;]" + "{\"content\":\"" + (project.hasProperty('hook_content') ? project.hook_content : "") + "\",\"embeds\":[{\"author\":{\"name\":\"itsmeow\",\"url\":\"https://itsmeow.dev/\",\"icon_url\":\"https://itsmeow.dev/icon.png\"},\"title\":\"${project.mod_id}-alpha-${project.version}\",\"url\":\"https://github.com/${project.github}/releases/tag/alpha-${project.version}\",\"color\":14700288,\"description\":\"" + log + "\"}]}";
}
}
}