gradle/src/main/kotlin/com/lagradost/cloudstream3/gradle/Utils.kt

49 lines
1.5 KiB
Kotlin
Raw Normal View History

2022-08-07 19:04:52 +00:00
package com.lagradost.cloudstream3.gradle
import org.gradle.api.Project
import com.lagradost.cloudstream3.gradle.getCloudstream
2022-08-08 09:54:17 +00:00
import com.lagradost.cloudstream3.gradle.entities.*
2022-08-07 19:04:52 +00:00
import groovy.json.JsonBuilder
2022-08-08 09:54:17 +00:00
fun Project.makeManifest(): PluginManifest {
2022-08-07 19:04:52 +00:00
val extension = this.extensions.getCloudstream()
2022-08-08 09:54:17 +00:00
require(extension.pluginClassName != null) {
"No plugin class found, make sure your plugin class is annotated with @CloudstreamPlugin"
2022-08-08 06:09:55 +00:00
}
2022-08-08 07:53:41 +00:00
2022-08-08 14:59:23 +00:00
val version = this.version.toString().toIntOrNull(10)
if (version == null) {
logger.warn("'${project.version}' is not a valid version. Use an integer.")
}
2022-08-07 19:04:52 +00:00
return PluginManifest(
2022-08-08 07:40:35 +00:00
pluginClassName = extension.pluginClassName,
2022-08-07 19:04:52 +00:00
name = this.name,
2022-08-08 19:59:17 +00:00
version = version ?: -1,
2022-08-08 09:54:17 +00:00
)
}
fun Project.makePluginEntry(): PluginEntry {
val extension = this.extensions.getCloudstream()
2022-08-08 14:59:23 +00:00
val version = this.version.toString().toIntOrNull(10)
if (version == null) {
logger.warn("'${project.version}' is not a valid version. Use an integer.")
2022-08-08 09:54:17 +00:00
}
val repo = extension.repository
return PluginEntry(
url = (if (repo == null) "" else repo.getRawLink("${this.name}.cs3", "builds")),
2022-08-08 14:59:23 +00:00
status = extension.status,
version = version ?: -1,
2022-08-08 09:54:17 +00:00
name = this.name,
internalName = this.name,
2022-08-08 14:59:23 +00:00
authors = extension.authors,
description = extension.description,
2022-08-08 09:54:17 +00:00
repositoryUrl = (if (repo == null) null else repo.url),
2022-08-09 15:15:01 +00:00
adult = extension.adult,
2022-08-08 10:35:17 +00:00
apiVersion = extension.apiVersion
2022-08-07 19:04:52 +00:00
)
}