Skip to content

Commit

Permalink
build: Publish artifacts on Jitpack
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Oct 14, 2023
1 parent 03be852 commit 70f93bf
Showing 1 changed file with 53 additions and 15 deletions.
68 changes: 53 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import org.gradle.kotlin.dsl.support.listFilesOrdered

plugins {
kotlin("jvm") version "1.8.20"
alias(libs.plugins.ksp)
`maven-publish`
}

group = "app.revanced"
Expand All @@ -27,6 +30,7 @@ dependencies {
implementation(libs.guava)
// Used in JsonGenerator.
implementation(libs.gson)

// A dependency to the Android library unfortunately fails the build, which is why this is required.
compileOnly(project("dummy"))

Expand All @@ -40,40 +44,74 @@ kotlin {
tasks {
register<DefaultTask>("generateBundle") {
description = "Generate dex files from build and bundle them in the jar file"

dependsOn(build)

doLast {
val androidHome = System.getenv("ANDROID_HOME") ?: throw GradleException("ANDROID_HOME not found")
val d8 = "${androidHome}/build-tools/33.0.1/d8"
val input = configurations.archives.get().allArtifacts.files.files.first().absolutePath
val work = layout.buildDirectory.dir("libs").get().asFile
val d8 = File(System.getenv("ANDROID_HOME")).resolve("build-tools")
.listFilesOrdered().last().resolve("d8").absolutePath

val artifacts = configurations.archives.get().allArtifacts.files.files.first().absolutePath
val workingDirectory = layout.buildDirectory.dir("libs").get().asFile

exec {
workingDir = work
commandLine = listOf(d8, input)
workingDir = workingDirectory
commandLine = listOf(d8, artifacts)
}

exec {
workingDir = work
commandLine = listOf("zip", "-u", input, "classes.dex")
workingDir = workingDirectory
commandLine = listOf("zip", "-u", artifacts, "classes.dex")
}
}
}

register<JavaExec>("generateMeta") {
description = "Generate metadata for this bundle"

dependsOn(build)

classpath = sourceSets["main"].runtimeClasspath
mainClass.set("app.revanced.meta.PatchesFileGenerator")
}

// Dummy task to fix the Gradle semantic-release plugin.
// Remove this if you forked it to support building only.
// Tracking issue: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
register<DefaultTask>("publish") {
group = "publish"
description = "Dummy task"
dependsOn(named("generateBundle"), named("generateMeta"))
// Required to run tasks because Gradle semantic-release plugin runs the publish task.
// Tracking: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
named("publish") {
dependsOn("generateBundle")
dependsOn("generateMeta")
}
}

publishing {
publications {
create<MavenPublication>("revanced-patches-publication") {
from(components["java"])

pom {
name = "ReVanced Patches"
description = "Patches for ReVanced."
url = "https://revanced.app"

licenses {
license {
name = "GNU General Public License v3.0"
url = "https://www.gnu.org/licenses/gpl-3.0.en.html"
}
}
developers {
developer {
id = "ReVanced"
name = "ReVanced"
email = "contact@revanced.app"
}
}
scm {
connection = "scm:git:git://github.com/revanced/revanced-patches.git"
developerConnection = "scm:git:git@github.com:revanced/revanced-patches.git"
url = "https://github.com/revanced/revanced-patches"
}
}
}
}
}

0 comments on commit 70f93bf

Please sign in to comment.