@@ -10,9 +10,12 @@ private object Consts {
1010// configure distZip tasks for multiplatform
1111fun DistributionContainer.configureForMultiplatform (project : Project ) {
1212 val sep = File .separator
13+ val version = project.properties[" versionName" ].toString()
1314
1415 this .maybeCreate(" android" ).contents {
15- from(" build${sep} publications${sep} androidRelease" )
16+ from(" build${sep} publications${sep} androidRelease" ) {
17+ renameModule(project.name, " android" , version = version)
18+ }
1619 from(" build${sep} outputs${sep} aar" ) {
1720 include(" *-release*" )
1821 rename {
@@ -25,7 +28,9 @@ fun DistributionContainer.configureForMultiplatform(project: Project) {
2528 }
2629 }
2730 this .getByName(" main" ).contents {
28- from(" build${sep} publications${sep} kotlinMultiplatform" )
31+ from(" build${sep} publications${sep} kotlinMultiplatform" ) {
32+ renameModule(project.name, version = version)
33+ }
2934 from(" build${sep} kotlinToolingMetadata" )
3035 from(" build${sep} libs" ) {
3136 include(" *compose-kotlin*" )
@@ -39,7 +44,9 @@ fun DistributionContainer.configureForMultiplatform(project: Project) {
3944 }
4045 this .maybeCreate(" desktop" ).contents {
4146 // kotlin multiplatform modules
42- from(" build${sep} publications${sep} desktop" )
47+ from(" build${sep} publications${sep} desktop" ) {
48+ renameModule(project.name, " desktop" , version = version)
49+ }
4350 from(" build${sep} libs" ) {
4451 include(" *desktop*" )
4552 withJavadoc(renameTo = " compose-desktop" )
@@ -53,6 +60,26 @@ fun DistributionContainer.configureForMultiplatform(project: Project) {
5360 project.tasks.getByName(" distZip" ).finalizedBy(* platformDists)
5461}
5562
63+ fun DistributionContainer.configureForJvm (project : Project ) {
64+ val sep = File .separator
65+ val version = project.properties[" versionName" ].toString()
66+
67+ this .getByName(" main" ).contents {
68+ // non android modules
69+ from(" build${sep} libs" )
70+ from(" build${sep} publications${sep} maven" ) {
71+ renameModule(project.name, version = version)
72+ }
73+ // android modules
74+ from(" build${sep} outputs${sep} aar" ) {
75+ include(" *-release*" )
76+ }
77+ from(" build${sep} publications${sep} release" ) {
78+ renameModule(project.name, version = version)
79+ }
80+ }
81+ }
82+
5683private fun CopySpec.withJavadoc (renameTo : String = "compose") {
5784 include(" *javadoc*" )
5885 rename {
@@ -63,3 +90,13 @@ private fun CopySpec.withJavadoc(renameTo: String = "compose") {
6390 }
6491 }
6592}
93+
94+ private fun CopySpec.renameModule (projectName : String , renameTo : String = "", version : String ) {
95+ var target = " "
96+ if (renameTo.isNotEmpty()) {
97+ target = " -$renameTo "
98+ }
99+ rename {
100+ it.replace(" module.json" , " $projectName$target -$version .module" )
101+ }
102+ }
0 commit comments