1
+ import com.vanniktech.maven.publish.SonatypeHost
1
2
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
2
- import java.util.*
3
3
4
4
plugins {
5
5
alias(libs.plugins.kotlin.multiplatform)
@@ -8,7 +8,11 @@ plugins {
8
8
alias(libs.plugins.compose.compiler)
9
9
alias(libs.plugins.android.library)
10
10
alias(libs.plugins.dokka)
11
- id(" maven-publish" )
11
+ // TODO: Migrate back to the Gradle id("maven-publish") plugin when
12
+ // the maven-publish plugin starts to support publishing to Central Portal:
13
+ // https://central.sonatype.org/publish/publish-portal-gradle/
14
+ // See https://www.jetbrains.com/help/kotlin-multiplatform-dev/multiplatform-publish-libraries.html
15
+ alias(libs.plugins.maven.publish)
12
16
id(" signing" )
13
17
}
14
18
@@ -98,13 +102,6 @@ android {
98
102
}
99
103
}
100
104
101
- // Custom javadoc that contains Dokka HTML instead of traditional Java HTML
102
- val javadocJar by tasks.registering(Jar ::class ) {
103
- dependsOn(tasks.dokkaGenerate)
104
- from(tasks.dokkaGeneratePublicationHtml.flatMap { it.outputDirectory })
105
- archiveClassifier = " javadoc"
106
- }
107
-
108
105
dokka {
109
106
moduleName = " Wavy Slider"
110
107
// TODO: Remove this after https://github.com/Kotlin/dokka/issues/3885 is resolved
@@ -137,107 +134,85 @@ dokka {
137
134
}
138
135
}
139
136
140
- val localProperties = Properties ().apply {
141
- rootProject
142
- .runCatching { file(" local.properties" ) }
143
- .getOrNull()
144
- ?.takeIf (File ::exists)
145
- ?.reader()
146
- ?.use(::load)
147
- }
148
- // For information about signing.* properties,
149
- // see comments on signing { ... } block below
150
- extra[" ossrhUsername" ] = localProperties[" ossrh.username" ] as ? String
151
- ? : properties[" ossrh.username" ] as ? String // From gradle.properties in ~/.gradle/ or project root
152
- ? : System .getenv(" OSSRH_USERNAME" )
153
- ? : " "
154
- extra[" ossrhPassword" ] = localProperties[" ossrh.password" ] as ? String
155
- ? : properties[" ossrh.password" ] as ? String // From gradle.properties in ~/.gradle/ or project root
156
- ? : System .getenv(" OSSRH_PASSWORD" )
157
- ? : " "
158
- extra[" githubToken" ] = localProperties[" github.token" ] as ? String
159
- ? : properties[" github.token" ] as ? String // From gradle.properties in ~/.gradle/ or project root
160
- ? : System .getenv(" GITHUB_TOKEN" )
161
- ? : " "
162
-
163
137
publishing {
164
138
repositories {
165
139
maven {
166
140
name = " CustomLocal"
167
141
url = uri(" file://${layout.buildDirectory.get()} /local-repository" )
168
142
}
169
- maven {
170
- name = " MavenCentral"
171
- url = uri(" https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" )
172
- credentials {
173
- username = extra[" ossrhUsername" ]?.toString()
174
- password = extra[" ossrhPassword" ]?.toString()
175
- }
176
- }
177
143
maven {
178
144
name = " GitHubPackages"
179
145
url = uri(" https://maven.pkg.github.com/mahozad/${project.name} " )
180
- credentials {
181
- username = " mahozad "
182
- password = extra[ " githubToken " ]?.toString()
183
- }
146
+ // username and password/token should be specified as `GitHubPackagesUsername` and `GitHubPackagesPassword`
147
+ // in gradle.properties in ~/.gradle/ or project root or from CLI like ./gradlew task -PexampleProperty=...
148
+ // or with environment variables as `ORG_GRADLE_PROJECT_GitHubPackagesUsername` and `ORG_GRADLE_PROJECT_GitHubPackagesPassword`
149
+ credentials(credentialsType = PasswordCredentials :: class )
184
150
}
185
151
}
186
- publications.withType<MavenPublication > {
187
- // Publishes javadoc/kdoc/dokka; for sources see the kotlin block
188
- artifact(javadocJar) // Required a workaround. See the below TODO
189
- pom {
190
- url = " https://mahozad.ir/${project.name} "
191
- name = project.name
192
- description = """
193
- Animated Material wavy slider and progress bar similar to the one introduced in Android 13 media player.
194
- It has curly, wobbly, squiggly, wiggly, jiggly, wriggly, dancing movements.
195
- Some users call it the sperm. Visit the project on GitHub to learn more.
196
- """ .trimIndent()
197
- inceptionYear = " 2023"
198
- licenses {
199
- license {
200
- name = " Apache-2.0 License"
201
- url = " http://www.apache.org/licenses/LICENSE-2.0.txt"
202
- }
203
- }
204
- developers {
205
- developer {
206
- id = " mahozad"
207
- name = " Mahdi Hosseinzadeh"
208
- url = " https://mahozad.ir/"
209
- email = " "
210
- roles = listOf (" Lead Developer" )
211
- timezone = " GMT+4:30"
212
- }
213
- }
214
- contributors {
215
- // contributor {}
216
- }
217
- scm {
218
- tag = " HEAD"
219
- url = " https://github.com/mahozad/${project.name} "
220
- connection = " scm:git:github.com/mahozad/${project.name} .git"
221
- developerConnection = " scm:git:ssh://github.com/mahozad/${project.name} .git"
222
- }
223
- issueManagement {
224
- system = " GitHub"
225
- url = " https://github.com/mahozad/${project.name} /issues"
152
+ // Maven Central Portal is defined below
153
+ }
154
+
155
+ mavenPublishing {
156
+ // GitHub and other Maven repos are defined above
157
+ // Should set Gradle mavenCentralUsername and mavenCentralPassword properties
158
+ publishToMavenCentral(
159
+ host = SonatypeHost .CENTRAL_PORTAL ,
160
+ automaticRelease = false
161
+ )
162
+
163
+ signAllPublications()
164
+
165
+ coordinates(
166
+ groupId = project.group.toString(),
167
+ artifactId = project.name,
168
+ version = project.version.toString()
169
+ )
170
+
171
+ pom {
172
+ url = " https://mahozad.ir/${project.name} "
173
+ name = project.name
174
+ description = """
175
+ Animated Material wavy slider and progress bar similar to the one introduced in Android 13 media player.
176
+ It has curly, wobbly, squiggly, wiggly, jiggly, wriggly, dancing movements.
177
+ Some users call it the sperm. Visit the project on GitHub to learn more.
178
+ """ .trimIndent()
179
+ inceptionYear = " 2023"
180
+ licenses {
181
+ license {
182
+ name = " Apache-2.0 License"
183
+ url = " http://www.apache.org/licenses/LICENSE-2.0.txt"
226
184
}
227
- ciManagement {
228
- system = " GitHub Actions"
229
- url = " https://github.com/mahozad/${project.name} /actions"
185
+ }
186
+ developers {
187
+ developer {
188
+ id = " mahozad"
189
+ name = " Mahdi Hosseinzadeh"
190
+ url = " https://mahozad.ir/"
191
+ email = " "
192
+ roles = listOf (" Lead Developer" )
193
+ timezone = " GMT+4:30"
230
194
}
231
195
}
196
+ contributors {
197
+ // contributor {}
198
+ }
199
+ scm {
200
+ tag = " HEAD"
201
+ url = " https://github.com/mahozad/${project.name} "
202
+ connection = " scm:git:github.com/mahozad/${project.name} .git"
203
+ developerConnection = " scm:git:ssh://github.com/mahozad/${project.name} .git"
204
+ }
205
+ issueManagement {
206
+ system = " GitHub"
207
+ url = " https://github.com/mahozad/${project.name} /issues"
208
+ }
209
+ ciManagement {
210
+ system = " GitHub Actions"
211
+ url = " https://github.com/mahozad/${project.name} /actions"
212
+ }
232
213
}
233
214
}
234
215
235
- // TODO: Remove after https://github.com/gradle/gradle/issues/26091 is fixed
236
- // Thanks to KSoup repository for this code snippet
237
- tasks.withType(AbstractPublishToMaven ::class ).configureEach {
238
- dependsOn(tasks.withType(Sign ::class ))
239
- }
240
-
241
216
/*
242
217
* Uses signing.* properties defined in gradle.properties in ~/.gradle/ or project root
243
218
* Can also pass from command line like below:
0 commit comments