mirror of
https://github.com/recloudstream/gradle.git
synced 2024-08-14 23:56:59 +00:00
Compare commits
5 commits
ec90f79c5b
...
711629926e
Author | SHA1 | Date | |
---|---|---|---|
|
711629926e | ||
|
a52375b346 | ||
|
2448a204df | ||
|
3580feb0ae | ||
|
17997e15c0 |
3 changed files with 53 additions and 14 deletions
|
@ -17,6 +17,8 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) {
|
||||||
var repository: Repo? = null
|
var repository: Repo? = null
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
|
var buildBranch: String = "builds"
|
||||||
|
|
||||||
fun overrideUrlPrefix(url: String) {
|
fun overrideUrlPrefix(url: String) {
|
||||||
if (apkinfo == null) {
|
if (apkinfo == null) {
|
||||||
apkinfo = ApkInfo(this, "pre-release")
|
apkinfo = ApkInfo(this, "pre-release")
|
||||||
|
@ -24,16 +26,51 @@ abstract class CloudstreamExtension @Inject constructor(project: Project) {
|
||||||
apkinfo!!.urlPrefix = url
|
apkinfo!!.urlPrefix = url
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setRepo(user: String, repo: String) {
|
fun setRepo(user: String, repo: String, url: String, rawLinkFormat: String) {
|
||||||
repository = Repo(user, repo)
|
repository = Repo(user, repo, url, rawLinkFormat)
|
||||||
}
|
}
|
||||||
fun setRepo(identifier: String) {
|
fun setRepo(user: String, repo: String, type: String) {
|
||||||
val split = identifier
|
when {
|
||||||
.removePrefix("https://")
|
type == "github" -> setRepo(user, repo, "https://github.com/${user}/${repo}", "https://raw.githubusercontent.com/${user}/${repo}/%branch%/%filename%")
|
||||||
.removePrefix("github.com")
|
type == "gitlab" -> setRepo(user, repo, "https://gitlab.com/${user}/${repo}", "https://gitlab.com/${user}/${repo}/-/raw/%branch%/%filename%")
|
||||||
.removeSurrounding("/")
|
type.startsWith("gitlab-") -> {
|
||||||
|
val domain = type.removePrefix("gitlab-")
|
||||||
|
setRepo(user, repo, "https://${domain}/${user}/${repo}", "https://${domain}/${user}/${repo}/-/raw/%branch%/%filename%")
|
||||||
|
}
|
||||||
|
type.startsWith("gitea-") -> {
|
||||||
|
val domain = type.removePrefix("gitea-")
|
||||||
|
setRepo(user, repo, "https://${domain}/${user}/${repo}", "https://${domain}/${user}/${repo}/raw/branch/%branch%/%filename%")
|
||||||
|
}
|
||||||
|
else -> throw IllegalArgumentException("Unknown type ${type}. Use github, gitlab, gitlab-<domain> or gitea-<domain> or set repository via setRepo(user, repo, url, rawLinkFormat)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun setRepo(url: String) {
|
||||||
|
var type: String? = null
|
||||||
|
|
||||||
|
var split = when {
|
||||||
|
url.startsWith("https://github.com") -> {
|
||||||
|
type = "github"
|
||||||
|
url
|
||||||
|
.removePrefix("https://")
|
||||||
|
.removePrefix("github.com")
|
||||||
|
}
|
||||||
|
url.startsWith("https://gitlab.com") -> {
|
||||||
|
type = "gitlab"
|
||||||
|
url
|
||||||
|
.removePrefix("https://")
|
||||||
|
.removePrefix("gitlab.com")
|
||||||
|
}
|
||||||
|
!url.startsWith("https://") -> { // assume default as github
|
||||||
|
type = "github"
|
||||||
|
url
|
||||||
|
}
|
||||||
|
else -> throw IllegalArgumentException("Unknown domain, please set repository via setRepo(user, repo, type)")
|
||||||
|
}
|
||||||
|
.removePrefix("/")
|
||||||
|
.removeSuffix("/")
|
||||||
.split("/")
|
.split("/")
|
||||||
repository = Repo(split[0], split[1])
|
|
||||||
|
setRepo(split[0], split[1], type)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var pluginClassName: String? = null
|
internal var pluginClassName: String? = null
|
||||||
|
@ -55,12 +92,11 @@ class ApkInfo(extension: CloudstreamExtension, release: String) {
|
||||||
val jarFile = cache.resolve("cloudstream.jar")
|
val jarFile = cache.resolve("cloudstream.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
class Repo(val user: String, val repo: String) {
|
class Repo(val user: String, val repo: String, val url: String, val rawLinkFormat: String) {
|
||||||
val url: String
|
|
||||||
get() = "https://github.com/${user}/${repo}"
|
|
||||||
|
|
||||||
fun getRawLink(filename: String, branch: String): String {
|
fun getRawLink(filename: String, branch: String): String {
|
||||||
return "https://raw.githubusercontent.com/${user}/${repo}/${branch}/${filename}"
|
return rawLinkFormat
|
||||||
|
.replace("%filename%", filename)
|
||||||
|
.replace("%branch%", branch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ fun Project.makePluginEntry(): PluginEntry {
|
||||||
val repo = extension.repository
|
val repo = extension.repository
|
||||||
|
|
||||||
return PluginEntry(
|
return PluginEntry(
|
||||||
url = (if (repo == null) "" else repo.getRawLink("${this.name}.cs3", "builds")),
|
url = (if (repo == null) "" else repo.getRawLink("${this.name}.cs3", extension.buildBranch)),
|
||||||
status = extension.status,
|
status = extension.status,
|
||||||
version = version ?: -1,
|
version = version ?: -1,
|
||||||
name = this.name,
|
name = this.name,
|
||||||
|
|
|
@ -32,6 +32,7 @@ abstract class CompileResourcesTask : Exec() {
|
||||||
executable = aaptExecutable.path
|
executable = aaptExecutable.path
|
||||||
args("compile")
|
args("compile")
|
||||||
args("--dir", input.asFile.get().path)
|
args("--dir", input.asFile.get().path)
|
||||||
|
args("-v")
|
||||||
args("-o", tmpRes.path)
|
args("-o", tmpRes.path)
|
||||||
execute()
|
execute()
|
||||||
}
|
}
|
||||||
|
@ -49,6 +50,8 @@ abstract class CompileResourcesTask : Exec() {
|
||||||
args("-R", tmpRes.path)
|
args("-R", tmpRes.path)
|
||||||
args("--manifest", manifestFile.asFile.get().path)
|
args("--manifest", manifestFile.asFile.get().path)
|
||||||
args("--auto-add-overlay")
|
args("--auto-add-overlay")
|
||||||
|
args("--warn-manifest-validation")
|
||||||
|
args("-v")
|
||||||
args("-o", outputFile.asFile.get().path)
|
args("-o", outputFile.asFile.get().path)
|
||||||
execute()
|
execute()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue