-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
252 lines (216 loc) · 8.15 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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.utils.addExtendsFromRelation
import com.google.gson.Gson
plugins {
kotlin("jvm") version "1.6.21"
`java-gradle-plugin`
`maven-publish`
id("com.gradle.plugin-publish") version "1.0.0"
id("org.openapi.generator") version "6.2.1"
}
group = "io.github.frontrider"
version = "0.3.3"
allprojects {
tasks.withType(Javadoc::class.java).all { enabled = false }
}
repositories {
mavenCentral()
}
dependencies {
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
val openapiDir = "$buildDir/generated"
val generatedLicenseSource = project.buildDir.absolutePath+"/license/src"
java {
sourceSets {
main {
this.java.apply{
srcDir("$openapiDir/src/main/java")
}
}
}
}
kotlin {
sourceSets {
main {
this.kotlin.apply{
srcDir(generatedLicenseSource)
}
}
}
}
val functionalTest: SourceSet by sourceSets.creating
val integrationTest: SourceSet by sourceSets.creating
addExtendsFromRelation("integrationTestImplementation", "testImplementation")
addExtendsFromRelation("functionalTestImplementation", "testImplementation")
val swaggerAnnotationsVersion = "1.5.22"
val jacksonVersion = "2.13.4"
val jakartaAnnotationVersion = "1.3.5"
dependencies {
implementation(gradleApi())
testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation("org.apache.commons:commons-lang3:3.12.0")
// https://mvnrepository.com/artifact/commons-io/commons-io
implementation("commons-io:commons-io:2.11.0")
//downloader plugin.
implementation("fi.linuxbox.gradle:gradle-download:0.6")
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
//json parsing to interact with the godot asset store.
implementation("com.fasterxml.jackson.core:jackson-core:2.14.0")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0")
implementation("com.fasterxml.jackson.core:jackson-databind:2.14.0")
// https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
implementation("com.fasterxml.jackson.core:jackson-annotations:2.14.0")
testImplementation(gradleTestKit())
testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
testImplementation("org.junit.platform:junit-platform-runner:1.9.0")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.0")
//corutines for async execution of tests.
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
// https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm
runtimeOnly("org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4")
//git compat, used to fetch some repository information.
// https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit
implementation("org.eclipse.jgit:org.eclipse.jgit:6.4.0.202211300538-r")
//openapi:
implementation("io.swagger:swagger-annotations:$swaggerAnnotationsVersion")
implementation("com.google.code.findbugs:jsr305:3.0.2")
implementation("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")
implementation("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion")
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion")
implementation("org.openapitools:jackson-databind-nullable:0.2.4")
implementation("jakarta.annotation:jakarta.annotation-api:$jakartaAnnotationVersion")
}
pluginBundle {
vcsUrl = "https://github.com/Frontrider/Godle-Publish"
website = vcsUrl
tags = listOf("game development", "godot","publishing")
}
gradlePlugin {
isAutomatedPublishing = false
plugins {
create("godlePublish") {
id = "io.github.frontrider.godle-publish"
displayName = "Godle Publish"
implementationClass = "io.github.frontrider.godle.publish.GodlePublishPlugin"
description = "Publish Godot addons with Gradle."
}
}
testSourceSets(functionalTest)
testSourceSets(integrationTest)
}
publishing {
publications {
create<MavenPublication>("pluginMaven") {
groupId = project.group.toString()
artifactId ="godle-publish"
version = project.version.toString()
from(components["java"])
}
}
}
openApiGenerate {
generatorName.set("java")
inputSpec.set("$rootDir/src/main/resources/AssetStore.yaml")
outputDir.set(openapiDir)
apiPackage.set("godot.assets.api")
modelPackage.set("godot.assets.model")
invokerPackage.set("godot.assets.invoker")
configOptions.putAll(
mapOf(
"annotationLibrary" to "swagger1",
"apiPackage" to "godot.assets.api",
"invokerPackage" to "godot.assets.invoker",
"modelPackage" to "godot.assets.model",
"groupId" to "godot.assets",
"serializationLibrary" to "jackson",
"performBeanValidation" to "false",
"artifactId" to "godot",
"library" to "native",
"ensureUniqueParams" to "true",
"snapshotVersion" to "false",
"dateLibrary" to "legacy",
"sortParamsByRequiredFlag" to "true",
"sortModelPropertiesByRequiredFlag" to "true",
"useSingleRequestParameter" to "false"
)
)
}
val compileKotlin: Task by tasks
//generate license information.
class LicenseData(
var licenseListVersion: String? = null,
var licenses: ArrayList<License> = arrayListOf(),
var releaseDate: String? = null
)
class License(
var reference: String?=null,
var isDeprecatedLicenseId: Boolean?=null,
var detailsUrl: String?=null,
var referenceNumber: Int?=null,
var name: String?=null,
var licenseId: String?=null,
var seeAlso: List<String> = emptyList(),
var isOsiApproved: Boolean?=null
)
val generateLicenseData= tasks.create("generateLicenseData") {
compileKotlin.dependsOn(this)
doFirst {
val text = File(project.rootDir, "/src/main/resources/licenses.json").readText()
val licenseData = Gson().fromJson(text, LicenseData::class.java)
file("$generatedLicenseSource/License.kt").apply {
parentFile.mkdirs()
writeText(
"""
package godle.license
data class License(
var reference: String,
var isDeprecatedLicenseId: Boolean,
var detailsUrl: String,
var referenceNumber: Int,
var name: String,
var licenseId: String,
var seeAlso: List<String>,
var isOsiApproved: Boolean
)
""".trimIndent()
)
}
licenseData.licenses.forEach {
val fileName = it.licenseId!!.replace(".","_")
file("$generatedLicenseSource/${fileName}.kt").apply {
writeText(
"""
package godle.license
import io.github.frontrider.godle.publish.dsl.AddonArtifact
fun AddonArtifact.`${fileName}`():License{
return License(
reference = "${it.reference}",
referenceNumber = ${it.referenceNumber},
isDeprecatedLicenseId = ${it.isDeprecatedLicenseId},
name = ${"\"\"\""+it.name+"\"\"\""},
licenseId = "${it.licenseId}",
isOsiApproved = ${it.isOsiApproved},
detailsUrl= "${it.detailsUrl}",
seeAlso = listOf(
${it.seeAlso.map { also ->
""""$also""""
}.joinToString(",")}
)
)
}
""".trimIndent()
)
}
}
}
}
compileKotlin.dependsOn("openApiGenerate")