generated from natanfudge/fabric-example-mod-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
137 lines (117 loc) · 3.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
plugins {
alias libs.plugins.loom
id "maven-publish"
id "signing"
alias libs.plugins.kotlin
alias libs.plugins.kotlin.serialization
alias libs.plugins.nexus.publish
alias libs.plugins.loom.quiltflower
}
// After publishing, the artifact must be closed and then released at https://oss.sonatype.org/#stagingRepositories
def total_version = "${libs.versions.mod.version.get()}+${libs.versions.minecraft.get()}"
archivesBaseName = project.archives_base_name
version = total_version
group = project.maven_group
loom {
accessWidenerPath = file("src/main/resources/kotlinx_serialization_minecraft.accessWidener")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
withSourcesJar()
withJavadocJar()
}
kotlin {
explicitApi()
}
dependencies {
//to change the versions see the gradle.properties file
minecraft libs.minecraft
mappings "net.fabricmc:yarn:${libs.versions.yarn.mappings.get()}:v2"
modImplementation libs.fabric.loader
modImplementation libs.flk
api libs.kotlin.serialization.core
testImplementation libs.kotlin.test
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
test {
useJUnitPlatform()
}
def getSecretProperty(String path, String key) {
def rootPath = System.getenv("SECRETS_PATH")
def file = new File("${rootPath}/${path}.properties")
if (!file.exists()) return ""
def properties = new Properties()
new FileInputStream(file).withCloseable { is -> properties.load(is) }
return properties[key]
}
def getSecretFile(String path) {
def rootPath = System.getenv("SECRETS_PATH")
def file = new File("${rootPath}/${path}")
if (!file.exists()) return ""
return new String(file.readBytes())
}
afterEvaluate {
task uploadLibrary {
group = "kotlinSerializationMinecraft"
dependsOn tasks.publishToSonatype, tasks.closeAndReleaseSonatypeStagingRepository
}
}
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
// The coordinates of the library, being set from variables that
// we'll set up later
groupId maven_group
artifactId archives_base_name
version total_version
from components.java
// Mostly self-explanatory metadata
pom {
name = archives_base_name
description = 'Fabric mod that adds NBT and PacketByteBuf to kotlinx.serialization'
url = github_url
licenses {
license {
name = license
}
}
developers {
developer {
id = "fudge"
name = "natan"
email = "natandestroyer100@gmail.com"
}
}
scm {
url = github_url
}
}
}
}
}
}
nexusPublishing {
repositories {
sonatype {
stagingProfileId = getSecretProperty('ksm/keys', "sonatype_staging_profile_id")
username = getSecretProperty("sonatype", "ossrh_username")
password = getSecretProperty("sonatype", "ossrh_password")
}
}
}
signing {
useInMemoryPgpKeys(
getSecretProperty("ksm/keys", "gpg_key_id"),
getSecretFile("ksm/secret_key.txt"),
getSecretProperty("ksm/keys", "gpg_key_password"),
)
sign publishing.publications
}