use an int for version

This commit is contained in:
C10udburst 2022-08-08 16:59:23 +02:00
parent 0df1fcdf08
commit c1a4db8a66
4 changed files with 20 additions and 18 deletions

View file

@ -38,10 +38,10 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) {
internal var pluginClassName: String? = null
val description: Property<String> = project.objects.property(String::class.java)
val authors: ListProperty<String> = project.objects.listProperty(String::class.java)
val adult: Property<Boolean> = project.objects.property(Boolean::class.java)
val status: Property<Int> = project.objects.property(Int::class.java)
var description: String? = null
var authors = listOf<String>()
var isAdult = false
var status = 3
}
class ApkInfo(extension: CloudstreamExtension, release: String) {

View file

@ -8,18 +8,19 @@ import groovy.json.JsonBuilder
fun Project.makeManifest(): PluginManifest {
val extension = this.extensions.getCloudstream()
require(this.version != "unspecified") {
"No version is set"
}
require(extension.pluginClassName != null) {
"No plugin class found, make sure your plugin class is annotated with @CloudstreamPlugin"
}
val version = this.version.toString().toIntOrNull(10)
if (version == null) {
logger.warn("'${project.version}' is not a valid version. Use an integer.")
}
return PluginManifest(
pluginClassName = extension.pluginClassName,
name = this.name,
pluginVersion = this.version.toString(),
pluginVersion = version ?: -1,
apiVersion = extension.apiVersion
)
}
@ -27,22 +28,23 @@ fun Project.makeManifest(): PluginManifest {
fun Project.makePluginEntry(): PluginEntry {
val extension = this.extensions.getCloudstream()
require(this.version != "unspecified") {
"No version is set"
val version = this.version.toString().toIntOrNull(10)
if (version == null) {
logger.warn("'${project.version}' is not a valid version. Use an integer.")
}
val repo = extension.repository
return PluginEntry(
url = (if (repo == null) "" else repo.getRawLink("${this.name}.cs3", "builds")),
status = extension.status.getOrElse(3),
version = this.version.toString(),
status = extension.status,
version = version ?: -1,
name = this.name,
internalName = this.name,
authors = extension.authors.getOrElse(listOf()),
description = extension.description.orNull,
authors = extension.authors,
description = extension.description,
repositoryUrl = (if (repo == null) null else repo.url),
isAdult = extension.adult.getOrElse(false),
isAdult = extension.isAdult,
apiVersion = extension.apiVersion
)
}

View file

@ -3,7 +3,7 @@ package com.lagradost.cloudstream3.gradle.entities
data class PluginEntry(
val url: String,
val status: Int,
val version: String,
val version: Int,
val name: String,
val internalName: String,
val authors: List<String>,

View file

@ -3,6 +3,6 @@ package com.lagradost.cloudstream3.gradle.entities
data class PluginManifest(
val pluginClassName: String?,
val name: String,
val pluginVersion: String,
val pluginVersion: Int,
val apiVersion: Int
)