Skip to content

Commit baca360

Browse files
authored
feat: Configure publishing for compose multiplatform artifacts (#2162)
1 parent a0a0b15 commit baca360

File tree

6 files changed

+96
-9
lines changed

6 files changed

+96
-9
lines changed

.craft.yml

+2
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ targets:
4343
maven:io.sentry:sentry-graphql:
4444
maven:io.sentry:sentry-android-navigation:
4545
maven:io.sentry:sentry-compose:
46+
maven:io.sentry:sentry-compose-android:
47+
maven:io.sentry:sentry-compose-desktop:

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
.PHONY: all clean compile dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease
1+
.PHONY: all clean compile javadocs dryRelease update stop checkFormat format api assembleBenchmarkTestRelease assembleUiTestRelease
22

3-
all: stop clean checkFormat compile dryRelease
3+
all: stop clean javadocs compile
44
assembleBenchmarks: stop clean assembleBenchmarkTestRelease
55
assembleUiTests: stop clean assembleUiTestRelease
66

@@ -13,6 +13,9 @@ clean:
1313
compile:
1414
./gradlew build
1515

16+
javadocs:
17+
./gradlew aggregateJavadocs
18+
1619
# do a dry release (like a local deploy)
1720
dryRelease:
1821
./gradlew aggregateJavadocs publishToMavenLocal --no-daemon --no-parallel

build.gradle.kts

+11-7
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,17 @@ subprojects {
104104
val sep = File.separator
105105

106106
configure<DistributionContainer> {
107-
this.getByName("main").contents {
108-
// non android modules
109-
from("build${sep}libs")
110-
from("build${sep}publications${sep}maven")
111-
// android modules
112-
from("build${sep}outputs${sep}aar")
113-
from("build${sep}publications${sep}release")
107+
if (this@subprojects.name.contains("-compose")) {
108+
this.configureForMultiplatform(this@subprojects)
109+
} else {
110+
this.getByName("main").contents {
111+
// non android modules
112+
from("build${sep}libs")
113+
from("build${sep}publications${sep}maven")
114+
// android modules
115+
from("build${sep}outputs${sep}aar")
116+
from("build${sep}publications${sep}release")
117+
}
114118
}
115119
}
116120

buildSrc/src/main/java/Config.kt

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ object Config {
2121
val grettyVersion = "4.0.0"
2222
val gradleMavenPublishPlugin = "com.vanniktech:gradle-maven-publish-plugin:0.18.0"
2323
val dokkaPlugin = "org.jetbrains.dokka:dokka-gradle-plugin:$kotlinVersion"
24+
val dokkaPluginAlias = "org.jetbrains.dokka"
2425
val composeGradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$composeVersion"
2526
}
2627

buildSrc/src/main/java/Publication.kt

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import org.gradle.api.Project
2+
import org.gradle.api.distribution.DistributionContainer
3+
import org.gradle.api.file.CopySpec
4+
import java.io.File
5+
6+
private object Consts {
7+
val taskRegex = Regex("(.*)DistZip")
8+
}
9+
10+
// configure distZip tasks for multiplatform
11+
fun DistributionContainer.configureForMultiplatform(project: Project) {
12+
val sep = File.separator
13+
14+
this.maybeCreate("android").contents {
15+
from("build${sep}publications${sep}androidRelease")
16+
from("build${sep}outputs${sep}aar") {
17+
rename {
18+
it.replace("-release", "-android-${project.version}")
19+
}
20+
}
21+
from("build${sep}libs") {
22+
include("*android*")
23+
withJavadoc(renameTo = "compose-android")
24+
}
25+
}
26+
this.getByName("main").contents {
27+
from("build${sep}publications${sep}kotlinMultiplatform")
28+
from("build${sep}kotlinToolingMetadata")
29+
from("build${sep}libs") {
30+
include("*compose-kotlin*")
31+
rename {
32+
it.replace("-kotlin", "")
33+
}
34+
withJavadoc()
35+
}
36+
}
37+
this.maybeCreate("desktop").contents {
38+
// kotlin multiplatform modules
39+
from("build${sep}publications${sep}desktop")
40+
from("build${sep}libs") {
41+
include("*desktop*")
42+
withJavadoc(renameTo = "compose-desktop")
43+
}
44+
}
45+
46+
// make other distZip tasks run together with the main distZip
47+
project.tasks.getByName("distZip").dependsOn(
48+
*project.tasks.filter { task ->
49+
task.name.matches(Consts.taskRegex)
50+
}.toTypedArray()
51+
)
52+
}
53+
54+
private fun CopySpec.withJavadoc(renameTo: String = "compose") {
55+
include("*javadoc*")
56+
rename {
57+
if (it.contains("javadoc")) {
58+
it.replace("compose", renameTo)
59+
} else {
60+
it
61+
}
62+
}
63+
}

sentry-compose/build.gradle.kts

+14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import io.gitlab.arturbosch.detekt.Detekt
2+
import org.jetbrains.dokka.gradle.DokkaTask
23

34
plugins {
45
kotlin("multiplatform")
@@ -7,6 +8,7 @@ plugins {
78
jacoco
89
id(Config.QualityPlugins.gradleVersions)
910
id(Config.QualityPlugins.detektPlugin)
11+
id(Config.BuildPlugins.dokkaPluginAlias)
1012
`maven-publish` // necessary for publishMavenLocal task to publish correct artifacts
1113
}
1214

@@ -113,3 +115,15 @@ tasks.withType<Detekt> {
113115
// Target version of the generated JVM bytecode. It is used for type resolution.
114116
jvmTarget = JavaVersion.VERSION_1_8.toString()
115117
}
118+
119+
tasks.withType<DokkaTask>().configureEach {
120+
// suppress unattached source sets for docs
121+
dokkaSourceSets {
122+
matching {
123+
it.name.contains("androidandroid", ignoreCase = true) ||
124+
it.name.contains("testfixtures", ignoreCase = true)
125+
}.configureEach {
126+
suppress.set(true)
127+
}
128+
}
129+
}

0 commit comments

Comments
 (0)