-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
181 lines (147 loc) · 3.46 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
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
@file:Suppress("UnstableApiUsage")
import dev.strixpyrr.shorthand.*
import dev.strixpyrr.shorthand.CompilerArgumentScope.Companion.RequiresOptIn
import dev.strixpyrr.shorthand.JvmDefaultMode.All
import de.undercouch.gradle.tasks.download.Download as Download
plugins {
kotlin("jvm") version "1.6.0"
kotlin("plugin.serialization") version "1.6.0"
alias(deps.plugins.shorthand)
alias(deps.plugins.openapi )
alias(deps.plugins.download )
`maven-publish`
`java-gradle-plugin`
}
group = "dev.strixpyrr.powerloom"
version = "0.1.1.2"
repositories()
{
mavenCentral()
maven(url = "https://maven.fabricmc.net")
}
dependencies()
{
implementation(kotlin("stdlib"))
implementation(kotlin("gradle-plugin"))
implementation(gradleApi())
implementation(gradleKotlinDsl())
implementation(deps.kotlinx.serialization.json)
implementation(deps.kotlinx.couroutines.core)
implementation(deps.fabric.loom)
implementation(deps.square.okio)
implementation(deps.square.retrofit2)
implementation(deps.square.retrofit2.scalars)
implementation(deps.square.okhttp3)
implementation(deps.square.okhttp3.logging)
implementation(deps.retrofitSerializationConverter)
implementation(deps.mordant)
compileOnly(deps.kotlinx.serialization.properties)
compileOnly(deps.charleskorn.kaml)
compileOnly(deps.electronwill.nightConfig.toml)
testImplementation(deps.kotest)
testImplementation(gradleTestKit())
}
val openApiOutPath = "$buildDir/generated-sources/openapi"
kotlin()
{
target.run()
{
compilations.forEach()
{
it.kotlinOptions.run()
{
jvmTarget = "1.8"
languageVersion = "1.6"
freeCompilerArgs()
{
optIn(RequiresOptIn)
jvmDefault = All
}
}
}
}
sourceSets()
{
main()
{
kotlin.srcDir(openApiOutPath)
}
}
}
val openApiSpecPath = "$buildDir/openapi-specs/modrinth.yaml"
tasks()
{
withType<Test>
{
useJUnitPlatform()
}
val testClasses by getting()
{
// Why tf is this not done by default? O_o
dependsOn("pluginUnderTestMetadata")
}
val downloadModrinthOpenApiSpec: Download by creating()
{
src("https://docs.modrinth.com/openapi.yaml")
dest(openApiSpecPath)
overwrite(false)
}
val openApiGenerate by getting()
{
dependsOn(downloadModrinthOpenApiSpec)
doLast()
{
delete(
"$openApiOutPath/gradle",
"$openApiOutPath/.openapi-generator"
)
}
}
val processResources: Copy by getting()
{
exclude("templates")
}
}
openApiGenerate()
{
generatorName("kotlin")
inputSpec(openApiSpecPath)
outputDir(openApiOutPath)
ignoreFileOverride("$rootDir/.openapi-generator-ignore")
templateDir("$rootDir/src/main/resources/templates")
// Retrofit generation is broken, we'll just use the default for now.
// library("jvm-retrofit2")
val packageName = "dev.strixpyrr.powerLoom.modDistributionPlatforms.modrinth"
modelPackage(packageName)
apiPackage(packageName)
modelNamePrefix("Modrinth")
configOptions += mapOf(
"enumPropertyNaming" to "PascalCase",
"useCoroutines" to "true",
"serializationLibrary" to "kotlinx_serialization",
"apiSuffix" to "Service",
"sourceFolder" to "."
)
}
gradlePlugin()
{
plugins()
{
val powerLoom by creating()
{
id = "dev.strixpyrr.powerloom"
implementationClass = "dev.strixpyrr.powerLoom.PowerLoomPlugin"
}
}
}
publishing()
{
publications()
{
val powerLoom: MavenPublication by creating()
{
from(components["kotlin"])
artifact(tasks.kotlinSourcesJar)
}
}
}