build.gradle.kts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. plugins {
  2. kotlin("jvm") version "1.7.0"
  3. }
  4. group = "app.revanced"
  5. val githubUsername: String = project.findProperty("gpr.user") as? String ?: System.getenv("GITHUB_ACTOR")
  6. val githubPassword: String = project.findProperty("gpr.key") as? String ?: System.getenv("GITHUB_TOKEN")
  7. repositories {
  8. mavenCentral()
  9. mavenLocal()
  10. maven {
  11. url = uri("https://maven.pkg.github.com/revanced/revanced-patcher")
  12. credentials {
  13. username = githubUsername
  14. password = githubPassword
  15. }
  16. }
  17. }
  18. dependencies {
  19. implementation("app.revanced:revanced-patcher:6.3.0")
  20. implementation("app.revanced:multidexlib2:2.5.2.r2")
  21. // Required for meta
  22. implementation("com.google.code.gson:gson:2.10")
  23. }
  24. tasks {
  25. register<DefaultTask>("generateBundle") {
  26. description = "Generate dex files from build and bundle them in the jar file"
  27. dependsOn(build)
  28. doLast {
  29. val androidHome = System.getenv("ANDROID_HOME") ?: throw GradleException("ANDROID_HOME not found")
  30. val d8 = "${androidHome}/build-tools/32.0.0/d8"
  31. val input = configurations.archives.get().allArtifacts.files.files.first().absolutePath
  32. val work = File("${buildDir}/libs")
  33. exec {
  34. workingDir = work
  35. commandLine = listOf(d8, input)
  36. }
  37. exec {
  38. workingDir = work
  39. commandLine = listOf("zip", "-u", input, "classes.dex")
  40. }
  41. }
  42. }
  43. register<JavaExec>("generateMeta") {
  44. description = "Generate metadata for this bundle"
  45. dependsOn(build)
  46. classpath = sourceSets["main"].runtimeClasspath
  47. mainClass.set("app.revanced.meta.Meta")
  48. }
  49. // Dummy task to fix the Gradle semantic-release plugin.
  50. // Remove this if you forked it to support building only.
  51. // Tracking issue: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
  52. register<DefaultTask>("publish") {
  53. group = "publish"
  54. description = "Dummy task"
  55. dependsOn(named("generateBundle"), named("generateMeta"))
  56. }
  57. }