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

53 lines
1.7 KiB
Kotlin
Raw Permalink 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-10-16 08:15:02 +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-09 16:04:41 +00:00
requiresResources = extension.requiresResources
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(
2022-08-31 08:26:20 +00:00
url = (if (repo == null) "" else repo.getRawLink("${this.name}.cs3", extension.buildBranch)),
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),
language = extension.language,
iconUrl = extension.iconUrl,
2022-08-14 12:50:52 +00:00
apiVersion = extension.apiVersion,
tvTypes = extension.tvTypes,
fileSize = extension.fileSize
2022-08-07 19:04:52 +00:00
)
}