diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/Utils.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/Utils.kt index 70817d8..fee86f0 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/Utils.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/Utils.kt @@ -8,14 +8,23 @@ 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" + } + + return PluginManifest( pluginClassName = extension.pluginClassName!!, name = this.name, version = this.version.toString(), - authors = extension.authors.get(), - repositoryUrl = extension.repositoryUrl.get(), - description = extension.description.get(), - isAdult = extension.isAdult.get(), - status = extension.status.get() ?: 3 + authors = extension.authors.getOrElse(listOf()), + repositoryUrl = extension.repositoryUrl.orNull, + description = extension.description.orNull, + isAdult = extension.isAdult.getOrElse(false), + status = extension.status.getOrElse(3) ) } \ No newline at end of file diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/entities/PluginManifest.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/entities/PluginManifest.kt index 2dd3510..69fb9b6 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/entities/PluginManifest.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/entities/PluginManifest.kt @@ -7,6 +7,6 @@ data class PluginManifest( val authors: List, val repositoryUrl: String?, val description: String?, - val isAdult: Boolean?, + val isAdult: Boolean, val status: Int ) \ No newline at end of file diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/DumpManifestTask.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/DumpManifestTask.kt new file mode 100644 index 0000000..fdb1725 --- /dev/null +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/DumpManifestTask.kt @@ -0,0 +1,22 @@ +package com.lagradost.cloudstream3.gradle.tasks + +import com.lagradost.cloudstream3.gradle.getCloudstream +import com.lagradost.cloudstream3.gradle.makeManifest +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.AbstractCopyTask +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.options.Option +import java.nio.charset.StandardCharsets +import groovy.json.JsonBuilder + +abstract class DumpManifestTask : DefaultTask() { + @TaskAction + fun dumpManifest() { + val manifestFile = project.buildDir.resolve("${project.name}.json") + + manifestFile.writeText( + JsonBuilder(project.makeManifest()).toPrettyString() + ) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/Tasks.kt b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/Tasks.kt index 9360f08..df9000a 100644 --- a/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/Tasks.kt +++ b/src/main/kotlin/com/lagradost/cloudstream3/gradle/tasks/Tasks.kt @@ -52,20 +52,12 @@ fun registerTasks(project: Project) { val manifestFile = intermediates.resolve("manifest.json") it.from(manifestFile) it.doFirst { - require(project.version != "unspecified") { - "No version is set" - } - if (extension.pluginClassName == null) { if (pluginClassFile.exists()) { extension.pluginClassName = pluginClassFile.readText() } } - require(extension.pluginClassName != null) { - "No plugin class found, make sure your plugin class is annotated with @CloudstreamPlugin" - } - manifestFile.writeText( JsonBuilder(project.makeManifest()).toPrettyString() ) @@ -90,6 +82,11 @@ fun registerTasks(project: Project) { it.group = TASK_GROUP } + project.tasks.register("dumpManifest", DumpManifestTask::class.java) { + it.group = TASK_GROUP + it.dependsOn("make") + } + project.tasks.register("deployWithAdb", DeployWithAdbTask::class.java) { it.group = TASK_GROUP it.dependsOn("make")