xref: /aosp_15_r20/external/kotlinx.atomicfu/buildSrc/src/main/kotlin/MavenPomConfiguration.kt (revision 68017707106cb9da9fed635c150bc497c09c160f)
1 @file:JvmName("MavenPomConfiguration")
2 
3 import org.gradle.api.*
4 import org.gradle.api.publish.maven.*
5 
MavenPomnull6 fun MavenPom.configureMavenPluginPomAttributes(
7     project: Project,
8     outputDir: String
9 ) {
10     val customKotlinRepoURL = getCustomKotlinRepositoryURL(project)
11     val buildSnapshots = project.hasProperty("build_snapshot_train")
12     name.set(project.name)
13     packaging = "maven-plugin"
14     description.set("Atomicfu Maven Plugin")
15 
16     withXml {
17         with(asNode()) {
18             with(appendNode("build")) {
19                 appendNode("directory", project.buildDir)
20                 appendNode("outputDirectory", outputDir)
21             }
22             appendNode("properties")
23                 .appendNode("project.build.sourceEncoding", "UTF-8")
24             with(appendNode("repositories")) {
25                 if (!customKotlinRepoURL.isNullOrEmpty()) {
26                     with(appendNode("repository")) {
27                         appendNode("id", "dev")
28                         appendNode("url", customKotlinRepoURL)
29                     }
30                 }
31                 if (buildSnapshots) {
32                     with(appendNode("repository")) {
33                         appendNode("id", "kotlin-snapshots")
34                         appendNode("url", "https://oss.sonatype.org/content/repositories/snapshots")
35                     }
36                 }
37             }
38         }
39     }
40 }
41