-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
149 lines (126 loc) · 4.31 KB
/
build.gradle.kts
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
import com.github.breadmoirai.GithubReleaseExtension
import com.matthewprenger.cursegradle.CurseProject
import com.matthewprenger.cursegradle.CurseRelation
import com.matthewprenger.cursegradle.Options
import org.gradle.jvm.tasks.Jar
import org.apache.tools.ant.filters.ReplaceTokens
import org.ajoberstar.grgit.Grgit
plugins {
kotlin("jvm") version "1.3.21"
id("fabric-loom") version "0.2.0-SNAPSHOT"
id("com.matthewprenger.cursegradle") version "1.1.2"
id("com.github.breadmoirai.github-release") version "2.2.4"
id("org.ajoberstar.grgit") version "3.0.0"
}
val BUILD_NO: String? by project
val buildNo = BUILD_NO ?: "SNAPSHOT"
val project_version: String by project
val version_mc: String by project
val version_mc_jar: String by project
val version_mc_mappings: String by project
val version_fabric: String by project
val version_fabric_loader: String by project
val version_fabric_kotlin: String by project
val version_kotlin: String by project
val version_h3nt_commonutils: String by project
val curse_api_key: String? by project
val project_curseforge_id: String by project
/* val changelog: String? by project */
val github_release_token: String? by project
group = "com.hea3ven.dulcedeleche"
version = "$project_version-$buildNo"
base {
archivesBaseName = "dulcedeleche"
}
tasks.compileJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
repositories {
maven(url="http://mribecky.com.ar/maven") {
name = "Hea3veN"
}
maven(url = "https://kotlin.bintray.com/kotlinx") {
name = "Kotlin X"
}
}
val shadow by configurations.creating {
isTransitive = false
}
/* compileOnly.extendsFrom(configurations. */
dependencies {
minecraft("com.mojang:minecraft:$version_mc_jar")
mappings("net.fabricmc:yarn:$version_mc_mappings")
modCompile("net.fabricmc:fabric-loader:$version_fabric_loader")
modCompile("net.fabricmc:fabric:$version_fabric")
modCompile("net.fabricmc:fabric-language-kotlin:$version_fabric_kotlin")
compileOnly("org.jetbrains.kotlin:kotlin-stdlib:$version_kotlin")
modCompile("com.hea3ven.tools.commonutils:h3nt-commonutils:$version_h3nt_commonutils")
shadow("com.hea3ven.tools.commonutils:h3nt-commonutils:$version_h3nt_commonutils")
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
}
tasks.processResources {
filesMatching("**/*.json") {
filter<ReplaceTokens>("tokens" to mapOf(
"version" to project.version.toString(),
"version_fabric" to "$version_fabric".toString(),
"version_kotlin" to "$version_kotlin".toString(),
"version_fabric_kotlin" to "$version_fabric_kotlin".toString()
))
}
}
tasks.withType<Jar> {
from(configurations["shadow"].asFileTree.files.map { zipTree(it) })
}
val versionRegex = Regex("v[0-9].*")
val versionExcludeRegex = Regex("v1.(9(.4)?|10)-.*")
var repo = Grgit.open()
val lastVersionTag = repo.tag.list()
.map { it.fullName.substring(10) }
.filterNot(versionExcludeRegex::matches)
.filter(versionRegex::matches)
.sortedWith({a, b -> -(a.split('.').zip(b.split('.')).map { it.first.compareTo(it.second) }.filter { it != 0 }.first() ?: 0) })
.first()
val changes = repo.log {
range(lastVersionTag, "HEAD")
}.filter {
it.parentIds.size > 1
}.map {
it.fullMessage.removeRange(0, it.fullMessage.indexOf('\n')).trim()
}.joinToString("\r\n")
curseforge {
apiKey = curse_api_key ?: ""
options(closureOf<Options> {
forgeGradleIntegration = false
debug = true
})
project(closureOf<CurseProject> {
id = project_curseforge_id
releaseType = "release"
println(changes)
changelog = changes
addGameVersion(version_mc)
relations(closureOf<CurseRelation> {
requiredDependency("fabric")
requiredDependency("fabric-language-kotlin")
})
})
}
afterEvaluate {
tasks.named("curseforge$project_curseforge_id") {
dependsOn(tasks.getByName("remapJar"))
}
}
configure<GithubReleaseExtension> {
token(github_release_token ?: "")
owner.set("Hea3veN")
repo.set("DulceDeLeche")
targetCommitish.set("master")
body.set(changes)
draft.set(false)
prerelease.set(false)
releaseAssets.setFrom(tasks.jar.get().outputs.files)
}
tasks.named("githubRelease") {
dependsOn(tasks.getByName("remapJar"))
}