-
-
Notifications
You must be signed in to change notification settings - Fork 19
Update distZip
task to use the locally published artifacts via publishToMavenLocal
#425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
buenaflor
merged 13 commits into
deps/upgrade-kotlin
from
chore/update-distribution-generation
Jul 18, 2025
+48
−220
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
17c1920
Update
buenaflor d523c68
Update
buenaflor 4c6b9c3
Update
buenaflor d48b16d
Let CI run for testing
buenaflor 3a7acf7
Update
buenaflor 76963f6
Merge branch 'deps/upgrade-kotlin' into chore/update-distribution-gen…
buenaflor 30484fa
Update
buenaflor 973fe5e
Update
buenaflor 6c59179
Merge branch 'deps/upgrade-kotlin' into chore/update-distribution-gen…
buenaflor 3b031f5
Update
buenaflor 09b194a
Update
buenaflor d9f06ca
Clean up
buenaflor 2de644e
Update use maybeCreate always
buenaflor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,228 +1,47 @@ | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.Project | ||
import org.gradle.api.distribution.DistributionContainer | ||
import org.gradle.api.file.CopySpec | ||
import java.io.File | ||
|
||
val sep: String = File.separator | ||
private val sep: String = File.separator | ||
|
||
// configure distZip tasks for multiplatform | ||
fun DistributionContainer.configureForMultiplatform(project: Project) { | ||
val version = project.properties["versionName"].toString() | ||
this.getByName("main").contents { | ||
from("build${sep}publications${sep}kotlinMultiplatform") { | ||
renameModule(project.name, version = version) | ||
} | ||
// The current Kotlin version doesn't generate this *-all.jar anymore. | ||
// This is a placeholder for backwards compatibility with craft until we fix it there directly. | ||
from("build${sep}libs") { | ||
include("${project.name}-metadata-$version*") | ||
rename { | ||
it.replace("metadata-$version", "$version-all") | ||
} | ||
} | ||
from("build${sep}kotlinToolingMetadata") { | ||
rename { | ||
it.replace( | ||
"kotlin-tooling-metadata.json", | ||
"${project.name}-$version-kotlin-tooling-metadata.json" | ||
) | ||
} | ||
} | ||
from("build${sep}libs") { | ||
include("${project.name}-kotlin*") | ||
include("${project.name}-metadata*") | ||
withJavadoc(project.name) | ||
rename { | ||
it.replace("multiplatform-kotlin", "multiplatform").replace("-metadata", "") | ||
} | ||
} | ||
} | ||
this.maybeCreate("android").contents { | ||
from("build${sep}publications${sep}androidRelease") { | ||
renameModule(project.name, "android", version) | ||
} | ||
from("build${sep}outputs${sep}aar${sep}${project.name}-release.aar") { | ||
rename { | ||
it.replace("-release", "-android-release") | ||
} | ||
} | ||
from("build${sep}libs") { | ||
include("*android*") | ||
withJavadoc(project.name, "android") | ||
} | ||
} | ||
this.maybeCreate("jvm").contents { | ||
from("build${sep}publications${sep}jvm") { | ||
renameModule(project.name, "jvm", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("*jvm*") | ||
withJavadoc(project.name, "jvm") | ||
} | ||
} | ||
this.maybeCreate("iosarm64").contents { | ||
from("build${sep}publications${sep}iosArm64") { | ||
renameModule(project.name, "iosarm64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-iosarm64*") | ||
withJavadoc(project.name, "iosarm64") | ||
} | ||
fromKlib(project.name, "iosArm64", version) | ||
} | ||
this.maybeCreate("iosx64").contents { | ||
from("build${sep}publications${sep}iosX64") { | ||
renameModule(project.name, "iosx64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-iosx64*") | ||
withJavadoc(project.name, "iosx64") | ||
} | ||
fromKlib(project.name, "iosX64", version) | ||
} | ||
this.maybeCreate("iossimulatorarm64").contents { | ||
from("build${sep}publications${sep}iosSimulatorArm64") { | ||
renameModule(project.name, "iossimulatorarm64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-iossimulatorarm64*") | ||
withJavadoc(project.name, "iossimulatorarm64") | ||
} | ||
fromKlib(project.name, "iosSimulatorArm64", version) | ||
} | ||
this.maybeCreate("macosarm64").contents { | ||
from("build${sep}publications${sep}macosArm64") { | ||
renameModule(project.name, "macosarm64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-macosarm64*") | ||
withJavadoc(project.name, "macosarm64") | ||
} | ||
fromKlib(project.name, "macosArm64", version) | ||
} | ||
this.maybeCreate("macosx64").contents { | ||
from("build${sep}publications${sep}macosX64") { | ||
renameModule(project.name, "macosx64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-macosx64*") | ||
withJavadoc(project.name, "macosx64") | ||
} | ||
fromKlib(project.name, "macosX64", version) | ||
} | ||
this.maybeCreate("watchosx64").contents { | ||
from("build${sep}publications${sep}watchosX64") { | ||
renameModule(project.name, "watchosx64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-watchosx64*") | ||
withJavadoc(project.name, "watchosx64") | ||
} | ||
fromKlib(project.name, "watchosX64", version) | ||
} | ||
this.maybeCreate("watchosarm32").contents { | ||
from("build${sep}publications${sep}watchosArm32") { | ||
renameModule(project.name, "watchosarm32", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-watchosarm32*") | ||
withJavadoc(project.name, "watchosarm32") | ||
} | ||
fromKlib(project.name, "watchosArm32", version) | ||
} | ||
this.maybeCreate("watchosarm64").contents { | ||
from("build${sep}publications${sep}watchosArm64") { | ||
renameModule(project.name, "watchosarm64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-watchosarm64*") | ||
withJavadoc(project.name, "watchosarm64") | ||
} | ||
fromKlib(project.name, "watchosArm64", version) | ||
} | ||
this.maybeCreate("watchossimulatorarm64").contents { | ||
from("build${sep}publications${sep}watchosSimulatorArm64") { | ||
renameModule(project.name, "watchossimulatorarm64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-watchossimulatorarm64*") | ||
withJavadoc(project.name, "watchossimulatorarm64") | ||
} | ||
fromKlib(project.name, "watchosSimulatorArm64", version) | ||
} | ||
this.maybeCreate("tvosarm64").contents { | ||
from("build${sep}publications${sep}tvosArm64") { | ||
renameModule(project.name, "tvosarm64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-tvosarm64*") | ||
withJavadoc(project.name, "tvosarm64") | ||
} | ||
fromKlib(project.name, "tvosArm64", version) | ||
} | ||
this.maybeCreate("tvosx64").contents { | ||
from("build${sep}publications${sep}tvosX64") { | ||
renameModule(project.name, "tvosx64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-tvosx64*") | ||
withJavadoc(project.name, "tvosx64") | ||
} | ||
fromKlib(project.name, "tvosX64", version) | ||
} | ||
this.maybeCreate("tvossimulatorarm64").contents { | ||
from("build${sep}publications${sep}tvosSimulatorArm64") { | ||
renameModule(project.name, "tvossimulatorarm64", version) | ||
} | ||
from("build${sep}libs$sep") { | ||
include("${project.name}-tvossimulatorarm64*") | ||
withJavadoc(project.name, "tvossimulatorarm64") | ||
} | ||
fromKlib(project.name, "tvosSimulatorArm64", version) | ||
} | ||
} | ||
fun DistributionContainer.configureForMultiplatform(project: Project, buildPublishDir: String) { | ||
val version = project.property("versionName").toString() | ||
if (version.isEmpty()) { | ||
buenaflor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throw GradleException("DistZip: version name is empty") | ||
} | ||
val projectName = project.name | ||
val platforms = mapOf( | ||
"main" to projectName, | ||
"android" to "$projectName-android", | ||
"jvm" to "$projectName-jvm", | ||
"iosarm64" to "$projectName-iosarm64", | ||
"iossimulatorarm64" to "$projectName-iossimulatorarm64", | ||
"iosx64" to "$projectName-iosx64", | ||
"macosarm64" to "$projectName-macosarm64", | ||
"macosx64" to "$projectName-macosx64", | ||
"tvosarm64" to "$projectName-tvosarm64", | ||
"tvossimulatorarm64" to "$projectName-tvossimulatorarm64", | ||
"tvosx64" to "$projectName-tvosx64", | ||
"watchosarm32" to "$projectName-watchosarm32", | ||
"watchosarm64" to "$projectName-watchosarm64", | ||
"watchossimulatorarm64" to "$projectName-watchossimulatorarm64", | ||
"watchosx64" to "$projectName-watchosx64" | ||
) | ||
|
||
private fun CopySpec.fromKlib(projectName: String, target: String, version: String) { | ||
val pos = projectName.length | ||
from("build${sep}classes${sep}kotlin${sep}${target}${sep}main${sep}cinterop") { | ||
include("*.klib") | ||
rename { | ||
it.replaceRange(pos, pos, "-${target.lowercase()}-$version") | ||
} | ||
} | ||
from("build${sep}classes${sep}kotlin${sep}${target}${sep}main${sep}klib") { | ||
rename { | ||
"$projectName-${target.lowercase()}-$version.klib" | ||
} | ||
} | ||
} | ||
platforms.forEach { (distName, projectName) -> | ||
val distribution = maybeCreate(distName) | ||
distribution.contents { | ||
val basePath = "${buildPublishDir}io${sep}sentry${sep}$projectName$sep$version" | ||
|
||
private fun CopySpec.renameModule(projectName: String, renameTo: String = "", version: String) { | ||
var target = "" | ||
if (renameTo.isNotEmpty()) { | ||
target = "-$renameTo" | ||
} | ||
rename { | ||
it.replace("module.json", "$projectName$target-$version.module") | ||
} | ||
} | ||
// Rename the POM since craft looks for pom-default.xml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ugh, I guess ideal-world we wouldn't need this, but would have to change craft again 🙈 maybe makes sense to align this between repos and change craft at some point |
||
from("$basePath$sep$projectName-$version.pom") { | ||
rename { "pom-default.xml" } | ||
} | ||
|
||
private fun CopySpec.withJavadoc(projectName: String, renameTo: String = "") { | ||
include("*javadoc*") | ||
rename { fileName -> | ||
when { | ||
"javadoc" in fileName -> { | ||
val newName = buildString { | ||
append(fileName.substring(0, projectName.length)) | ||
if (renameTo.isNotEmpty()) { | ||
append('-') | ||
append(renameTo) | ||
} | ||
append(fileName.substring(projectName.length)) | ||
} | ||
newName | ||
from(basePath) { | ||
exclude("*.pom") | ||
} | ||
else -> fileName | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this will tell the task where to publish to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, it then publishes into the specified dir