Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Apple Framework publishing via Gradle and the jfrog CLI
class FrameworkPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = with(project) {
val zipFramework = tasks.register("zipFatFramework", Zip::class.java) {
it.dependsOn(tasks.named("releaseFatFramework"))
it.from("$buildDir/fat-framework")
it.archiveFileName.set("SomeFramework.framework.zip")
it.destinationDirectory.set(file("$buildDir/fat-framework-zip"))
}
tasks.register("publishFatFrameworkToArtifactory", Exec::class.java) {
it.dependsOn(tasks.named("releaseFatFramework"), zipFramework)
it.commandLine("jfrog", "rt", "u", "$buildDir/fat-framework-zip/SomeFramework.framework.zip", "maven-playground/$groupAsPath/SomeFramework/$version/")
}
val downloadAndModifyJson = tasks.register("downloadAndModifyFrameworkJson", Exec::class.java) {
it.commandLine("jfrog", "rt", "dl", "maven-playground/$groupAsPath/SomeFramework/SomeFramework.json", "$buildDir/")
it.doLast {
file("$buildDir/$groupAsPath/SomeFramework/SomeFramework.json").apply {
if (exists()) {
val currentContent = readText()
if(currentContent.contains("\"$version\"")) return@apply
val replace = currentContent.replace("{", "").replace("}", "")
val newContent = "$replace, \"$version\" : \"https://artifactory.url/maven-playground/$groupAsPath/SomeFramework/$version/SomeFramework.framework.zip\""
writeText("{ $newContent }")
} else {
parentFile.mkdirs()
createNewFile()
writeText("""
{ "$version" : "https://artifactory.url/maven-playground/$groupAsPath/SomeFramework/$version/SomeFramework.framework.zip" }
""".trimIndent())
}
}
}
}
tasks.register("publishFrameworkJsonToArtifactory", Exec::class.java) {
it.dependsOn(downloadAndModifyJson)
it.commandLine("jfrog", "rt", "u", "$buildDir/$groupAsPath/SomeFramework/SomeFramework.json", "maven-playground/$groupAsPath/SomeFramework/")
}
}
private val Project.groupAsPath
get() = (group as String).replace(".", "/")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.